KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > impl > traverse > OMChildrenWithSpecificAttributeIteratorTest


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.impl.traverse;
17
18 import org.apache.axis2.om.OMConstants;
19 import org.apache.axis2.om.OMTestCase;
20
21 public class OMChildrenWithSpecificAttributeIteratorTest extends OMTestCase implements OMConstants {
22     private String JavaDoc sampleSOAPMessage = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">\n" +
23                     " <soapenv:Header>\n" +
24                     " <wsa:MessageID soapenv:mustUnderstand=\"1\">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>\n" +
25                     " <wsa:To soapenv:mustUnderstand=\"0\">http://localhost:8081/axis/services/BankPort</wsa:To>\n" +
26                     " <wsa:From soapenv:mustUnderstand=\"1\">\n" +
27                     " <Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address>\n" +
28                     " </wsa:From>\n" +
29                     " </soapenv:Header>\n" +
30                     " <soapenv:Body>\n" +
31                     " <axis2:echoVoid xmlns:axis2=\"http://ws.apache.org/axis2\" ></axis2:echoVoid>\n" +
32                     " </soapenv:Body>\n" +
33                     "</soapenv:Envelope>";
34
35     public OMChildrenWithSpecificAttributeIteratorTest(String JavaDoc testName) {
36         super(testName);
37     }
38
39     public static void main(String JavaDoc[] args) {
40         junit.textui.TestRunner
41         .run(OMChildrenWithSpecificAttributeIteratorTest.class);
42     }
43
44     /*
45      * @see TestCase#setUp()
46      */

47     protected void setUp() throws Exception JavaDoc {
48         super.setUp();
49     }
50
51     public void testChildrenRetrievalWithNoDetach() {
52         // try {
53
// soapEnvelope = getOMBuilder(new ByteArrayInputStream(sampleSOAPMessage.getBytes())).getSOAPEnvelope();
54
// SOAPHeader soapHeader = soapEnvelope.getHeader();
55
//
56
// // getting header blocks with mustUnderstand="0"
57
// OMChildrenWithSpecificAttributeIterator iter = new OMChildrenWithSpecificAttributeIterator(soapHeader.getFirstChild(), new QName(SOAP_ENVELOPE_NAMESPACE_URI, ATTR_MUSTUNDERSTAND), "0", false);
58
//
59
// if (iter.hasNext()) {
60
// SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) iter.next();
61
// assertEquals("Header Block with mustUnderstand=\")0\" has not been retrieved properly", soapHeaderBlock.getLocalName(), AddressingConstants.WSA_TO);
62
// }
63
//
64
// if (iter.hasNext()) {
65
// fail("Given sample SOAP doesn't have more than one mustunderstand false header blocks");
66
// }
67
//
68
//
69
// } catch (Exception e) {
70
// e.printStackTrace();
71
// fail("Something has gone wrong in accessing the test xml file");
72
// }
73
}
74
75     public void testChildrenRetrievalWithDetach() throws Exception JavaDoc {
76         // soapEnvelope = getOMBuilder(new ByteArrayInputStream(sampleSOAPMessage.getBytes())).getSOAPEnvelope();
77
// SOAPHeader soapHeader = soapEnvelope.getHeader();
78
//
79
// OMChildrenWithSpecificAttributeIterator iter = new OMChildrenWithSpecificAttributeIterator(soapHeader.getFirstChild(), new QName(SOAP_ENVELOPE_NAMESPACE_URI, ATTR_MUSTUNDERSTAND), "0", true);
80
// if (iter.hasNext()) {
81
// SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) iter.next();
82
// assertEquals("Header Block with mustUnderstand=\")0\" has not been retrieved properly", soapHeaderBlock.getLocalName(), AddressingConstants.WSA_TO);
83
// }
84
//
85
// Iterator soapHeaderChildrenIter = soapHeader.getChildren();
86
// int childrenCount = 0;
87
// while (soapHeaderChildrenIter.hasNext()) {
88
// Object o = soapHeaderChildrenIter.next();
89
// childrenCount++;
90
// }
91
//
92
// assertEquals("OMChildrenWithSpecificAttributeIterator with detach true, not working properly", childrenCount, 6); // here this 6 includes white spaces as OMText
93

94     }
95
96
97 }
98
Popular Tags