KickJava   Java API By Example, From Geeks To Geeks.

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


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.SOAPEnvelope;
20 import org.apache.axis2.soap.SOAPHeader;
21 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
22
23 public class OMEnvelopeTest extends OMTestCase {
24     public OMEnvelopeTest(String JavaDoc testName) {
25         super(testName);
26     }
27
28     protected void setUp() throws Exception JavaDoc {
29         super.setUp();
30     }
31
32     public void testGetHeader1() {
33         SOAPHeader header = soapEnvelope.getHeader();
34         assertTrue("Header information retrieved not correct", (header != null && header.getLocalName().equalsIgnoreCase("Header")));
35     }
36
37     public void testGetBody1() {
38         SOAPBody body = soapEnvelope.getBody();
39         assertTrue("Header information retrieved not correct", (body != null && body.getLocalName().equalsIgnoreCase("Body")));
40     }
41
42     private SOAPEnvelope getSecondEnvelope() throws Exception JavaDoc {
43         return (SOAPEnvelope) OMTestUtils.getOMBuilder(getTestResourceFile("soap/sample1.xml")).getDocumentElement();
44     }
45
46     public void testGetHeader2() throws Exception JavaDoc {
47         SOAPHeader header = getSecondEnvelope().getHeader();
48         assertTrue("Header information retrieved not correct", (header != null && header.getLocalName().equalsIgnoreCase("Header")));
49     }
50
51     public void testGetBody2() throws Exception JavaDoc {
52         SOAPBody body = getSecondEnvelope().getBody();
53         assertTrue("Header information retrieved not correct", (body != null && body.getLocalName().equalsIgnoreCase("Body")));
54     }
55
56     public void testDefaultEnveleope() {
57         SOAPEnvelope env = null;
58         try {
59             env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
60         } catch (SOAPProcessingException e) {
61             e.printStackTrace();
62             fail(e.getMessage());
63         }
64         assertNotNull(env);
65         assertNotNull("Header should not be null", env.getHeader());
66         assertNotNull("Body should not be null", env.getBody());
67
68     }
69
70 }
71
Popular Tags