KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > SOAPFaultCodeTest


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
17 package org.apache.axis2.soap;
18
19 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
20 import org.apache.axis2.soap.impl.llom.soap12.SOAP12Constants;
21
22 public class SOAPFaultCodeTest extends SOAPFaultCodeTestCase {
23
24     public SOAPFaultCodeTest(String JavaDoc testName) {
25         super(testName);
26     }
27
28     protected void setUp() throws Exception JavaDoc {
29         super.setUp();
30     }
31
32     //SOAP 1.1 Fault Code Test (Programaticaly Created)
33
public void testSOAP11SetValue() {
34         soap11FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode));
35         assertFalse("SOAP 1.1 Fault Code Test :- After calling setValue method, getValue method returns null",soap11FaultCode.getValue() == null);
36         try{
37             soap11FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode));
38             fail("SOAP12FaultValue should not be inserted to SOAP11FaultCode");
39         } catch (SOAPProcessingException e) {
40             assertTrue(true);
41         }
42
43     }
44
45     public void testSOAP11GetValue() {
46         assertTrue("SOAP 1.1 Fault Code Test :- After creating soapfaultcode, it has a value",soap11FaultCode.getValue() == null);
47         soap11FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode));
48         assertFalse("SOAP 1.1 Fault Code Test :- After calling setValue method, getValue method returns null",soap11FaultCode.getValue() == null);
49     }
50
51     //SOAP 1.2 Fault Code Test (Programaticaly Created)
52
public void testSOAP12SetValue() {
53         soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode));
54         assertFalse("SOAP 1.2 Fault Code Test :- After calling setValue method, getValue method returns null",soap12FaultCode.getValue() == null);
55         try{
56             soap12FaultCode.setValue(soap11Factory.createSOAPFaultValue(soap11FaultCode));
57             fail("SOAP11FaultValue should not be inserted to SOAP12FaultCode");
58         } catch (SOAPProcessingException e) {
59             assertTrue(true);
60         }
61
62         try {
63             soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12Factory.createSOAPFaultSubCode(soap12FaultCode)));
64         } catch (Exception JavaDoc e) {
65             fail("SOAP 1.2 Fault Code Test :- When calling setValue method, parent of value element mismatch");
66         }
67     }
68
69     public void testSOAP12GetValue() {
70         assertTrue("SOAP 1.2 Fault Code Test :- After creating soapfaultcode, it has a value",soap12FaultCode.getValue() == null);
71         soap12FaultCode.setValue(soap12Factory.createSOAPFaultValue(soap12FaultCode));
72         assertFalse("SOAP 1.2 Fault Code Test :- After calling setValue method, getValue method returns null",soap12FaultCode.getValue() == null);
73     }
74
75     public void testSOAP12SetSubCode() {
76         soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode));
77         assertFalse("SOAP 1.2 Fault Code Test :- After calling setSubCode method, getSubCode method returns null",soap12FaultCode.getSubCode() == null);
78         try{
79             soap12FaultCode.setSubCode(soap11Factory.createSOAPFaultSubCode(soap11FaultCode));
80             fail("SOAP11FaultSubCode should not be inserted to SOAP12FaultCode");
81         } catch (SOAPProcessingException e) {
82             assertTrue(true);
83         }
84
85         try {
86             soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode)));
87         } catch (Exception JavaDoc e) {
88             fail("SOAP 1.2 Fault Code Test :- When calling setSubCode method, parent of subcode element mismatch");
89         }
90     }
91
92     public void testSOAP12GetSubCode() {
93         assertTrue("SOAP 1.2 Fault Code Test :- After creating soapfaultcode, it has a subcode",soap12FaultCode.getSubCode() == null);
94         soap12FaultCode.setSubCode(soap12Factory.createSOAPFaultSubCode(soap12FaultCode));
95         assertFalse("SOAP 1.2 Fault Code Test :- After calling setSubCode method, getSubCode method returns null",soap12FaultCode.getSubCode() == null);
96     }
97
98     //SOAP 1.1 Fault Code Test (With Parser)
99
public void testSOAP11GetValueWithParser() {
100         assertFalse("SOAP 1.1 Fault Code Test with parser : - getValue method returns null",soap11FaultCodeWithParser.getValue() == null);
101         assertTrue("SOAP 1.1 Fault Code Test with parser : - Value local name mismatch",soap11FaultCodeWithParser.getValue().getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
102     }
103
104     //SOAP 1.2 Fault Code Test (With Parser)
105
public void testSOAP12GetValueWithParser() {
106         assertFalse("SOAP 1.2 Fault Code Test with parser : - getValue method returns null",soap12FaultCodeWithParser.getValue() == null);
107         assertTrue("SOAP 1.2 Fault Code Test with parser : - Value local name mismatch",soap12FaultCodeWithParser.getValue().getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
108     }
109
110     public void testSOAP12GetSubCodeWithParser() {
111         assertFalse("SOAP 1.2 Fault Code Test with parser :- getSubCode method returns null",soap12FaultCodeWithParser.getSubCode() == null);
112         assertTrue("SOAP 1.2 Fault Code Test with parser : - subcode local name mismatch",soap12FaultCodeWithParser.getSubCode().getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME));
113     }
114 }
115
Popular Tags