You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/07/12 20:42:28 UTC

svn commit: r1360854 - in /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap: ./ message/

Author: veithen
Date: Thu Jul 12 18:42:28 2012
New Revision: 1360854

URL: http://svn.apache.org/viewvc?rev=1360854&view=rev
Log:
Added more unit tests for StAXSOAPModelBuilder.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java?rev=1360854&r1=1360853&r2=1360854&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java Thu Jul 12 18:42:28 2012
@@ -28,6 +28,7 @@ import org.apache.axiom.soap.SOAPEnvelop
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.soap.SOAPModelBuilder;
 import org.apache.axiom.ts.AxiomTestCase;
 import org.xml.sax.InputSource;
 
@@ -52,10 +53,13 @@ public abstract class SOAPTestCase exten
         altSoapFactory = spec.getAltFactory(metaFactory);
     }
 
-    protected SOAPEnvelope getTestMessage(String name) {
+    protected SOAPModelBuilder getBuilderForTestMessage(String name) {
         InputStream in = AbstractTestCase.getTestResource("soap/" + spec.getName() + "/" + name);
-        SOAPEnvelope envelope = (SOAPEnvelope)metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP,
-                new InputSource(in)).getDocumentElement();
+        return metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP, new InputSource(in));
+    }
+    
+    protected SOAPEnvelope getTestMessage(String name) {
+        SOAPEnvelope envelope = getBuilderForTestMessage(name).getSOAPEnvelope();
         assertSame(spec.getEnvelopeNamespaceURI(), ((SOAPFactory)envelope.getOMFactory()).getSoapVersionURI());
         return envelope;
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1360854&r1=1360853&r2=1360854&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Thu Jul 12 18:42:28 2012
@@ -185,6 +185,8 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent1(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent2(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent3(metaFactory, spec));
+        addTest(new org.apache.axiom.ts.soap.message.TestGetCharsetEncodingWithParser(metaFactory, spec));
+        addTest(new org.apache.axiom.ts.soap.message.TestGetOMFactoryWithParser(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.xpath.TestXPathAppliedToSOAPEnvelope(metaFactory, spec, true));
         addTest(new org.apache.axiom.ts.soap.xpath.TestXPathAppliedToSOAPEnvelope(metaFactory, spec, false));
     }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java?rev=1360854&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java Thu Jul 12 18:42:28 2012
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.soap.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPMessage;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests {@link OMDocument#getCharsetEncoding()} on a {@link SOAPMessage} created by a builder.
+ */
+public class TestGetCharsetEncodingWithParser extends SOAPTestCase {
+    public TestGetCharsetEncodingWithParser(OMMetaFactory metaFactory, SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    protected void runTest() throws Throwable {
+        String encoding = "iso-8859-15";
+        SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
+        soapFactory.createOMElement("echo", soapFactory.createOMNamespace("urn:test", null)).setText("test");
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        OMOutputFormat format = new OMOutputFormat();
+        format.setCharSetEncoding(encoding);
+        orgEnvelope.serialize(baos, format);
+        SOAPMessage message = (SOAPMessage)OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
+                new ByteArrayInputStream(baos.toByteArray()), encoding).getDocument();
+        assertEquals(encoding, message.getCharsetEncoding());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetCharsetEncodingWithParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java?rev=1360854&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java Thu Jul 12 18:42:28 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.soap.message;
+
+import org.apache.axiom.om.OMInformationItem;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPMessage;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests that {@link OMInformationItem#getOMFactory()} returns the expected {@link SOAPFactory}
+ * when invoked on a {@link SOAPMessage} created by a builder. Note that this is non trivial
+ * because the factory is auto-detected based on the namespace URI of the SOAP envelope.
+ */
+public class TestGetOMFactoryWithParser extends SOAPTestCase {
+    public TestGetOMFactoryWithParser(OMMetaFactory metaFactory, SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPMessage message = (SOAPMessage)getBuilderForTestMessage(SOAP_MESSAGE).getDocument();
+        assertSame(soapFactory, message.getOMFactory());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestGetOMFactoryWithParser.java
------------------------------------------------------------------------------
    svn:eol-style = native