KickJava   Java API By Example, From Geeks To Geeks.

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


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.SOAPConstants;
20
21 public class SOAPBodyTest extends SOAPBodyTestCase {
22
23     public SOAPBodyTest(String JavaDoc testName) {
24         super(testName);
25     }
26
27     protected void setUp() throws Exception JavaDoc {
28         super.setUp();
29     }
30
31     //SOAP 1.1 Body Test (Programaticaly created)----------------------------------------------------------------------------------
32
public void testSOAP11AddFault1() {
33         soap11Body.addFault(new Exception JavaDoc("This an exception for testing"));
34         assertTrue("SOAP 1.1 Body Test:- After calling addFault method, SOAP body has no fault", soap11Body.hasFault());
35
36     }
37
38     public void testSOAP11addFault2() {
39         soap11Body.addFault(soap11Factory.createSOAPFault(soap11Body));
40         assertTrue("SOAP 1.1 Body Test:- After calling addFault method, SOAP body has no fault",soap11Body.hasFault());
41
42
43     }
44
45     public void testSOAP11HasFault() {
46         assertFalse("SOAP 1.1 Body Test:- After creating a soap body it has a fault", soap11Body.hasFault());
47         soap11Body.addFault(new Exception JavaDoc("This an exception for testing"));
48         assertTrue("SOAP 1.1 Body Test:- After calling addFault method, hasFault method returns false", soap11Body.hasFault());
49     }
50
51     public void testSOAP11GetFault() {
52         assertTrue("SOAP 1.1 Body Test:- After creating a soap body it has a fault", soap11Body.getFault() == null);
53         soap11Body.addFault(new Exception JavaDoc("This an exception for testing"));
54         assertFalse("SOAP 1.1 Body Test:- After calling addFault method, getFault method returns null", soap11Body.getFault() == null);
55     }
56
57     //SOAP 1.2 Body Test (Programaticaly Created)----------------------------------------------------------------------------------
58
public void testSOAP12AddFault1() {
59         soap12Body.addFault(new Exception JavaDoc("This an exception for testing"));
60         assertTrue("SOAP 1.2 Body Test:- After calling addFault method, SOAP body has no fault", soap12Body.hasFault());
61         
62     }
63
64     public void testSOAP12AddFault2() {
65         soap12Body.addFault(soap12Factory.createSOAPFault(soap12Body));
66         assertTrue("SOAP 1.2 Body Test:- After calling addFault method, SOAP body has no fault",soap12Body.hasFault());
67     }
68
69     public void testSOAP12HasFault() {
70         assertFalse("SOAP 1.2 Body Test:- After creating a soap body it has a fault", soap12Body.hasFault());
71         soap12Body.addFault(new Exception JavaDoc("This an exception for testing"));
72         assertTrue("SOAP 1.2 Body Test:- After calling addFault method, hasFault method returns false", soap12Body.hasFault());
73     }
74
75     public void testSOAP12GetFault() {
76         assertTrue("SOAP 1.2 Body Test:- After creating a soap body it has a fault", soap12Body.getFault() == null);
77         soap12Body.addFault(new Exception JavaDoc("This an exception for testing"));
78         assertFalse("SOAP 1.2 Body Test:- After calling addFault method, getFault method returns null", soap12Body.getFault() == null);
79     }
80
81     //SOAP 1.1 Body Test (With Parser)-------------------------------------------------------------------------------------------
82
public void testSOAP11HasFaultWithParser() {
83         assertTrue("SOAP 1.1 Body Test With parser :- hasFault method returns false", soap11BodyWithParser.hasFault());
84     }
85
86     public void testSOAP11GetFaultWithParser() {
87         assertFalse("SOAP 1.1 Body Test With parser :- getFault method returns null", soap11BodyWithParser.getFault() == null);
88         assertTrue("SOAP 1.1 Body Test With parser : - SOAP fault name mismatch",soap11BodyWithParser.getFault().getLocalName().equals(SOAPConstants.SOAPFAULT_LOCAL_NAME));
89     }
90
91     //SOAP 1.2 Body Test (With Parser)-------------------------------------------------------------------------------------------------
92
public void testSOAP12HasFaultWithParser() {
93         assertTrue("SOAP 1.2 Body Test With parser :- hasFault method returns false", soap12BodyWithParser.hasFault());
94     }
95
96     public void testSOAP12GetFaultWithParser() {
97         assertFalse("SOAP 1.2 Body Test With parser :- getFault method returns null", soap12BodyWithParser.getFault() == null);
98         assertTrue("SOAP 1.2 Body Test With parser : - SOAP fault name mismatch",soap12BodyWithParser.getFault().getLocalName().equals(SOAPConstants.SOAPFAULT_LOCAL_NAME));
99     }
100 }
101
Popular Tags