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 2011/01/15 20:24:02 UTC

svn commit: r1059394 [2/2] - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/soap/ axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/ axiom-impl/sr...

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestGetAllDetailEntriesWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestGetAllDetailEntriesWithParser.java?rev=1059394&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestGetAllDetailEntriesWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestGetAllDetailEntriesWithParser.java Sat Jan 15 19:24:00 2011
@@ -0,0 +1,65 @@
+/*
+ * 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.faultdetail;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+//SOAP Fault Detail Test (With Parser)
+public class TestGetAllDetailEntriesWithParser extends SOAPTestCase {
+    public TestGetAllDetailEntriesWithParser(OMMetaFactory metaFactory, String envelopeNamespaceURI) {
+        super(metaFactory, envelopeNamespaceURI);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPFaultDetail soapFaultDetail = getTestMessage(MESSAGE).getBody().getFault().getDetail();
+        Iterator iterator = soapFaultDetail.getAllDetailEntries();
+        OMText textEntry = (OMText) iterator.next();
+        assertFalse(
+                "SOAP Fault Detail Test With Parser : - getAllDetailEntries method returns empty iterator",
+                textEntry == null);
+        assertTrue(
+                "SOAP Fault Detail Test With Parser : - text value mismatch",
+                textEntry.getText().trim().equals("Details of error"));
+        OMElement detailEntry1 = (OMElement) iterator.next();
+        assertFalse(
+                "SOAP Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator without detail entries",
+                detailEntry1 == null);
+        assertTrue(
+                "SOAP Fault Detail Test With Parser : - detailEntry1 localname mismatch",
+                detailEntry1.getLocalName().equals("MaxTime"));
+        iterator.next();
+        OMElement detailEntry2 = (OMElement) iterator.next();
+        assertFalse(
+                "SOAP Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with only one detail entries",
+                detailEntry2 == null);
+        assertTrue(
+                "SOAP Fault Detail Test With Parser : - detailEntry2 localname mismatch",
+                detailEntry2.getLocalName().equals("AveTime"));
+        iterator.next();
+        assertTrue(
+                "SOAP Fault Detail Test With Parser : - getAllDetailEntries method returns an itrator with more than two detail entries",
+                !iterator.hasNext());
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestSerialization.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestSerialization.java?rev=1059394&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestSerialization.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestSerialization.java Sat Jan 15 19:24:00 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.faultdetail;
+
+import java.io.StringWriter;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+// Regression test for WSCOMMONS-530
+public class TestSerialization extends SOAPTestCase {
+    public TestSerialization(OMMetaFactory metaFactory, String envelopeNamespaceURI) {
+        super(metaFactory, envelopeNamespaceURI);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
+        SOAPBody body = soapFactory.createSOAPBody(envelope);
+        SOAPFault fault = soapFactory.createSOAPFault(body);
+        SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(fault);
+        OMNamespace omNamespace = soapFactory.createOMNamespace("http://www.test.org", "test");
+        soapFaultDetail.addDetailEntry(
+                soapFactory.createOMElement("DetailEntry1", omNamespace));
+        soapFaultDetail.addDetailEntry(
+                soapFactory.createOMElement("DetailEntry2", omNamespace));
+        StringWriter out = new StringWriter();
+        soapFaultDetail.serialize(out);
+        String msg = out.toString();
+        System.out.println(msg);
+        assertTrue(msg.indexOf("DetailEntry1") != -1);
+        assertTrue(msg.indexOf("DetailEntry2") != -1);
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestWSCommons202.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestWSCommons202.java?rev=1059394&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestWSCommons202.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/faultdetail/TestWSCommons202.java Sat Jan 15 19:24:00 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.faultdetail;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+public class TestWSCommons202 extends SOAPTestCase {
+    public TestWSCommons202(OMMetaFactory metaFactory, String envelopeNamespaceURI) {
+        super(metaFactory, envelopeNamespaceURI);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
+        soapFaultDetail.setText("a");
+
+        assertTrue(soapFaultDetail.getText().trim().equals("a"));
+        assertTrue("Text serialization has problems. It had serialized same text twice", soapFaultDetail.toString().indexOf("aa") == -1);
+
+        OMElement omElement = soapFactory.createOMElement("DummyElement", null);
+        soapFaultDetail.addChild(omElement);
+        omElement.setText("Some text is here");
+
+        assertTrue("Children of SOAP Fault Detail element are not serialized properly", soapFaultDetail.toString().indexOf("Some text is here") != -1);
+    }
+}

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

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/envelope/TestAddElementAfterBody.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/envelope/TestAddElementAfterBody.java?rev=1059394&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/envelope/TestAddElementAfterBody.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/envelope/TestAddElementAfterBody.java Sat Jan 15 19:24:00 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.soap11.envelope;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Test that adding an arbitrary element to the envelope is allowed. SOAP 1.1 indeed allows for
+ * arbitrary elements to appear after the SOAP body.
+ */
+public class TestAddElementAfterBody extends AxiomTestCase {
+    public TestAddElementAfterBody(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPFactory soapFactory = metaFactory.getSOAP11Factory();
+        SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+        env.addChild(soapFactory.createOMElement("test", "urn:test", "p"));
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/envelope/TestAddElementAfterBody.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestAddElementAfterBody.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestAddElementAfterBody.java?rev=1059394&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestAddElementAfterBody.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestAddElementAfterBody.java Sat Jan 15 19:24:00 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.soap12.envelope;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Test that an attempt to add an arbitrary element to the SOAP envelope triggers an exception.
+ */
+public class TestAddElementAfterBody extends AxiomTestCase {
+    public TestAddElementAfterBody(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPFactory soapFactory = metaFactory.getSOAP12Factory();
+        SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+        try {
+            env.addChild(soapFactory.createOMElement("test", "urn:test", "p"));
+            fail("Expected SOAPProcessingException");
+        } catch (SOAPProcessingException ex) {
+            // Expected
+        }
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestAddElementAfterBody.java
------------------------------------------------------------------------------
    svn:eol-style = native