KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.axis2.om;
2
3 import org.apache.axis2.soap.SOAPEnvelope;
4 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
5
6 import javax.xml.namespace.QName JavaDoc;
7
8 /**
9  * Copyright 2001-2004 The Apache Software Foundation.
10  * <p/>
11  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12  * use this file except in compliance with the License. You may obtain a copy of
13  * the License at
14  * <p/>
15  * http://www.apache.org/licenses/LICENSE-2.0
16  * <p/>
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
20  * License for the specific language governing permissions and limitations under
21  * the License.
22  * <p/>
23  */

24 public class OMElementTest extends OMTestCase implements OMConstants {
25     private static final String JavaDoc WSA_URI = "http://schemas.xmlsoap.org/ws/2004/03/addressing";
26     private static final String JavaDoc WSA_TO = "To";
27
28
29     public OMElementTest(String JavaDoc testName) {
30         super(testName);
31     }
32
33     /*
34      * @see TestCase#setUp()
35      */

36     protected void setUp() throws Exception JavaDoc {
37
38     }
39
40     public void testGetText(){
41         try {
42             StAXSOAPModelBuilder soapBuilder = getOMBuilder("soap/OMElementTest.xml");
43             SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapBuilder.getDocumentElement();
44             OMElement wsaTo = soapEnvelope.getHeader().getFirstChildWithName(new QName JavaDoc(WSA_URI, WSA_TO));
45
46             String JavaDoc expectedString = "http://localhost:8081/axis/services/BankPort";
47             assertEquals("getText is not returning the correct value", wsaTo.getText().trim(), expectedString);
48         } catch (Exception JavaDoc e) {
49             e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
50
}
51     }
52
53 }
54
Popular Tags