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 2014/06/23 18:23:49 UTC

svn commit: r1604855 - in /webservices/axiom/trunk/modules: axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/

Author: veithen
Date: Mon Jun 23 16:23:48 2014
New Revision: 1604855

URL: http://svn.apache.org/r1604855
Log:
AXIOM-311: Refactored a test case for the registerCustomBuilder method.

Added:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java   (with props)
Modified:
    webservices/axiom/trunk/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java

Modified: webservices/axiom/trunk/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java?rev=1604855&r1=1604854&r2=1604855&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java Mon Jun 23 16:23:48 2014
@@ -37,10 +37,7 @@ import org.apache.axiom.soap.impl.builde
 import org.apache.axiom.ts.soap.SOAPSpec;
 import org.apache.axiom.ts.soap.TestMessageSet;
 
-import javax.xml.namespace.QName;
-
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.Iterator;
 
 /**
@@ -52,24 +49,6 @@ public class CustomBuilderTest extends A
         copyAndCheck(createEnvelope(getTestResource(TestConstants.SAMPLE1)), true);
     }
     
-    
-    public void testHeaderCustomBuilder() throws Exception{
-        StAXSOAPModelBuilder builder = (StAXSOAPModelBuilder)OMXMLBuilderFactory.createSOAPModelBuilder(
-                TestMessageSet.WSA.getMessage(SOAPSpec.SOAP11).getInputStream(), null);
-        builder.registerCustomBuilder(new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing","To"), 3, new
-                                      ByteArrayCustomBuilder("utf-8"));
-        SOAPEnvelope sourceEnv = (SOAPEnvelope) builder.getDocumentElement();
-        SOAPHeader header = sourceEnv.getHeader();
-        ArrayList al =
-            header.getHeaderBlocksWithNSURI("http://schemas.xmlsoap.org/ws/2004/03/addressing");
-        for(int i=0;i<al.size();i++){
-            SOAPHeaderBlock shb = (SOAPHeaderBlock)al.get(i);
-            if("To".equals(shb.getLocalName())){
-                assertNotNull(shb.getDataSource());
-            }
-        }
-    }
-    
     /**
      * Test OMSE with SOAPMessage
      * @throws Exception

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1604855&r1=1604854&r2=1604855&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Mon Jun 23 16:23:48 2014
@@ -150,8 +150,11 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.builder.TestCommentInEpilog(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.builder.TestCommentInProlog(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.builder.TestDTD(metaFactory, spec));
-        if (supportsBodyElementNameOptimization) {
-            addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck(metaFactory, spec));
+        if (supportsOMSourcedElement) {
+            addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilder(metaFactory, spec));
+            if (supportsBodyElementNameOptimization) {
+                addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck(metaFactory, spec));
+            }
         }
         addTest(new org.apache.axiom.ts.soap.envelope.TestAddHeaderToIncompleteEnvelope(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestBodyHeaderOrder(metaFactory, spec));

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java?rev=1604855&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilder.java Mon Jun 23 16:23:48 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.builder;
+
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.ts.soap.TestMessageAdapter;
+import org.apache.axiom.ts.soap.TestMessageSet;
+
+public class TestRegisterCustomBuilder extends SOAPTestCase {
+    public TestRegisterCustomBuilder(OMMetaFactory metaFactory, SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        StAXSOAPModelBuilder builder = (StAXSOAPModelBuilder)TestMessageSet.WSA.getMessage(spec).getAdapter(TestMessageAdapter.class).getBuilder(metaFactory);
+        builder.registerCustomBuilder(new QName("http://www.w3.org/2005/08/addressing", "To"), 3,
+                new ByteArrayCustomBuilder("utf-8"));
+        SOAPHeader header = builder.getSOAPEnvelope().getHeader();
+        ArrayList al = header.getHeaderBlocksWithNSURI("http://www.w3.org/2005/08/addressing");
+        assertEquals(al.size(), 4);
+        for (int i=0; i<al.size(); i++){
+            SOAPHeaderBlock shb = (SOAPHeaderBlock)al.get(i);
+            if ("To".equals(shb.getLocalName())) {
+                assertNotNull(shb.getDataSource());
+            }
+        }
+    }
+}

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