KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > BadInputTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis2.om;
17
18 import org.apache.axis2.soap.SOAPEnvelope;
19
20 import java.io.File JavaDoc;
21
22 public class BadInputTest extends OMTestCase {
23     File JavaDoc dir = new File JavaDoc(testResourceDir, "badsoap");
24
25     public BadInputTest(String JavaDoc testName) {
26         super(testName);
27     }
28
29
30     //done
31
public void testEnvelopeMissing() throws Exception JavaDoc {
32         try {
33             SOAPEnvelope soapEnvelope =
34                     (SOAPEnvelope) OMTestUtils.getOMBuilder(new File JavaDoc(dir, "envelopeMissing.xml")).getDocumentElement();
35             OMTestUtils.walkThrough(soapEnvelope);
36             fail("this must failed gracefully with OMException or AxisFault");
37         } catch (OMException e) {
38             return;
39         }
40
41     }
42
43     //done
44
public void testHeaderBodyWrongOrder() throws Exception JavaDoc {
45         try {
46             SOAPEnvelope soapEnvelope =
47                     (SOAPEnvelope) OMTestUtils.getOMBuilder(new File JavaDoc(dir, "haederBodyWrongOrder.xml")).getDocumentElement();
48             OMTestUtils.walkThrough(soapEnvelope);
49             fail("this must failed gracefully with OMException or AxisFault");
50         } catch (OMException e) {
51             return;
52         }
53     }
54
55     //done
56
// public void testNotnamespaceQualified() throws Exception {
57
// try {
58
// SOAPEnvelope soapEnvelope =
59
// (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "notnamespaceQualified.xml")).getDocumentElement();
60
// OMTestUtils.walkThrough(soapEnvelope);
61
// fail("this must failed gracefully with OMException or AxisFault");
62
// } catch (OMException e) {
63
// return;
64
// } catch (AxisFault e) {
65
// return;
66
// }
67
//
68
// }
69
//done
70
// public void testBodyNotQualified() throws Exception {
71
// try {
72
// SOAPEnvelope soapEnvelope =
73
// (SOAPEnvelope) OMTestUtils.getOMBuilder(new File(dir, "bodyNotQualified.xml")).getDocumentElement();
74
// OMTestUtils.walkThrough(soapEnvelope);
75
// fail("this must failed gracefully with OMException or AxisFault");
76
// } catch (OMException e) {
77
// //we are OK!
78
// return;
79
// } catch (AxisFault e) {
80
// //we are OK here too!
81
// return;
82
// }
83
//
84
// }
85

86     //done
87
public void testTwoBodymessage() throws Exception JavaDoc {
88         try {
89             SOAPEnvelope soapEnvelope =
90                     (SOAPEnvelope) OMTestUtils.getOMBuilder(new File JavaDoc(dir, "twoBodymessage.xml")).getDocumentElement();
91             OMTestUtils.walkThrough(soapEnvelope);
92             fail("this must failed gracefully with OMException or AxisFault");
93         } catch (OMException e) {
94             return;
95         }
96
97     }
98
99     //done
100
public void testTwoheaders() throws Exception JavaDoc {
101         try {
102             SOAPEnvelope soapEnvelope =
103                     (SOAPEnvelope) OMTestUtils.getOMBuilder(new File JavaDoc(dir, "twoheaders.xml")).getDocumentElement();
104             OMTestUtils.walkThrough(soapEnvelope);
105             fail("this must failed gracefully with OMException or AxisFault");
106         } catch (OMException e) {
107             return;
108         }
109
110     }
111
112     //done
113
public void testWrongSoapNs() throws Exception JavaDoc {
114         try {
115             SOAPEnvelope soapEnvelope =
116                     (SOAPEnvelope) OMTestUtils.getOMBuilder(new File JavaDoc(dir, "wrongSoapNs.xml")).getDocumentElement();
117             OMTestUtils.walkThrough(soapEnvelope);
118             fail("this must failed gracefully with OMException or AxisFault");
119         } catch (OMException e) {
120             return;
121         }
122
123     }
124
125     // public void testAllMessagesInBadSOAP() throws OMException, Exception{
126
// File dir = ;
127
// File[] files = dir.listFiles();
128
//
129
// if(files != null){
130
// for(int i = 0;i<files.length;i++){
131
// System.out.print(files[i] + "=");
132
// try {
133
// if(files[i].isFile() && files[i].getName().endsWith(".xml")){
134
// SOAPEnvelope soapEnvelope = (SOAPEnvelope) OMTestUtils.getOMBuilder(
135
// files[i]).getDocumentElement();
136
// OMTestUtils.walkThrough(soapEnvelope);
137
// }
138
// } catch (OMException e) {
139
// System.out.println(e);
140
// }catch(AxisFault e){
141
// System.out.println(e);
142
// }catch(Exception e){
143
// e.printStackTrace();
144
// fail("must failed gracefully with OMException or AxisFault");
145
// return;
146
// }
147
// }
148
// }
149
// }
150

151
152 }
153
Popular Tags