You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [133/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/a...
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTest.java Thu Sep 15 11:52:11 2005
@@ -1,466 +1,466 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.soap;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-public class SOAPHeaderTest extends SOAPHeaderTestCase {
- protected boolean isThereException;
-
- public SOAPHeaderTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- //SOAP 1.1 Header Test (Programaticaly Created)--------------------------------------------------------------------------------
- public void testSOAP11AddHeadearBlock() {
- soap11Header.addHeaderBlock("echoOk1", namespace);
- soap11Header.addHeaderBlock("echoOk2", namespace);
- Iterator iterator = soap11Header.getChildren();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns empty iterator",
- headerBlock1 == null);
- assertTrue("SOAP 1.1 Header Test : - HeaderBlock1 local name mismatch",
- headerBlock1.getLocalName().equals("echoOk1"));
- assertTrue(
- "SOAP 1.1 Header Test : - HeaderBlock1 namespace uri mismatch",
- headerBlock1.getNamespace().getName().equals(
- "http://www.example.org"));
-
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with only one object",
- headerBlock2 == null);
- assertTrue("SOAP 1.1 Header Test : - HeaderBlock2 local name mismatch",
- headerBlock2.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.1 Header Test : - HeaderBlock2 namespace uri mismatch",
- headerBlock2.getNamespace().getName().equals(
- "http://www.example.org"));
-
- assertTrue(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with more than two object",
- iterator.next() == null);
- }
-
- public void testSOAP11ExamineHeaderBlocks() {
- soap11Header.addHeaderBlock("echoOk1", namespace).setRole(
- "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
- ;
- soap11Header.addHeaderBlock("echoOk2", namespace).setRole(
- "http://schemas.xmlsoap.org/soap/envelope/actor/next");
- Iterator iterator = soap11Header.examineHeaderBlocks(
- "http://schemas.xmlsoap.org/soap/envelope/actor/next");
- iterator.hasNext();
- SOAPHeaderBlock headerBlockWithRole1 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test : - headerBlockWithRole local name mismatch",
- headerBlockWithRole1.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.1 Header Test : - headerBlockWithRole role value mismatch",
- headerBlockWithRole1.getRole().equals(
- "http://schemas.xmlsoap.org/soap/envelope/actor/next"));
-
-
- assertFalse(
- "SOAP 1.1 Header Test : - header has three headerBlocks with the given role, but examineHeaderBlocks(String role) method returns an iterator with more than three objects",
- iterator.hasNext());
- }
-
-// public void testSOAP11ExtractHeaderBlocks() {
-
-// }
-
-
-
- public void testSOAP11ExamineAllHeaderBlocks() {
- soap11Header.addHeaderBlock("echoOk1", namespace);
- soap11Header.addHeaderBlock("echoOk2", namespace);
- Iterator iterator = soap11Header.examineAllHeaderBlocks();
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator",
- headerBlock1 == null);
- assertTrue("SOAP 1.1 Header Test : - HeaderBlock1 local name mismatch",
- headerBlock1.getLocalName().equals("echoOk1"));
- assertTrue(
- "SOAP 1.1 Header Test : - HeaderBlock1 namespace uri mismatch",
- headerBlock1.getNamespace().getName().equals(
- "http://www.example.org"));
-
- iterator.hasNext();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object",
- headerBlock2 == null);
- assertTrue("SOAP 1.1 Header Test : - HeaderBlock2 local name mismatch",
- headerBlock2.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.1 Header Test : - HeaderBlock2 namespace uri mismatch",
- headerBlock2.getNamespace().getName().equals(
- "http://www.example.org"));
-
- assertFalse(
- "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object",
- iterator.hasNext());
-
- }
-
-// public void testSOAP11ExtractAllHeaderBlocks() {
-//
-// }
-
-
- public void testSOAP11getHeaderBlocksWithNSURI() {
- soap11Header.addHeaderBlock("echoOk1", namespace);
- soap11Header.addHeaderBlock("echoOk2",
- omFactory.createOMNamespace("http://www.test1.org", "test1"));
- ArrayList arrayList = soap11Header.getHeaderBlocksWithNSURI(
- "http://www.test1.org");
- assertTrue(
- "SOAP 1.1 Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
- arrayList.size() == 1);
- assertTrue(
- "SOAP 1.1 Header Test : - headerBlock of given namespace uri mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
- .equals("http://www.test1.org"));
- }
-
- //SOAP 1.2 Header Test (Programaticaly Created)----------------------------------------------------------------------------------
- public void testSOAP12AddHeadearBlock() {
- soap12Header.addHeaderBlock("echoOk1", namespace);
- soap12Header.addHeaderBlock("echoOk2", namespace);
- Iterator iterator = soap12Header.getChildren();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method, getChildren method returns empty iterator",
- headerBlock1 == null);
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock1 local name mismatch",
- headerBlock1.getLocalName().equals("echoOk1"));
- assertTrue(
- "SOAP 1.2 Header Test : - HeaderBlock1 namespace uri mismatch",
- headerBlock1.getNamespace().getName().equals(
- "http://www.example.org"));
-
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method, getChildren method returns an iterator with only one object",
- headerBlock2 == null);
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock2 local name mismatch",
- headerBlock2.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.2 Header Test : - HeaderBlock2 namespace uri mismatch",
- headerBlock2.getNamespace().getName().equals(
- "http://www.example.org"));
-
- assertTrue(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with more than two elements",
- iterator.next() == null);
- }
-
- public void testSOAP12ExamineHeaderBlocks() {
- soap12Header.addHeaderBlock("echoOk1", namespace);
- soap12Header.addHeaderBlock("echoOk2", namespace).setRole(
- "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
- Iterator iterator = soap12Header.examineHeaderBlocks(
- "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
- iterator.hasNext();
- SOAPHeaderBlock headerBlockWithRole = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test : - headerBlockWithRole local name mismatch",
- headerBlockWithRole.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.2 Header Test : - headerBlockWithRole role value mismatch",
- headerBlockWithRole.getRole().equals(
- "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver"));
-
- assertFalse(
- "SOAP 1.2 Header Test : - header has one headerBlock with role, but examineHeaderBlocks(String role) method returns an iterator with more than one object",
- iterator.hasNext());
-
- }
-
-
- public void testSOAP12ExamineMustUnderstandHeaderBlocks() {
- soap12Header.addHeaderBlock("echoOk1", namespace).setRole(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
-
- SOAPHeaderBlock headerBlock1 = soap12Header.addHeaderBlock("echoOk2",
- namespace);
- headerBlock1.setRole(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
- headerBlock1.setMustUnderstand(true);
-
- soap12Header.addHeaderBlock("echoOk3", namespace).setMustUnderstand(
- true);
-
- Iterator iterator = soap12Header.examineMustUnderstandHeaderBlocks(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
- iterator.hasNext();
- SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.2 Header Test : - examineMustUnderstandHeaderBlocks method returns empty iterator",
- headerBlock == null);
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock local name mismatch",
- headerBlock.getLocalName().equals("echoOk2"));
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock role value mismatch",
- headerBlock.getRole().equals(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
- assertFalse(
- "SOAP 1.2 Header Test : - examineMustUnderstandHeaderBlocks method returns an iterator with more than one object",
- iterator.hasNext());
- }
-
- public void testSOAP12ExamineAllHeaderBlocks() {
- soap12Header.addHeaderBlock("echoOk1", namespace);
- soap12Header.addHeaderBlock("echoOk2", namespace);
- Iterator iterator = soap12Header.examineAllHeaderBlocks();
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator",
- headerBlock1 == null);
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock1 local name mismatch",
- headerBlock1.getLocalName().equals("echoOk1"));
- assertTrue(
- "SOAP 1.2 Header Test : - HeaderBlock1 namespace uri mismatch",
- headerBlock1.getNamespace().getName().equals(
- "http://www.example.org"));
-
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertFalse(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object",
- headerBlock2 == null);
- assertTrue("SOAP 1.2 Header Test : - HeaderBlock2 local name mismatch",
- headerBlock2.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.2 Header Test : - HeaderBlock2 namespace uri mismatch",
- headerBlock2.getNamespace().getName().equals(
- "http://www.example.org"));
-
- assertFalse(
- "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object",
- iterator.hasNext());
- }
-// public void testSOAP12ExtractAllHeaderBlocks() {
-//
-// }
-
- public void testSOAP12getHeaderBlocksWithNSURI() {
- soap12Header.addHeaderBlock("echoOk1", namespace);
- soap12Header.addHeaderBlock("echoOk2",
- omFactory.createOMNamespace("http://www.test1.org", "test1"));
- ArrayList arrayList = soap12Header.getHeaderBlocksWithNSURI(
- "http://www.test1.org");
- assertTrue(
- "SOAP 1.2 Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
- arrayList.size() == 1);
- assertTrue(
- "SOAP 1.2 Header Test : - headerBlock of given namespace uri, mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
- .equals("http://www.test1.org"));
- }
-
- //SOAP 1.1 Header Test (With Parser)---------------------------------------------------------------------------------------------
- public void testSOAP11ExamineHeaderBlocksWithParser() {
- Iterator iterator = soap11HeaderWithParser.examineHeaderBlocks(
- "http://schemas.xmlsoap.org/soap/actor/next");
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertEquals(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mismatch",
- headerBlock1.getLocalName(),
- "From");
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 role value mismatch",
- headerBlock1.getRole().equals(
- "http://schemas.xmlsoap.org/soap/actor/next"));
- iterator.hasNext();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock2 localname mmismatch",
- headerBlock2.getLocalName().equals("MessageID"));
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock2 role value mmismatch",
- headerBlock2.getRole().equals(
- "http://schemas.xmlsoap.org/soap/actor/next"));
-
- assertFalse(
- "SOAP 1.1 Header Test With Parser : - examineHeaderBlocks(String role) method returns an iterator with more than two objects",
- iterator.hasNext());
- }
-
- public void testSOAP11ExamineMustUnderstandHeaderBlocksWithParser() {
- Iterator iterator = soap11HeaderWithParser.examineMustUnderstandHeaderBlocks(
- "http://schemas.xmlsoap.org/soap/actor/next");
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock1.getLocalName().equals("MessageID"));
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 role value mmismatch",
- headerBlock1.getRole().equals(
- "http://schemas.xmlsoap.org/soap/actor/next"));
-
- assertFalse(
- "SOAP 1.1 Header Test With Parser : - examineMustUnderstandHeaderBlocks(String role) method returns an iterator with more than one objects",
- iterator.hasNext());
- }
-
- public void testSOAP11ExamineAllHeaderBlocksWithParser() {
- Iterator iterator = soap11HeaderWithParser.examineAllHeaderBlocks();
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock1.getLocalName().equals("From"));
- iterator.hasNext();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock2.getLocalName().equals("MessageID"));
- iterator.hasNext();
- SOAPHeaderBlock headerBlock3 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock3.getLocalName().equals("To"));
-
- assertFalse(
- "SOAP 1.1 Header Test With Parser : - examineAllHeaderBlocks method returns an iterator with more than three objects",
- iterator.hasNext());
- }
-
- public void testSOAP11getHeaderBlocksWithNSURIWithParser() {
- ArrayList arrayList = soap11HeaderWithParser.getHeaderBlocksWithNSURI(
- "http://example.org/ts-tests");
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
- arrayList.size() == 1);
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock of given namespace uri, local name mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getLocalName().equals(
- "MessageID"));
- assertTrue(
- "SOAP 1.1 Header Test With Parser : - headerBlock of given namespace uri, mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
- .equals("http://example.org/ts-tests"));
- }
-
- //SOAP 1.2 Header Test (With Parser)-------------------------------------------------------------------------------------------
- public void testSOAP12ExamineHeaderBlocksWithParser() {
- Iterator iterator = soap12HeaderWithParser.examineHeaderBlocks(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock1.getLocalName().equals("echoOk"));
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock1 role value mmismatch",
- headerBlock1.getRole().equals(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
- iterator.hasNext();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock2 localname mmismatch",
- headerBlock2.getLocalName().equals("echoOk2"));
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock2 role value mmismatch",
- headerBlock2.getRole().equals(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
-
- assertFalse(
- "SOAP 1.2 Header Test With Parser : - examineHeaderBlocks(String role) method returns an iterator with more than two objects",
- iterator.hasNext());
- }
-
- public void testSOAP12ExamineMustUnderstandHeaderBlocksWithParser() {
- Iterator iterator = soap12HeaderWithParser.examineMustUnderstandHeaderBlocks(
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
- iterator.hasNext();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertEquals(
- "SOAP 1.2 Header Test With Parser : - headerBlock localname mmismatch",
- headerBlock1.getLocalName(),
- "echoOk");
- assertEquals(
- "SOAP 1.2 Header Test With Parser : - headerBlock role value mmismatch",
- headerBlock1.getRole(),
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
-
- iterator.hasNext();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertEquals(
- "SOAP 1.2 Header Test With Parser : - headerBlock localname mmismatch",
- headerBlock2.getLocalName(),
- "echoOk2");
- assertEquals(
- "SOAP 1.2 Header Test With Parser : - headerBlock role value mmismatch",
- headerBlock1.getRole(),
- "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
-
- assertFalse(
- "SOAP 1.2 Header Test With Parser : - examineMustUnderstandHeaderBlocks(String role) method returns an iterator with more than one objects",
- iterator.hasNext());
- }
-
- public void testSOAP12ExamineAllHeaderBlocksWithParser() {
- Iterator iterator = soap12HeaderWithParser.examineAllHeaderBlocks();
- iterator.next();
- SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock1.getLocalName().equals("echoOk"));
- iterator.next();
- SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock2.getLocalName().equals("echoOk1"));
- iterator.next();
- SOAPHeaderBlock headerBlock3 = (SOAPHeaderBlock) iterator.next();
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
- headerBlock3.getLocalName().equals("echoOk2"));
-
- assertFalse(
- "SOAP 1.2 Header Test With Parser : - examineAllHeaderBlocks method returns an iterator with more than three objects",
- iterator.hasNext());
- }
-
- public void testSOAP12getHeaderBlocksWithNSURIWithParser() {
- ArrayList arrayList = soap12HeaderWithParser.getHeaderBlocksWithNSURI(
- "http://example.org/ts-tests");
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
- arrayList.size() == 1);
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock of given namespace uri, local name mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getLocalName().equals(
- "echoOk"));
- assertTrue(
- "SOAP 1.2 Header Test With Parser : - headerBlock of given namespace uri, mismatch",
- ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
- .equals("http://example.org/ts-tests"));
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.soap;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class SOAPHeaderTest extends SOAPHeaderTestCase {
+ protected boolean isThereException;
+
+ public SOAPHeaderTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ //SOAP 1.1 Header Test (Programaticaly Created)--------------------------------------------------------------------------------
+ public void testSOAP11AddHeadearBlock() {
+ soap11Header.addHeaderBlock("echoOk1", namespace);
+ soap11Header.addHeaderBlock("echoOk2", namespace);
+ Iterator iterator = soap11Header.getChildren();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns empty iterator",
+ headerBlock1 == null);
+ assertTrue("SOAP 1.1 Header Test : - HeaderBlock1 local name mismatch",
+ headerBlock1.getLocalName().equals("echoOk1"));
+ assertTrue(
+ "SOAP 1.1 Header Test : - HeaderBlock1 namespace uri mismatch",
+ headerBlock1.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with only one object",
+ headerBlock2 == null);
+ assertTrue("SOAP 1.1 Header Test : - HeaderBlock2 local name mismatch",
+ headerBlock2.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.1 Header Test : - HeaderBlock2 namespace uri mismatch",
+ headerBlock2.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ assertTrue(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with more than two object",
+ iterator.next() == null);
+ }
+
+ public void testSOAP11ExamineHeaderBlocks() {
+ soap11Header.addHeaderBlock("echoOk1", namespace).setRole(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
+ ;
+ soap11Header.addHeaderBlock("echoOk2", namespace).setRole(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/next");
+ Iterator iterator = soap11Header.examineHeaderBlocks(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/next");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlockWithRole1 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test : - headerBlockWithRole local name mismatch",
+ headerBlockWithRole1.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.1 Header Test : - headerBlockWithRole role value mismatch",
+ headerBlockWithRole1.getRole().equals(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/next"));
+
+
+ assertFalse(
+ "SOAP 1.1 Header Test : - header has three headerBlocks with the given role, but examineHeaderBlocks(String role) method returns an iterator with more than three objects",
+ iterator.hasNext());
+ }
+
+// public void testSOAP11ExtractHeaderBlocks() {
+
+// }
+
+
+
+ public void testSOAP11ExamineAllHeaderBlocks() {
+ soap11Header.addHeaderBlock("echoOk1", namespace);
+ soap11Header.addHeaderBlock("echoOk2", namespace);
+ Iterator iterator = soap11Header.examineAllHeaderBlocks();
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator",
+ headerBlock1 == null);
+ assertTrue("SOAP 1.1 Header Test : - HeaderBlock1 local name mismatch",
+ headerBlock1.getLocalName().equals("echoOk1"));
+ assertTrue(
+ "SOAP 1.1 Header Test : - HeaderBlock1 namespace uri mismatch",
+ headerBlock1.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object",
+ headerBlock2 == null);
+ assertTrue("SOAP 1.1 Header Test : - HeaderBlock2 local name mismatch",
+ headerBlock2.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.1 Header Test : - HeaderBlock2 namespace uri mismatch",
+ headerBlock2.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ assertFalse(
+ "SOAP 1.1 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object",
+ iterator.hasNext());
+
+ }
+
+// public void testSOAP11ExtractAllHeaderBlocks() {
+//
+// }
+
+
+ public void testSOAP11getHeaderBlocksWithNSURI() {
+ soap11Header.addHeaderBlock("echoOk1", namespace);
+ soap11Header.addHeaderBlock("echoOk2",
+ omFactory.createOMNamespace("http://www.test1.org", "test1"));
+ ArrayList arrayList = soap11Header.getHeaderBlocksWithNSURI(
+ "http://www.test1.org");
+ assertTrue(
+ "SOAP 1.1 Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
+ arrayList.size() == 1);
+ assertTrue(
+ "SOAP 1.1 Header Test : - headerBlock of given namespace uri mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
+ .equals("http://www.test1.org"));
+ }
+
+ //SOAP 1.2 Header Test (Programaticaly Created)----------------------------------------------------------------------------------
+ public void testSOAP12AddHeadearBlock() {
+ soap12Header.addHeaderBlock("echoOk1", namespace);
+ soap12Header.addHeaderBlock("echoOk2", namespace);
+ Iterator iterator = soap12Header.getChildren();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method, getChildren method returns empty iterator",
+ headerBlock1 == null);
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock1 local name mismatch",
+ headerBlock1.getLocalName().equals("echoOk1"));
+ assertTrue(
+ "SOAP 1.2 Header Test : - HeaderBlock1 namespace uri mismatch",
+ headerBlock1.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method, getChildren method returns an iterator with only one object",
+ headerBlock2 == null);
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock2 local name mismatch",
+ headerBlock2.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.2 Header Test : - HeaderBlock2 namespace uri mismatch",
+ headerBlock2.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ assertTrue(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, getChildren method returns an iterator with more than two elements",
+ iterator.next() == null);
+ }
+
+ public void testSOAP12ExamineHeaderBlocks() {
+ soap12Header.addHeaderBlock("echoOk1", namespace);
+ soap12Header.addHeaderBlock("echoOk2", namespace).setRole(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
+ Iterator iterator = soap12Header.examineHeaderBlocks(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlockWithRole = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test : - headerBlockWithRole local name mismatch",
+ headerBlockWithRole.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.2 Header Test : - headerBlockWithRole role value mismatch",
+ headerBlockWithRole.getRole().equals(
+ "http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver"));
+
+ assertFalse(
+ "SOAP 1.2 Header Test : - header has one headerBlock with role, but examineHeaderBlocks(String role) method returns an iterator with more than one object",
+ iterator.hasNext());
+
+ }
+
+
+ public void testSOAP12ExamineMustUnderstandHeaderBlocks() {
+ soap12Header.addHeaderBlock("echoOk1", namespace).setRole(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+
+ SOAPHeaderBlock headerBlock1 = soap12Header.addHeaderBlock("echoOk2",
+ namespace);
+ headerBlock1.setRole(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+ headerBlock1.setMustUnderstand(true);
+
+ soap12Header.addHeaderBlock("echoOk3", namespace).setMustUnderstand(
+ true);
+
+ Iterator iterator = soap12Header.examineMustUnderstandHeaderBlocks(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.2 Header Test : - examineMustUnderstandHeaderBlocks method returns empty iterator",
+ headerBlock == null);
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock local name mismatch",
+ headerBlock.getLocalName().equals("echoOk2"));
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock role value mismatch",
+ headerBlock.getRole().equals(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
+ assertFalse(
+ "SOAP 1.2 Header Test : - examineMustUnderstandHeaderBlocks method returns an iterator with more than one object",
+ iterator.hasNext());
+ }
+
+ public void testSOAP12ExamineAllHeaderBlocks() {
+ soap12Header.addHeaderBlock("echoOk1", namespace);
+ soap12Header.addHeaderBlock("echoOk2", namespace);
+ Iterator iterator = soap12Header.examineAllHeaderBlocks();
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator",
+ headerBlock1 == null);
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock1 local name mismatch",
+ headerBlock1.getLocalName().equals("echoOk1"));
+ assertTrue(
+ "SOAP 1.2 Header Test : - HeaderBlock1 namespace uri mismatch",
+ headerBlock1.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertFalse(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with only one object",
+ headerBlock2 == null);
+ assertTrue("SOAP 1.2 Header Test : - HeaderBlock2 local name mismatch",
+ headerBlock2.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.2 Header Test : - HeaderBlock2 namespace uri mismatch",
+ headerBlock2.getNamespace().getName().equals(
+ "http://www.example.org"));
+
+ assertFalse(
+ "SOAP 1.2 Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns an iterator with more than two object",
+ iterator.hasNext());
+ }
+// public void testSOAP12ExtractAllHeaderBlocks() {
+//
+// }
+
+ public void testSOAP12getHeaderBlocksWithNSURI() {
+ soap12Header.addHeaderBlock("echoOk1", namespace);
+ soap12Header.addHeaderBlock("echoOk2",
+ omFactory.createOMNamespace("http://www.test1.org", "test1"));
+ ArrayList arrayList = soap12Header.getHeaderBlocksWithNSURI(
+ "http://www.test1.org");
+ assertTrue(
+ "SOAP 1.2 Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
+ arrayList.size() == 1);
+ assertTrue(
+ "SOAP 1.2 Header Test : - headerBlock of given namespace uri, mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
+ .equals("http://www.test1.org"));
+ }
+
+ //SOAP 1.1 Header Test (With Parser)---------------------------------------------------------------------------------------------
+ public void testSOAP11ExamineHeaderBlocksWithParser() {
+ Iterator iterator = soap11HeaderWithParser.examineHeaderBlocks(
+ "http://schemas.xmlsoap.org/soap/actor/next");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertEquals(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mismatch",
+ headerBlock1.getLocalName(),
+ "From");
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 role value mismatch",
+ headerBlock1.getRole().equals(
+ "http://schemas.xmlsoap.org/soap/actor/next"));
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock2 localname mmismatch",
+ headerBlock2.getLocalName().equals("MessageID"));
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock2 role value mmismatch",
+ headerBlock2.getRole().equals(
+ "http://schemas.xmlsoap.org/soap/actor/next"));
+
+ assertFalse(
+ "SOAP 1.1 Header Test With Parser : - examineHeaderBlocks(String role) method returns an iterator with more than two objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP11ExamineMustUnderstandHeaderBlocksWithParser() {
+ Iterator iterator = soap11HeaderWithParser.examineMustUnderstandHeaderBlocks(
+ "http://schemas.xmlsoap.org/soap/actor/next");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock1.getLocalName().equals("MessageID"));
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 role value mmismatch",
+ headerBlock1.getRole().equals(
+ "http://schemas.xmlsoap.org/soap/actor/next"));
+
+ assertFalse(
+ "SOAP 1.1 Header Test With Parser : - examineMustUnderstandHeaderBlocks(String role) method returns an iterator with more than one objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP11ExamineAllHeaderBlocksWithParser() {
+ Iterator iterator = soap11HeaderWithParser.examineAllHeaderBlocks();
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock1.getLocalName().equals("From"));
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock2.getLocalName().equals("MessageID"));
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock3 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock3.getLocalName().equals("To"));
+
+ assertFalse(
+ "SOAP 1.1 Header Test With Parser : - examineAllHeaderBlocks method returns an iterator with more than three objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP11getHeaderBlocksWithNSURIWithParser() {
+ ArrayList arrayList = soap11HeaderWithParser.getHeaderBlocksWithNSURI(
+ "http://example.org/ts-tests");
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
+ arrayList.size() == 1);
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock of given namespace uri, local name mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getLocalName().equals(
+ "MessageID"));
+ assertTrue(
+ "SOAP 1.1 Header Test With Parser : - headerBlock of given namespace uri, mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
+ .equals("http://example.org/ts-tests"));
+ }
+
+ //SOAP 1.2 Header Test (With Parser)-------------------------------------------------------------------------------------------
+ public void testSOAP12ExamineHeaderBlocksWithParser() {
+ Iterator iterator = soap12HeaderWithParser.examineHeaderBlocks(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock1.getLocalName().equals("echoOk"));
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock1 role value mmismatch",
+ headerBlock1.getRole().equals(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock2 localname mmismatch",
+ headerBlock2.getLocalName().equals("echoOk2"));
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock2 role value mmismatch",
+ headerBlock2.getRole().equals(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));
+
+ assertFalse(
+ "SOAP 1.2 Header Test With Parser : - examineHeaderBlocks(String role) method returns an iterator with more than two objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP12ExamineMustUnderstandHeaderBlocksWithParser() {
+ Iterator iterator = soap12HeaderWithParser.examineMustUnderstandHeaderBlocks(
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertEquals(
+ "SOAP 1.2 Header Test With Parser : - headerBlock localname mmismatch",
+ headerBlock1.getLocalName(),
+ "echoOk");
+ assertEquals(
+ "SOAP 1.2 Header Test With Parser : - headerBlock role value mmismatch",
+ headerBlock1.getRole(),
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+
+ iterator.hasNext();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertEquals(
+ "SOAP 1.2 Header Test With Parser : - headerBlock localname mmismatch",
+ headerBlock2.getLocalName(),
+ "echoOk2");
+ assertEquals(
+ "SOAP 1.2 Header Test With Parser : - headerBlock role value mmismatch",
+ headerBlock1.getRole(),
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver");
+
+ assertFalse(
+ "SOAP 1.2 Header Test With Parser : - examineMustUnderstandHeaderBlocks(String role) method returns an iterator with more than one objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP12ExamineAllHeaderBlocksWithParser() {
+ Iterator iterator = soap12HeaderWithParser.examineAllHeaderBlocks();
+ iterator.next();
+ SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock1.getLocalName().equals("echoOk"));
+ iterator.next();
+ SOAPHeaderBlock headerBlock2 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock2.getLocalName().equals("echoOk1"));
+ iterator.next();
+ SOAPHeaderBlock headerBlock3 = (SOAPHeaderBlock) iterator.next();
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock1 localname mmismatch",
+ headerBlock3.getLocalName().equals("echoOk2"));
+
+ assertFalse(
+ "SOAP 1.2 Header Test With Parser : - examineAllHeaderBlocks method returns an iterator with more than three objects",
+ iterator.hasNext());
+ }
+
+ public void testSOAP12getHeaderBlocksWithNSURIWithParser() {
+ ArrayList arrayList = soap12HeaderWithParser.getHeaderBlocksWithNSURI(
+ "http://example.org/ts-tests");
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
+ arrayList.size() == 1);
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock of given namespace uri, local name mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getLocalName().equals(
+ "echoOk"));
+ assertTrue(
+ "SOAP 1.2 Header Test With Parser : - headerBlock of given namespace uri, mismatch",
+ ((SOAPHeaderBlock) arrayList.get(0)).getNamespace().getName()
+ .equals("http://example.org/ts-tests"));
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTestCase.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTestCase.java Thu Sep 15 11:52:11 2005
@@ -1,41 +1,41 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.soap;
-
-import org.apache.axis2.om.OMNamespace;
-
-public class SOAPHeaderTestCase extends SOAPTestCase {
- protected SOAPHeader soap11Header;
- protected SOAPHeader soap12Header;
- protected SOAPHeader soap11HeaderWithParser;
- protected SOAPHeader soap12HeaderWithParser;
- protected OMNamespace namespace;
-
- public SOAPHeaderTestCase(String testName) {
- super(testName);
- namespace =
- omFactory.createOMNamespace("http://www.example.org", "test");
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- soap11Header = soap11Factory.createSOAPHeader(soap11Envelope);
- soap12Header = soap12Factory.createSOAPHeader(soap12Envelope);
- soap11HeaderWithParser = soap11EnvelopeWithParser.getHeader();
- soap12HeaderWithParser = soap12EnvelopeWithParser.getHeader();
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.soap;
+
+import org.apache.axis2.om.OMNamespace;
+
+public class SOAPHeaderTestCase extends SOAPTestCase {
+ protected SOAPHeader soap11Header;
+ protected SOAPHeader soap12Header;
+ protected SOAPHeader soap11HeaderWithParser;
+ protected SOAPHeader soap12HeaderWithParser;
+ protected OMNamespace namespace;
+
+ public SOAPHeaderTestCase(String testName) {
+ super(testName);
+ namespace =
+ omFactory.createOMNamespace("http://www.example.org", "test");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ soap11Header = soap11Factory.createSOAPHeader(soap11Envelope);
+ soap12Header = soap12Factory.createSOAPHeader(soap12Envelope);
+ soap11HeaderWithParser = soap11EnvelopeWithParser.getHeader();
+ soap12HeaderWithParser = soap12EnvelopeWithParser.getHeader();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPHeaderTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPMessageTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPMessageTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPMessageTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPMessageTest.java Thu Sep 15 11:52:11 2005
@@ -1,40 +1,40 @@
-package org.apache.axis2.soap;
-
-import org.apache.axis2.om.OMTestCase;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-public class SOAPMessageTest extends OMTestCase {
-
- public SOAPMessageTest(String testName) {
- super(testName);
- }
-
- public void testSOAPMessageCreation(){
- try {
- StAXSOAPModelBuilder soapBuilder = getOMBuilder("");
- SOAPMessage soapMessage = soapBuilder.getSoapMessage();
- assertNotNull(soapMessage);
- assertNotNull(soapMessage.getSOAPEnvelope());
- } catch (Exception e) {
- fail("Exception thrown "+ e);
- }
- }
-}
+package org.apache.axis2.soap;
+
+import org.apache.axis2.om.OMTestCase;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class SOAPMessageTest extends OMTestCase {
+
+ public SOAPMessageTest(String testName) {
+ super(testName);
+ }
+
+ public void testSOAPMessageCreation(){
+ try {
+ StAXSOAPModelBuilder soapBuilder = getOMBuilder("");
+ SOAPMessage soapMessage = soapBuilder.getSoapMessage();
+ assertNotNull(soapMessage);
+ assertNotNull(soapMessage.getSOAPEnvelope());
+ } catch (Exception e) {
+ fail("Exception thrown "+ e);
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPMessageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPTestCase.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPTestCase.java Thu Sep 15 11:52:11 2005
@@ -1,84 +1,84 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.soap;
-
-import org.apache.axis2.om.AbstractTestCase;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMFactory;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-
-public class SOAPTestCase extends AbstractTestCase {
- protected SOAPFactory soap11Factory;
- protected SOAPFactory soap12Factory;
- protected OMFactory omFactory;
-
- protected SOAPEnvelope soap11Envelope;
- protected SOAPEnvelope soap12Envelope;
-
- protected SOAPEnvelope soap11EnvelopeWithParser;
- protected SOAPEnvelope soap12EnvelopeWithParser;
-
- protected static final String SOAP11_FILE_NAME = "soap/soap11/soap11message.xml";
- protected static final String SOAP12_FILE_NAME = "soap/soap12message.xml";
- private Log log = LogFactory.getLog(getClass());
- /**
- * @param testName
- */
- public SOAPTestCase(String testName) {
- super(testName);
- soap11Factory = OMAbstractFactory.getSOAP11Factory();
- soap12Factory = OMAbstractFactory.getSOAP12Factory();
- omFactory = OMAbstractFactory.getOMFactory();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- soap11Envelope = soap11Factory.createSOAPEnvelope();
- soap12Envelope = soap12Factory.createSOAPEnvelope();
-
- soap11EnvelopeWithParser =
- (SOAPEnvelope) this.getSOAPBuilder(SOAP11_FILE_NAME)
- .getDocumentElement();
- soap12EnvelopeWithParser =
- (SOAPEnvelope) this.getSOAPBuilder(SOAP12_FILE_NAME)
- .getDocumentElement();
- }
-
- protected StAXSOAPModelBuilder getSOAPBuilder(String fileName) {
- XMLStreamReader parser = null;
- try {
- parser =
- XMLInputFactory.newInstance().createXMLStreamReader(
- new FileReader(getTestResourceFile(fileName)));
- } catch (XMLStreamException e) {
- log.info(e.getMessage());
- } catch (FileNotFoundException e) {
- log.info(e.getMessage());
- }
- return new StAXSOAPModelBuilder(parser, null);
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.soap;
+
+import org.apache.axis2.om.AbstractTestCase;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+
+public class SOAPTestCase extends AbstractTestCase {
+ protected SOAPFactory soap11Factory;
+ protected SOAPFactory soap12Factory;
+ protected OMFactory omFactory;
+
+ protected SOAPEnvelope soap11Envelope;
+ protected SOAPEnvelope soap12Envelope;
+
+ protected SOAPEnvelope soap11EnvelopeWithParser;
+ protected SOAPEnvelope soap12EnvelopeWithParser;
+
+ protected static final String SOAP11_FILE_NAME = "soap/soap11/soap11message.xml";
+ protected static final String SOAP12_FILE_NAME = "soap/soap12message.xml";
+ private Log log = LogFactory.getLog(getClass());
+ /**
+ * @param testName
+ */
+ public SOAPTestCase(String testName) {
+ super(testName);
+ soap11Factory = OMAbstractFactory.getSOAP11Factory();
+ soap12Factory = OMAbstractFactory.getSOAP12Factory();
+ omFactory = OMAbstractFactory.getOMFactory();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ soap11Envelope = soap11Factory.createSOAPEnvelope();
+ soap12Envelope = soap12Factory.createSOAPEnvelope();
+
+ soap11EnvelopeWithParser =
+ (SOAPEnvelope) this.getSOAPBuilder(SOAP11_FILE_NAME)
+ .getDocumentElement();
+ soap12EnvelopeWithParser =
+ (SOAPEnvelope) this.getSOAPBuilder(SOAP12_FILE_NAME)
+ .getDocumentElement();
+ }
+
+ protected StAXSOAPModelBuilder getSOAPBuilder(String fileName) {
+ XMLStreamReader parser = null;
+ try {
+ parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new FileReader(getTestResourceFile(fileName)));
+ } catch (XMLStreamException e) {
+ log.info(e.getMessage());
+ } catch (FileNotFoundException e) {
+ log.info(e.getMessage());
+ }
+ return new StAXSOAPModelBuilder(parser, null);
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/SOAPTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java Thu Sep 15 11:52:11 2005
@@ -1,52 +1,52 @@
-package org.apache.axis2.soap;
-
-import junit.framework.TestCase;
-import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
-import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
-
-public class WrongEnvelopeNamespaceTester extends TestCase {
- public void testCode() {
- try {
- String filename = "test-resources/soap/wrongEnvelopeNamespace.xml";
- XMLStreamReader xmlr = XMLInputFactory.newInstance()
- .createXMLStreamReader(new FileInputStream(filename));
- StAXBuilder builder = new StAXSOAPModelBuilder(xmlr, null); //exception here
- fail("Builder must fail here due to wrong SOAP namespace");
- } catch (SOAPProcessingException e) {
- assertTrue(true);
- } catch (FileNotFoundException e) {
- fail("Only SOAPProcessingException can be thrown here");
- }catch (Exception e) {
- fail("Only SOAPProcessingException can be thrown here");
- }
- }
-
- public static void main(String[] args) {
- WrongEnvelopeNamespaceTester tester = new WrongEnvelopeNamespaceTester();
- tester.testCode();
- }
-}
+package org.apache.axis2.soap;
+
+import junit.framework.TestCase;
+import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
+import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class WrongEnvelopeNamespaceTester extends TestCase {
+ public void testCode() {
+ try {
+ String filename = "test-resources/soap/wrongEnvelopeNamespace.xml";
+ XMLStreamReader xmlr = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new FileInputStream(filename));
+ StAXBuilder builder = new StAXSOAPModelBuilder(xmlr, null); //exception here
+ fail("Builder must fail here due to wrong SOAP namespace");
+ } catch (SOAPProcessingException e) {
+ assertTrue(true);
+ } catch (FileNotFoundException e) {
+ fail("Only SOAPProcessingException can be thrown here");
+ }catch (Exception e) {
+ fail("Only SOAPProcessingException can be thrown here");
+ }
+ }
+
+ public static void main(String[] args) {
+ WrongEnvelopeNamespaceTester tester = new WrongEnvelopeNamespaceTester();
+ tester.testCode();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/CharacterEncodingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java Thu Sep 15 11:52:11 2005
@@ -1,122 +1,122 @@
-package org.apache.axis2.soap.impl.llom;
-
-import org.apache.axis2.om.*;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- * <p/>
- */
-public class OMElementTest extends OMTestCase implements OMConstants {
- private static final String WSA_URI = "http://schemas.xmlsoap.org/ws/2004/03/addressing";
- private static final String WSA_TO = "To";
- private Log log = LogFactory.getLog(getClass());
-
- OMFactory factory = OMAbstractFactory.getOMFactory();
- private OMElement firstElement;
- private OMElement secondElement;
-
-
- public OMElementTest(String testName) {
- super(testName);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- OMNamespace testingNamespace = factory.createOMNamespace(
- "http://testing.axis2.org", "axis2");
- firstElement = factory.createOMElement("FirstElement", testingNamespace);
- secondElement = factory.createOMElement("SecondElement", factory.createOMNamespace(
- "http://testing.axis2.org", "axis2"), firstElement);
- }
-
- public void testGetText() {
- try {
- StAXSOAPModelBuilder soapBuilder = getOMBuilder(
- "soap/OMElementTest.xml");
- SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapBuilder.getDocumentElement();
- OMElement wsaTo = soapEnvelope.getHeader().getFirstChildWithName(
- new QName(WSA_URI, WSA_TO));
-
- String expectedString = "http://localhost:8081/axis/services/BankPort";
- assertEquals("getText is not returning the correct value",
- wsaTo.getText().trim(),
- expectedString);
- } catch (Exception e) {
- log.info(e.getMessage());
- }
- }
-
- public void testConstructors(){
-
- try {
- OMElement elementWithNoLocalName = factory.createOMElement("", null);
- fail("This should fail as OMElement should not be allowed to create without a local name ");
- } catch (Exception e) {
- assertTrue(true);
- }
-
- assertEquals("Namespace having same information, declared in the same context, should share" +
- " the same namespace object",firstElement.getNamespace(), secondElement.getNamespace());
- assertEquals("OMElement children addition has not worked properly", secondElement, firstElement.getFirstElement());
-
- OMNamespace testNamespace2 = factory.createOMNamespace("ftp://anotherTest.axis2.org", "axis2");
- firstElement.declareNamespace(testNamespace2);
-
- OMNamespace inheritedSecondNamespace = secondElement.findNamespace(testNamespace2.getName(),
- testNamespace2.getPrefix());
- assertNotNull("Children should inherit namespaces declared in parent", inheritedSecondNamespace);
- assertEquals("inherited namespace uri should be equal", inheritedSecondNamespace.getName(), testNamespace2.getName());
- assertEquals("inherited namespace prefix should be equal", inheritedSecondNamespace.getPrefix(), testNamespace2.getPrefix());
-
-
- }
-
- public void testChildDetachment() {
- OMNamespace testNamespace2 = factory.createOMNamespace("ftp://anotherTest.axis2.org", "axis2");
-
- secondElement.detach();
- assertTrue("OMElement children detachment has not worked properly", !secondElement.equals(firstElement.getFirstElement()));
- assertNull("First Element should not contain elements after detaching. ", firstElement.getFirstElement());
- assertNull("First Element should not contain elements after detaching. ", firstElement.getFirstChild());
- assertNull(secondElement.findNamespace(testNamespace2.getName(), testNamespace2.getPrefix()));
-
- firstElement.addChild(secondElement);
- firstElement.setText("Some Sample Text");
-
- assertTrue("First added child must be the first child", secondElement.equals(firstElement.getFirstChild()));
- Iterator children = firstElement.getChildren();
- int childCount = 0;
- while (children.hasNext()) {
- Object o = children.next();
- childCount++;
- }
- assertEquals("Children count should be two", childCount, 2);
-
- secondElement.detach();
- assertTrue("First child should be the text child", firstElement.getFirstChild() instanceof OMText);
-
-
- }
-
-}
+package org.apache.axis2.soap.impl.llom;
+
+import org.apache.axis2.om.*;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMElementTest extends OMTestCase implements OMConstants {
+ private static final String WSA_URI = "http://schemas.xmlsoap.org/ws/2004/03/addressing";
+ private static final String WSA_TO = "To";
+ private Log log = LogFactory.getLog(getClass());
+
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ private OMElement firstElement;
+ private OMElement secondElement;
+
+
+ public OMElementTest(String testName) {
+ super(testName);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ OMNamespace testingNamespace = factory.createOMNamespace(
+ "http://testing.axis2.org", "axis2");
+ firstElement = factory.createOMElement("FirstElement", testingNamespace);
+ secondElement = factory.createOMElement("SecondElement", factory.createOMNamespace(
+ "http://testing.axis2.org", "axis2"), firstElement);
+ }
+
+ public void testGetText() {
+ try {
+ StAXSOAPModelBuilder soapBuilder = getOMBuilder(
+ "soap/OMElementTest.xml");
+ SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapBuilder.getDocumentElement();
+ OMElement wsaTo = soapEnvelope.getHeader().getFirstChildWithName(
+ new QName(WSA_URI, WSA_TO));
+
+ String expectedString = "http://localhost:8081/axis/services/BankPort";
+ assertEquals("getText is not returning the correct value",
+ wsaTo.getText().trim(),
+ expectedString);
+ } catch (Exception e) {
+ log.info(e.getMessage());
+ }
+ }
+
+ public void testConstructors(){
+
+ try {
+ OMElement elementWithNoLocalName = factory.createOMElement("", null);
+ fail("This should fail as OMElement should not be allowed to create without a local name ");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ assertEquals("Namespace having same information, declared in the same context, should share" +
+ " the same namespace object",firstElement.getNamespace(), secondElement.getNamespace());
+ assertEquals("OMElement children addition has not worked properly", secondElement, firstElement.getFirstElement());
+
+ OMNamespace testNamespace2 = factory.createOMNamespace("ftp://anotherTest.axis2.org", "axis2");
+ firstElement.declareNamespace(testNamespace2);
+
+ OMNamespace inheritedSecondNamespace = secondElement.findNamespace(testNamespace2.getName(),
+ testNamespace2.getPrefix());
+ assertNotNull("Children should inherit namespaces declared in parent", inheritedSecondNamespace);
+ assertEquals("inherited namespace uri should be equal", inheritedSecondNamespace.getName(), testNamespace2.getName());
+ assertEquals("inherited namespace prefix should be equal", inheritedSecondNamespace.getPrefix(), testNamespace2.getPrefix());
+
+
+ }
+
+ public void testChildDetachment() {
+ OMNamespace testNamespace2 = factory.createOMNamespace("ftp://anotherTest.axis2.org", "axis2");
+
+ secondElement.detach();
+ assertTrue("OMElement children detachment has not worked properly", !secondElement.equals(firstElement.getFirstElement()));
+ assertNull("First Element should not contain elements after detaching. ", firstElement.getFirstElement());
+ assertNull("First Element should not contain elements after detaching. ", firstElement.getFirstChild());
+ assertNull(secondElement.findNamespace(testNamespace2.getName(), testNamespace2.getPrefix()));
+
+ firstElement.addChild(secondElement);
+ firstElement.setText("Some Sample Text");
+
+ assertTrue("First added child must be the first child", secondElement.equals(firstElement.getFirstChild()));
+ Iterator children = firstElement.getChildren();
+ int childCount = 0;
+ while (children.hasNext()) {
+ Object o = children.next();
+ childCount++;
+ }
+ assertEquals("Children count should be two", childCount, 2);
+
+ secondElement.detach();
+ assertTrue("First child should be the text child", firstElement.getFirstChild() instanceof OMText);
+
+
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java Thu Sep 15 11:52:11 2005
@@ -1,80 +1,80 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.soap.impl.llom;
-
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMTestCase;
-import org.apache.axis2.om.OMTestUtils;
-import org.apache.axis2.soap.SOAPBody;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPHeader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class OMEnvelopeTest extends OMTestCase {
- private Log log = LogFactory.getLog(getClass());
- public OMEnvelopeTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testGetHeader1() {
- SOAPHeader header = soapEnvelope.getHeader();
- assertTrue("Header information retrieved not correct",
- (header != null &&
- header.getLocalName().equalsIgnoreCase("Header")));
- }
-
- public void testGetBody1() {
- SOAPBody body = soapEnvelope.getBody();
- assertTrue("Header information retrieved not correct",
- (body != null && body.getLocalName().equalsIgnoreCase("Body")));
- }
-
- private SOAPEnvelope getSecondEnvelope() throws Exception {
- return (SOAPEnvelope) OMTestUtils.getOMBuilder(
- getTestResourceFile("soap/sample1.xml"))
- .getDocumentElement();
- }
-
- public void testGetHeader2() throws Exception {
- SOAPHeader header = getSecondEnvelope().getHeader();
- assertTrue("Header information retrieved not correct",
- (header != null &&
- header.getLocalName().equalsIgnoreCase("Header")));
- }
-
- public void testGetBody2() throws Exception {
- SOAPBody body = getSecondEnvelope().getBody();
- assertTrue("Header information retrieved not correct",
- (body != null && body.getLocalName().equalsIgnoreCase("Body")));
- }
-
- public void testDefaultEnveleope() {
- SOAPEnvelope env = null;
- try {
- env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
- } catch (SOAPProcessingException e) {
- log.info(e.getMessage());
- fail(e.getMessage());
- }
- assertNotNull(env);
- assertNotNull("Body should not be null", env.getBody());
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.soap.impl.llom;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMTestCase;
+import org.apache.axis2.om.OMTestUtils;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPHeader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class OMEnvelopeTest extends OMTestCase {
+ private Log log = LogFactory.getLog(getClass());
+ public OMEnvelopeTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testGetHeader1() {
+ SOAPHeader header = soapEnvelope.getHeader();
+ assertTrue("Header information retrieved not correct",
+ (header != null &&
+ header.getLocalName().equalsIgnoreCase("Header")));
+ }
+
+ public void testGetBody1() {
+ SOAPBody body = soapEnvelope.getBody();
+ assertTrue("Header information retrieved not correct",
+ (body != null && body.getLocalName().equalsIgnoreCase("Body")));
+ }
+
+ private SOAPEnvelope getSecondEnvelope() throws Exception {
+ return (SOAPEnvelope) OMTestUtils.getOMBuilder(
+ getTestResourceFile("soap/sample1.xml"))
+ .getDocumentElement();
+ }
+
+ public void testGetHeader2() throws Exception {
+ SOAPHeader header = getSecondEnvelope().getHeader();
+ assertTrue("Header information retrieved not correct",
+ (header != null &&
+ header.getLocalName().equalsIgnoreCase("Header")));
+ }
+
+ public void testGetBody2() throws Exception {
+ SOAPBody body = getSecondEnvelope().getBody();
+ assertTrue("Header information retrieved not correct",
+ (body != null && body.getLocalName().equalsIgnoreCase("Body")));
+ }
+
+ public void testDefaultEnveleope() {
+ SOAPEnvelope env = null;
+ try {
+ env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ } catch (SOAPProcessingException e) {
+ log.info(e.getMessage());
+ fail(e.getMessage());
+ }
+ assertNotNull(env);
+ assertNotNull("Body should not be null", env.getBody());
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/soap/impl/llom/OMEnvelopeTest.java
------------------------------------------------------------------------------
svn:eol-style = native