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/05/31 11:19:28 UTC

svn commit: r1598838 - in /webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts: soap/ soap/headerblock/ soap12/headerblock/

Author: veithen
Date: Sat May 31 09:19:27 2014
New Revision: 1598838

URL: http://svn.apache.org/r1598838
Log:
Unify the test cases that check the default value returned by getMustUnderstand and getRelay.

Added:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java   (with props)
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/BooleanAttributeTestCase.java
      - copied, changed from r1598837, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetBooleanAttributeDefault.java   (contents, props changed)
      - copied, changed from r1598837, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/headerblock/TestGetRelayDefault.java
Removed:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/headerblock/TestGetRelayDefault.java
Modified:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java

Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java?rev=1598838&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java Sat May 31 09:19:27 2014
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPConstants;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+
+/**
+ * Describes a boolean attribute that can appear on a SOAP header block. This includes the
+ * <tt>mustUnderstand</tt> attribute in all SOAP versions as well as the <tt>relay</tt> attribute
+ * defined by SOAP 1.2.
+ */
+public interface BooleanAttribute {
+    BooleanAttribute MUST_UNDERSTAND = new BooleanAttribute() {
+        public String getName() {
+            return SOAPConstants.ATTR_MUSTUNDERSTAND;
+        }
+
+        public boolean isSupported(SOAPSpec spec) {
+            return true;
+        }
+
+        public boolean getValue(SOAPHeaderBlock headerBlock) {
+            return headerBlock.getMustUnderstand();
+        }
+    };
+    
+    BooleanAttribute RELAY = new BooleanAttribute() {
+        public String getName() {
+            return SOAP12Constants.SOAP_RELAY;
+        }
+
+        public boolean isSupported(SOAPSpec spec) {
+            return spec == SOAPSpec.SOAP12;
+        }
+
+        public boolean getValue(SOAPHeaderBlock headerBlock) {
+            return headerBlock.getRelay();
+        }
+    };
+    
+    /**
+     * Get the name of the attribute.
+     * 
+     * @return the name of the attribute (<tt>mustUnderstand</tt> or <tt>relay</tt>)
+     */
+    String getName();
+    
+    /**
+     * Determine if the attribute is supported by the given SOAP version.
+     * 
+     * @param spec
+     *            identifies the SOAP version
+     * @return <code>true</code> if the attribute is supported, <code>false</code> otherwise
+     */
+    boolean isSupported(SOAPSpec spec);
+    
+    /**
+     * Invoke the getter method for this attribute on the given {@link SOAPHeaderBlock}.
+     * 
+     * @param headerBlock
+     *            the header block
+     * @return the value returned by the getter method
+     */
+    boolean getValue(SOAPHeaderBlock headerBlock);
+}

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

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=1598838&r1=1598837&r2=1598838&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 Sat May 31 09:19:27 2014
@@ -68,6 +68,11 @@ public class SOAPTestSuiteBuilder extend
         SOAPFaultChild.DETAIL,
     };
     
+    private static final BooleanAttribute[] booleanAttributes = {
+        BooleanAttribute.MUST_UNDERSTAND,
+        BooleanAttribute.RELAY,
+    };
+    
     private final OMMetaFactory metaFactory;
     private final boolean supportsOMSourcedElement;
     private final boolean supportsBodyElementNameOptimization;
@@ -212,6 +217,12 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.header.TestExtractAllHeaderBlocks(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestGetHeaderBlocksWithNSURI(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestGetHeadersToProcessWithNamespace(metaFactory, spec));
+        for (int i=0; i<booleanAttributes.length; i++) {
+            BooleanAttribute attribute = booleanAttributes[i];
+            if (attribute.isSupported(spec)) {
+                addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttributeDefault(metaFactory, spec, attribute));
+            }
+        }
         if (supportsOMSourcedElement) {
             addTest(new org.apache.axiom.ts.soap.headerblock.TestByteArrayDS(metaFactory, spec));
         }
@@ -327,7 +338,6 @@ public class SOAPTestSuiteBuilder extend
         for (int i=0; i<soap12BooleanLiterals.length; i++) {
             addTest(new org.apache.axiom.ts.soap12.headerblock.TestGetRelay(metaFactory, soap12BooleanLiterals[i]));
         }
-        addTest(new org.apache.axiom.ts.soap12.headerblock.TestGetRelayDefault(metaFactory));
         addTest(new org.apache.axiom.ts.soap12.headerblock.TestGetRelayInvalid(metaFactory, "invalid"));
         addTest(new org.apache.axiom.ts.soap12.headerblock.TestGetRelayInvalid(metaFactory, "TRUE"));
         addTest(new org.apache.axiom.ts.soap12.headerblock.TestGetRelayWithParser(metaFactory));

Copied: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/BooleanAttributeTestCase.java (from r1598837, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/BooleanAttributeTestCase.java?p2=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/BooleanAttributeTestCase.java&p1=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java&r1=1598837&r2=1598838&rev=1598838&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/BooleanAttributeTestCase.java Sat May 31 09:19:27 2014
@@ -19,23 +19,16 @@
 package org.apache.axiom.ts.soap.headerblock;
 
 import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.ts.soap.BooleanAttribute;
 import org.apache.axiom.ts.soap.SOAPSpec;
 import org.apache.axiom.ts.soap.SOAPTestCase;
 
-public class TestGetMustUnderstand extends SOAPTestCase {
-    public TestGetMustUnderstand(OMMetaFactory metaFactory, SOAPSpec spec) {
-        super(metaFactory, spec);
-    }
+public abstract class BooleanAttributeTestCase extends SOAPTestCase {
+    protected final BooleanAttribute attribute;
 
-    protected void runTest() throws Throwable {
-        SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
-        assertFalse(
-                "SOAP HeaderBlock Test : - After creating SOAPHeaderBlock, default MustUnderstand value true",
-                soapHeaderBlock.getMustUnderstand());
-        soapHeaderBlock.setMustUnderstand(true);
-        assertTrue(
-                "SOAP HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false",
-                soapHeaderBlock.getMustUnderstand());
+    public BooleanAttributeTestCase(OMMetaFactory metaFactory, SOAPSpec spec, BooleanAttribute attribute) {
+        super(metaFactory, spec);
+        this.attribute = attribute;
+        addTestParameter("attribute", attribute.getName());
     }
 }

Copied: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetBooleanAttributeDefault.java (from r1598837, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/headerblock/TestGetRelayDefault.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetBooleanAttributeDefault.java?p2=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetBooleanAttributeDefault.java&p1=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/headerblock/TestGetRelayDefault.java&r1=1598837&r2=1598838&rev=1598838&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/headerblock/TestGetRelayDefault.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetBooleanAttributeDefault.java Sat May 31 09:19:27 2014
@@ -16,28 +16,29 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.ts.soap12.headerblock;
+package org.apache.axiom.ts.soap.headerblock;
 
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.ts.soap.BooleanAttribute;
 import org.apache.axiom.ts.soap.SOAPSpec;
-import org.apache.axiom.ts.soap.SOAPTestCase;
 
 /**
- * Tests that {@link SOAPHeaderBlock#getRelay()} returns <code>false</code> if the <tt>relay</tt>
- * attribute is absent.
+ * Tests that {@link SOAPHeaderBlock#getMustUnderstand()} (resp. {@link SOAPHeaderBlock#getRelay()})
+ * returns <code>false</code> if the <tt>mustUnderstand</tt> (resp. <tt>relay</tt>) attribute is
+ * absent.
  */
-public class TestGetRelayDefault extends SOAPTestCase {
-    public TestGetRelayDefault(OMMetaFactory metaFactory) {
-        super(metaFactory, SOAPSpec.SOAP12);
+public class TestGetBooleanAttributeDefault extends BooleanAttributeTestCase {
+    public TestGetBooleanAttributeDefault(OMMetaFactory metaFactory, SOAPSpec spec, BooleanAttribute attribute) {
+        super(metaFactory, spec, attribute);
     }
 
     protected void runTest() throws Throwable {
         SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
         SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("http://example.org", "test", "h"));
-        assertFalse(headerBlock.getRelay());
+        assertFalse(attribute.getValue(headerBlock));
     }
 }

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

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java?rev=1598838&r1=1598837&r2=1598838&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestGetMustUnderstand.java Sat May 31 09:19:27 2014
@@ -30,9 +30,6 @@ public class TestGetMustUnderstand exten
 
     protected void runTest() throws Throwable {
         SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
-        assertFalse(
-                "SOAP HeaderBlock Test : - After creating SOAPHeaderBlock, default MustUnderstand value true",
-                soapHeaderBlock.getMustUnderstand());
         soapHeaderBlock.setMustUnderstand(true);
         assertTrue(
                 "SOAP HeaderBlock Test : - After setting MustUnderstand true calling setMustUnderstand method , getMustUnderstand method returns false",