KickJava   Java API By Example, From Geeks To Geeks.

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


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.SOAPBody;
19 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
20
21 public class OMBodyTest extends OMTestCase implements OMConstants {
22     SOAPBody soapBody;
23
24     public OMBodyTest(String JavaDoc testName) {
25         super(testName);
26     }
27
28     /*
29      * @see TestCase#setUp()
30      */

31     protected void setUp() throws Exception JavaDoc {
32         super.setUp();
33         soapBody = soapEnvelope.getBody();
34     }
35
36     /*
37      * Class under test for SOAPFault addFault()
38      */

39     public void testAddFault() {
40         System.out.println("Adding SOAP fault to body ....");
41         try {
42             soapBody.addChild(soapFactory.createSOAPFault(soapBody, new Exception JavaDoc("Testing soap fault")));
43         } catch (SOAPProcessingException e) {
44             e.printStackTrace();
45             fail(e.getMessage());
46         }
47         System.out.println("\t checking for SOAP Fault ...");
48         assertTrue("SOAP body has no SOAP fault", soapBody.hasFault());
49         System.out.println("\t checking for not-nullity ...");
50         assertTrue("SOAP body has no SOAP fault", soapBody.getFault() != null);
51
52         //SimpleOMSerializer simpleOMSerializer = new SimpleOMSerializer();
53
//simpleOMSerializer.serializeWithCache(soapBody, System.out);
54
}
55
56 }
57
Popular Tags