axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r264164 - in /webservices/axis/trunk/java/modules/xml: src/org/apache/axis2/soap/impl/llom/builder/ test-resources/soap/ test/org/apache/axis2/om/infoset/ test/org/apache/axis2/soap/
Date Mon, 29 Aug 2005 16:24:35 GMT
Author: chinthaka
Date: Mon Aug 29 09:24:05 2005
New Revision: 264164

URL: http://svn.apache.org/viewcvs?rev=264164&view=rev
Log:
- fixing a bug which causes a NPE when a wrong SOAP envelope is recd.
- test case for that

Added:
    webservices/axis/trunk/java/modules/xml/test-resources/soap/wrongEnvelopeNamespace.xml
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
Modified:
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
    webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/infoset/XMLConformanceUnit.java

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=264164&r1=264163&r2=264164&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
Mon Aug 29 09:24:05 2005
@@ -418,7 +418,10 @@
             if (node.getNamespace() != null &&
                     !node.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)
&&
                     !node.getNamespace().getName().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
{
-                throw new SOAPProcessingException("invalid SOAP namespace URI", getSenderFaultCode());
+                throw new SOAPProcessingException("invalid SOAP namespace URI. " +
+                        "Only " + SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI +
+                        " and "+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI +
+                        " are supported.", SOAP12Constants.FAULT_CODE_SENDER);
             }
         }
 

Added: webservices/axis/trunk/java/modules/xml/test-resources/soap/wrongEnvelopeNamespace.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test-resources/soap/wrongEnvelopeNamespace.xml?rev=264164&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test-resources/soap/wrongEnvelopeNamespace.xml
(added)
+++ webservices/axis/trunk/java/modules/xml/test-resources/soap/wrongEnvelopeNamespace.xml
Mon Aug 29 09:24:05 2005
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<soap:Envelope
+xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
+soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
+
+  <soap:Body xmlns:m="http://www.stock.org/stock">
+    <m:GetStockPrice>
+      <m:StockName>IBM</m:StockName>
+    </m:GetStockPrice>
+  </soap:Body>
+
+</soap:Envelope>
\ No newline at end of file

Modified: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/infoset/XMLConformanceUnit.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/infoset/XMLConformanceUnit.java?rev=264164&r1=264163&r2=264164&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/infoset/XMLConformanceUnit.java
(original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/infoset/XMLConformanceUnit.java
Mon Aug 29 09:24:05 2005
@@ -16,8 +16,8 @@
 package org.apache.axis2.om.infoset;
 
 import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
 import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
@@ -34,13 +34,7 @@
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
+import java.io.*;
 
 public class XMLConformanceUnit extends XMLTestCase implements EntityResolver {
 
@@ -59,6 +53,7 @@
 
         System.out.println("XML File:" + filePath);
         XMLInputFactory factory = XMLInputFactory.newInstance();
+//        factory.setProperty("report-cdata-event", Boolean.TRUE);
         StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
                 createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
                         factory.createXMLStreamReader(

Added: webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java?rev=264164&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
(added)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/soap/WrongEnvelopeNamespaceTester.java
Mon Aug 29 09:24:05 2005
@@ -0,0 +1,53 @@
+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) {
+            e.printStackTrace();
+            fail("Only SOAPProcessingException can be thrown here");
+        }
+    }
+
+    public static void main(String[] args) {
+        WrongEnvelopeNamespaceTester tester = new WrongEnvelopeNamespaceTester();
+        tester.testCode();
+    }
+}



Mime
View raw message