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 ch...@apache.org on 2005/06/26 11:59:41 UTC

svn commit: r201831 [3/3] - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/clientapi/ core/src/org/apache/axis/engine/ xml/src/org/apache/axis/om/impl/llom/ xml/src/org/apache/axis/soap/ xml/src/org/apache/axis/soap/impl/llom/ xml/sr...

Added: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPHeaderTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPHeaderTestCase.java?rev=201831&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPHeaderTestCase.java (added)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPHeaderTestCase.java Sun Jun 26 01:24:38 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.axis.soap;
+
+import org.apache.axis.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();
+    }
+}

Added: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPTestCase.java?rev=201831&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPTestCase.java (added)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/SOAPTestCase.java Sun Jun 26 01:24:38 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.axis.soap;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.AbstractTestCase;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+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";
+
+    /**
+     * @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) {
+            e.printStackTrace();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        return new StAXSOAPModelBuilder(parser);
+    }
+
+}

Modified: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilderTest.java?rev=201831&r1=201830&r2=201831&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilderTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilderTest.java Sun Jun 26 01:24:38 2005
@@ -27,7 +27,6 @@
 
     public void testStAXSOAPModelBuilder() {
         String soap12Message =
-                "<?xml version='1.0' ?>" +
                 "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">\n" +
                 "   <env:Header>\n" +
                 "       <test:echoOk xmlns:test=\"http://example.org/ts-tests\"\n" +
@@ -118,7 +117,7 @@
             XMLStreamReader sopa12Parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(soap12Message));
             OMXMLParserWrapper soap12Builder = new StAXSOAPModelBuilder(sopa12Parser);
             SOAPEnvelope soap12Envelope = (SOAPEnvelope) soap12Builder.getDocumentElement();
-            soap12Envelope.build();
+//            soap12Envelope.build();
 //            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
 //            soap12Envelope.serialize(writer);
 //		    writer.flush();
@@ -257,7 +256,7 @@
             XMLStreamReader sopa11Parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(soap11Message));
             OMXMLParserWrapper soap11Builder = new StAXSOAPModelBuilder(sopa11Parser);
             SOAPEnvelope soap11Envelope = (SOAPEnvelope) soap11Builder.getDocumentElement();
-            soap11Envelope.build();
+//            soap11Envelope.build();
 //            writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
 //            soap11Envelope.serialize(writer);
 //		    writer.flush();
@@ -291,22 +290,21 @@
             assertTrue("SOAP 1.1 :- Body namespace uri mismatch", body.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));
 
             fault = body.getFault();
-            assertTrue("SOAP 1.1 :- Fault local name mismatch", fault.getLocalName().equals(SOAPConstants.SOAPFAULT_LOCAL_NAME));
             assertTrue("SOAP 1.1 :- Fault namespace uri mismatch", fault.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));
 
             iteratorInFault = fault.getChildren();
 
             iteratorInFault.next();
             code = (SOAPFaultCode) iteratorInFault.next();
-            assertTrue("SOAP 1.1 :- Fault code local name mismatch", code.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME));
+            assertEquals("SOAP Fault code local name mismatch", code.getLocalName(), (SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME));
             assertTrue("SOAP 1.1 :- Fault code namespace uri mismatch", code.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));
-            assertTrue("SOAP 1.1 :- Fault code value mismatch",code.getText().equals("env:Sender"));
+            assertEquals("SOAP 1.1 :- Fault code value mismatch",code.getValue().getText().trim(), "env:Sender");
 
             iteratorInFault.next();
             reason = (SOAPFaultReason) iteratorInFault.next();
             assertTrue("SOAP 1.1 :- Fault string local name mismatch", reason.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME));
             assertTrue("SOAP 1.2 :- Fault string namespace uri mismatch", reason.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));
-            assertTrue("SOAP 1.1 :- Fault string value mismatch",reason.getText().equals("Sender Timeout"));
+            assertTrue("SOAP 1.1 :- Fault string value mismatch",reason.getSOAPText().getText().equals("Sender Timeout"));
 
             iteratorInFault.next();
             role = (SOAPFaultRole) iteratorInFault.next();
@@ -347,7 +345,7 @@
             assertTrue("SOAP 1.1 :- Time element namespace mismatch",element21.getNamespace().getName().equals("http:www.sample.org"));
             assertTrue("SOAP 1.1 :- Text value in Time element mismatch",element21.getText().equals("P3M"));
 
-            iteratorInFault.next();
+           iteratorInFault.next();
             OMElement testElement = (OMElement)iteratorInFault.next();
             assertTrue("SOAP 1.1 :- Test element mismatch",testElement.getLocalName().equals("Test"));
             assertTrue("SOAP 1.1 :- Test element namespace mismatch",testElement.getNamespace().getName().equals("http:www.Test.org"));
@@ -359,8 +357,11 @@
 
         } catch (XMLStreamException e) {
             e.printStackTrace();
+            fail("Test failed. Reason -> "+e.getMessage());
         } catch (Exception e) {
             e.printStackTrace();
+            fail("Test failed. Reason -> "+e.getMessage());
+
         }
     }
 }

Modified: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/soap11/SOAP11SerialiserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/soap11/SOAP11SerialiserTest.java?rev=201831&r1=201830&r2=201831&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/soap11/SOAP11SerialiserTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/soap/impl/llom/soap11/SOAP11SerialiserTest.java Sun Jun 26 01:24:38 2005
@@ -40,7 +40,7 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        soapEnvelope = (SOAPEnvelope) getOMBuilder("soap/soap11fault.xml").getDocumentElement();
+        soapEnvelope = (SOAPEnvelope) getOMBuilder("soap/soap11/soap11fault.xml").getDocumentElement();
         omOutput = new OMOutput(XMLOutputFactory.newInstance().
                 createXMLStreamWriter(System.out));
     }