ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1598845 - in /webservices/axiom/trunk/modules: axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/ axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/ axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/ axiom-...
Date Sat, 31 May 2014 09:23:36 GMT
Author: veithen
Date: Sat May 31 09:23:35 2014
New Revision: 1598845

URL: http://svn.apache.org/r1598845
Log:
SOAP 1.1: Eliminate the invalid TestSetMustUnderstandStringTrueFalse case and ensure that
the mustUnderstand attribute is processed strictly following to specs.

Removed:
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/headerblock/TestSetMustUnderstandStringTrueFalse.java
Modified:
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/SOAPHelper.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11HeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12HeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java
    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/TestSetMustUnderstandWithInvalidValue.java

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/SOAPHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/SOAPHelper.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/SOAPHelper.java
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/soap/impl/common/SOAPHelper.java
Sat May 31 09:23:35 2014
@@ -28,8 +28,13 @@ import org.apache.axiom.soap.SOAPVersion
 public interface SOAPHelper {
     SOAPHelper SOAP11 = new SOAPHelper() {
         public Boolean parseBoolean(String literal) {
-            // TODO
-            return null;
+            if (literal.equals("1")) {
+                return Boolean.TRUE;
+            } else if (literal.equals("0")) {
+                return Boolean.FALSE;
+            } else {
+                return null;
+            }
         }
     };
     

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -35,6 +35,7 @@ import org.apache.axiom.soap.SOAPCloneOp
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.soap.impl.common.SOAPHelper;
 
 import javax.xml.namespace.QName;
 
@@ -126,4 +127,34 @@ public abstract class SOAPHeaderBlockImp
             targetSHB.setProcessed();
         }
     }
+    
+    protected abstract SOAPHelper getSOAPHelper();
+
+    public final void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException
{
+        Boolean value = getSOAPHelper().parseBoolean(mustUnderstand);
+        if (value != null) {
+            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
+                         mustUnderstand,
+                         getVersion().getEnvelopeURI());
+        } else {
+            throw new SOAPProcessingException("Invalid value for mustUnderstand attribute");
+        }
+    }
+
+    public final boolean getMustUnderstand() throws SOAPProcessingException {
+        String mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, getVersion().getEnvelopeURI());
+        if (mustUnderstand != null) {
+            Boolean value = getSOAPHelper().parseBoolean(mustUnderstand);
+            if (value != null) {
+                return value.booleanValue();
+            } else {
+                throw new SOAPProcessingException(
+                        "Invalid value found in mustUnderstand value of " +
+                                this.getLocalName() +
+                                " header block");
+            }
+        } else {
+            return false;
+        }
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11HeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11HeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11HeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -31,6 +31,7 @@ import org.apache.axiom.soap.SOAPHeaderB
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.impl.common.SOAPHelper;
 import org.apache.axiom.soap.impl.dom.SOAPHeaderBlockImpl;
 
 public class SOAP11HeaderBlockImpl extends SOAPHeaderBlockImpl {
@@ -75,43 +76,6 @@ public class SOAP11HeaderBlockImpl exten
                      SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     }
 
-    public void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException {
-        if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                         mustUnderstand,
-                         SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        } else {
-            throw new SOAPProcessingException(
-                    "mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" ");
-        }
-    }
-
-    public boolean getMustUnderstand() throws SOAPProcessingException {
-        String mustUnderstand;
-        if ((mustUnderstand =
-                getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                             SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI))
-                != null) {
-            if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-                return true;
-            } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand)) {
-                return false;
-            } else {
-                throw new SOAPProcessingException(
-                        "Invalid value found in mustUnderstand value of " +
-                                this.getLocalName() +
-                                " header block");
-            }
-        }
-        return false;
-
-    }
-
     /**
      * What SOAP version is this HeaderBlock?
      *
@@ -121,6 +85,10 @@ public class SOAP11HeaderBlockImpl exten
         return SOAP11Version.getSingleton();
     }
 
+    protected SOAPHelper getSOAPHelper() {
+        return SOAPHelper.SOAP11;
+    }
+
     protected OMElement createClone(OMCloneOptions options, ParentNode targetParent, boolean
generateNSDecl) {
         SOAPHeaderBlock clone = new SOAP11HeaderBlockImpl(targetParent, getLocalName(), getNamespace(),
null, factory, generateNSDecl);
         copyData(options, clone);

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12HeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12HeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12HeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -67,43 +67,6 @@ public class SOAP12HeaderBlockImpl exten
 
     }
 
-    public void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException {
-        if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                         mustUnderstand,
-                         SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        } else {
-            throw new SOAPProcessingException(
-                    "mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" ");
-        }
-    }
-
-    public boolean getMustUnderstand() throws SOAPProcessingException {
-        String mustUnderstand;
-        if ((mustUnderstand =
-                getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                             SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
-                != null) {
-            if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-                return true;
-            } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand)) {
-                return false;
-            } else {
-                throw new SOAPProcessingException(
-                        "Invalid value found in mustUnderstand value of " +
-                                this.getLocalName() +
-                                " header block");
-            }
-        }
-        return false;
-
-    }
-
     public void setRelay(boolean relay) {
         setAttribute(SOAP12Constants.SOAP_RELAY,
                      String.valueOf(relay),
@@ -134,6 +97,10 @@ public class SOAP12HeaderBlockImpl exten
         return SOAP12Version.getSingleton();
     }
 
+    protected SOAPHelper getSOAPHelper() {
+        return SOAPHelper.SOAP12;
+    }
+
     protected OMElement createClone(OMCloneOptions options, ParentNode targetParent, boolean
generateNSDecl) {
         SOAPHeaderBlock clone = new SOAP12HeaderBlockImpl(targetParent, getLocalName(), getNamespace(),
null, factory, generateNSDecl);
         copyData(options, clone);

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -38,6 +38,7 @@ import org.apache.axiom.soap.SOAPFactory
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.soap.impl.common.SOAPHelper;
 
 import javax.xml.namespace.QName;
 
@@ -163,4 +164,43 @@ public abstract class SOAPHeaderBlockImp
             targetSHB.setProcessed();
         }
     }
+    
+    protected abstract SOAPHelper getSOAPHelper();
+
+    public final void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException
{
+        Boolean value = getSOAPHelper().parseBoolean(mustUnderstand);
+        if (value != null) {
+            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
+                         mustUnderstand,
+                         getVersion().getEnvelopeURI());
+        } else {
+            throw new SOAPProcessingException("Invalid value for mustUnderstand attribute");
+        }
+    }
+
+    public final boolean getMustUnderstand() throws SOAPProcessingException {
+        // First, try getting the information from the property
+        // Fallback to getting the information from the attribute
+        String mustUnderstand;
+        if (this.hasOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY)) {
+            mustUnderstand = this.getOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY);
+        } else {
+            mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, getVersion().getEnvelopeURI());
+        }
+        
+        // Now parse the value
+        if (mustUnderstand != null) {
+            Boolean value = getSOAPHelper().parseBoolean(mustUnderstand);
+            if (value != null) {
+                return value.booleanValue();
+            } else {
+                throw new SOAPProcessingException(
+                        "Invalid value found in mustUnderstand value of " +
+                                this.getLocalName() +
+                                " header block");
+            }
+        } else {
+            return false;
+        }
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -31,6 +31,7 @@ import org.apache.axiom.soap.SOAPFactory
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.impl.common.SOAPHelper;
 import org.apache.axiom.soap.impl.llom.SOAPHeaderBlockImpl;
 
 public class SOAP11HeaderBlockImpl extends SOAPHeaderBlockImpl {
@@ -82,51 +83,6 @@ public class SOAP11HeaderBlockImpl exten
                      SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     }
 
-    public void setMustUnderstand(String mustUnderstand) throws SOAPProcessingException {
-        if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                         mustUnderstand,
-                         SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        } else {
-            throw new SOAPProcessingException(
-                    "mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" ");
-        }
-    }
-
-    public boolean getMustUnderstand() throws SOAPProcessingException {
-        // First, try getting the information from the property
-        // Fallback to getting the information from the attribute
-        String mustUnderstand;
-        if (this.hasOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY)) {
-            mustUnderstand = this.getOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY);
-        } else {
-            mustUnderstand =
-                getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                             SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        }
-        
-        // Parse the value
-        if (mustUnderstand != null) {
-            if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-                return true;
-            } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand)) {
-                return false;
-            } else {
-                throw new SOAPProcessingException(
-                        "Invalid value found in mustUnderstand value of " +
-                                this.getLocalName() +
-                                " header block");
-            }
-        }
-        return false;
-
-    }
-
     public void setRelay(boolean relay) {
         throw new UnsupportedOperationException("Not supported for SOAP 1.1");
     }
@@ -138,4 +94,8 @@ public class SOAP11HeaderBlockImpl exten
     public SOAPVersion getVersion() {
         return SOAP11Version.getSingleton();
     }
+
+    protected SOAPHelper getSOAPHelper() {
+        return SOAPHelper.SOAP11;
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
Sat May 31 09:23:35 2014
@@ -80,51 +80,6 @@ public class SOAP12HeaderBlockImpl exten
 
     }
 
-    public void setMustUnderstand(String mustUnderstand)
-            throws SOAPProcessingException {
-        if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) ||
-                SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-            setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND,
-                         mustUnderstand,
-                         SOAP_ENVELOPE_NAMESPACE_URI);
-        } else {
-            throw new SOAPProcessingException(
-                    "mustUndertand should be one of \"true\", " +
-                            "\"false\", \"0\" or \"1\" ");
-        }
-    }
-
-    public boolean getMustUnderstand() throws SOAPProcessingException {
-        // First, try getting the information from the property
-        // Fallback to getting the information from the attribute
-        String mustUnderstand;
-        if (this.hasOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY)) {
-            mustUnderstand = this.getOMDataSourceProperty(MUST_UNDERSTAND_PROPERTY);
-        } else {
-            mustUnderstand = getAttribute(ATTR_MUSTUNDERSTAND, SOAP_ENVELOPE_NAMESPACE_URI);
-        }
-       
-        // Now parse the value
-        if (mustUnderstand != null) {
-            if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
-                return true;
-            } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) ||
-                    SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand)) {
-                return false;
-            } else {
-                throw new SOAPProcessingException(
-                        "Invalid value found in mustUnderstand value of " +
-                                this.getLocalName() +
-                                " header block");
-            }
-        }
-        return false;
-
-    }
-
     public void setRelay(boolean relay) {
         setAttribute(SOAP_RELAY, relay ? "true" : "false", SOAP_ENVELOPE_NAMESPACE_URI);
     }
@@ -158,4 +113,8 @@ public class SOAP12HeaderBlockImpl exten
     public SOAPVersion getVersion() {
         return SOAP12Version.getSingleton();
     }
+
+    protected SOAPHelper getSOAPHelper() {
+        return SOAPHelper.SOAP12;
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java
(original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java
Sat May 31 09:23:35 2014
@@ -18,6 +18,11 @@
  */
 package org.apache.axiom.ts.soap;
 
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMMetaFactory;
@@ -39,12 +44,12 @@ public abstract class SOAPSpec {
             return "soap11";
         }
         
-        public SOAPFactory getFactory(OMMetaFactory metaFactory) {
-            return metaFactory.getSOAP11Factory();
+        public SOAPSpec getAltSpec() {
+            return SOAPSpec.SOAP12;
         }
 
-        public SOAPFactory getAltFactory(OMMetaFactory metaFactory) {
-            return metaFactory.getSOAP12Factory();
+        public SOAPFactory getFactory(OMMetaFactory metaFactory) {
+            return metaFactory.getSOAP11Factory();
         }
 
         public String getEnvelopeNamespaceURI() {
@@ -62,12 +67,12 @@ public abstract class SOAPSpec {
             return "soap12";
         }
         
-        public SOAPFactory getFactory(OMMetaFactory metaFactory) {
-            return metaFactory.getSOAP12Factory();
+        public SOAPSpec getAltSpec() {
+            return SOAPSpec.SOAP11;
         }
 
-        public SOAPFactory getAltFactory(OMMetaFactory metaFactory) {
-            return metaFactory.getSOAP11Factory();
+        public SOAPFactory getFactory(OMMetaFactory metaFactory) {
+            return metaFactory.getSOAP12Factory();
         }
 
         public String getEnvelopeNamespaceURI() {
@@ -88,8 +93,21 @@ public abstract class SOAPSpec {
     }
     
     public abstract String getName();
+    
+    /**
+     * Get the {@link SOAPSpec} instance for the other SOAP version. This is useful when
+     * constructing test cases that test SOAP version mismatches.
+     * 
+     * @return the {@link SOAPSpec} instance for the other SOAP version
+     */
+    public abstract SOAPSpec getAltSpec();
+    
     public abstract SOAPFactory getFactory(OMMetaFactory metaFactory);
-    public abstract SOAPFactory getAltFactory(OMMetaFactory metaFactory);
+    
+    public final SOAPFactory getAltFactory(OMMetaFactory metaFactory) {
+        return getAltSpec().getFactory(metaFactory);
+    }
+    
     public abstract String getEnvelopeNamespaceURI();
     
     public final QName getFaultCodeQName() {
@@ -119,6 +137,39 @@ public abstract class SOAPSpec {
         return (BooleanLiteral[])booleanLiterals.clone();
     }
 
+    private static List getReps(BooleanLiteral[] literals) {
+        List result = new ArrayList(literals.length);
+        for (int i=0; i<literals.length; i++) {
+            result.add(literals[i].getLexicalRepresentation());
+        }
+        return result;
+    }
+    
+    /**
+     * Produce a representative list of strings that are not valid lexical representations
of
+     * booleans as defined by this SOAP version. The list in particular contains:
+     * <ul>
+     * <li>Boolean literals allowed by the other SOAP version, but that are not valid
in this SOAP
+     * version.
+     * <li>A variant of a valid boolean literal that uses a different case and that
is not valid,
+     * unless no such variant exists.
+     * <li>The string <code>"invalid"</code>.
+     * </ul>
+     * 
+     * @return an array of invalid boolean literals
+     */
+    public final String[] getInvalidBooleanLiterals() {
+        Set result = new LinkedHashSet();
+        result.addAll(getReps(getAltSpec().booleanLiterals));
+        List valid = getReps(booleanLiterals);
+        result.removeAll(valid);
+        result.add("invalid");
+        if (valid.contains("true")) {
+            result.add("TRUE");
+        }
+        return (String[])result.toArray(new String[result.size()]);
+    }
+    
     /**
      * Get the canonical representation for the given boolean value as specified by this
SOAP
      * version.

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=1598845&r1=1598844&r2=1598845&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:23:35 2014
@@ -96,6 +96,7 @@ public class SOAPTestSuiteBuilder extend
     private void addTests(SOAPSpec spec) {
         SerializationStrategy[] serializationStrategies = Strategies.getSerializationStrategies();
         BooleanLiteral[] booleanLiterals = spec.getBooleanLiterals();
+        String[] invalidBooleanLiterals = spec.getInvalidBooleanLiterals();
         addTest(new org.apache.axiom.ts.soap.body.TestAddFault1(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.body.TestAddFault2(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.body.TestCloneOMElement(metaFactory, spec));
@@ -224,8 +225,9 @@ public class SOAPTestSuiteBuilder extend
                     addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttribute(metaFactory,
spec, attribute, booleanLiterals[j]));
                 }
                 addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttributeDefault(metaFactory,
spec, attribute));
-                addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttributeInvalid(metaFactory,
spec, attribute, "invalid"));
-                addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttributeInvalid(metaFactory,
spec, attribute, "TRUE"));
+                for (int j=0; j<invalidBooleanLiterals.length; j++) {
+                    addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttributeInvalid(metaFactory,
spec, attribute, invalidBooleanLiterals[j]));
+                }
                 addTest(new org.apache.axiom.ts.soap.headerblock.TestSetBooleanAttribute(metaFactory,
spec, attribute, true));
                 addTest(new org.apache.axiom.ts.soap.headerblock.TestSetBooleanAttribute(metaFactory,
spec, attribute, false));
             } else {
@@ -241,7 +243,9 @@ public class SOAPTestSuiteBuilder extend
         for (int i=0; i<booleanLiterals.length; i++) {
             addTest(new org.apache.axiom.ts.soap.headerblock.TestSetMustUnderstandString(metaFactory,
spec, booleanLiterals[i]));
         }
-        addTest(new org.apache.axiom.ts.soap.headerblock.TestSetMustUnderstandWithInvalidValue(metaFactory,
spec));
+        for (int i=0; i<invalidBooleanLiterals.length; i++) {
+            addTest(new org.apache.axiom.ts.soap.headerblock.TestSetMustUnderstandWithInvalidValue(metaFactory,
spec, invalidBooleanLiterals[i]));
+        }
         addTest(new org.apache.axiom.ts.soap.headerblock.TestSetRole(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent1(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent2(metaFactory, spec));
@@ -301,7 +305,6 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap11.header.TestGetHeadersToProcessWithParser(metaFactory));
         addTest(new org.apache.axiom.ts.soap11.headerblock.TestGetMustUnderstandWithParser(metaFactory));
         addTest(new org.apache.axiom.ts.soap11.headerblock.TestGetRoleWithParser(metaFactory));
-        addTest(new org.apache.axiom.ts.soap11.headerblock.TestSetMustUnderstandStringTrueFalse(metaFactory));
         if (supportsOMSourcedElement) {
             addTest(new org.apache.axiom.ts.soap11.misc.TestElementPullStreamAndOMExpansion(metaFactory));
             addTest(new org.apache.axiom.ts.soap11.misc.TestElementPullStreamAndOMExpansion2(metaFactory));

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetMustUnderstandWithInvalidValue.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetMustUnderstandWithInvalidValue.java?rev=1598845&r1=1598844&r2=1598845&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetMustUnderstandWithInvalidValue.java
(original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetMustUnderstandWithInvalidValue.java
Sat May 31 09:23:35 2014
@@ -29,14 +29,18 @@ import org.apache.axiom.ts.soap.SOAPTest
  * {@link SOAPProcessingException} if the argument is not a valid boolean literal.
  */
 public class TestSetMustUnderstandWithInvalidValue extends SOAPTestCase {
-    public TestSetMustUnderstandWithInvalidValue(OMMetaFactory metaFactory, SOAPSpec spec)
{
+    private final String value;
+    
+    public TestSetMustUnderstandWithInvalidValue(OMMetaFactory metaFactory, SOAPSpec spec,
String value) {
         super(metaFactory, spec);
+        this.value = value;
+        addTestParameter("value", value);
     }
 
     protected void runTest() throws Throwable {
         SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
         try {
-            soapHeaderBlock.setMustUnderstand("otherValue");
+            soapHeaderBlock.setMustUnderstand(value);
             fail("Expected SOAPProcessingException");
         } catch (SOAPProcessingException ex) {
             // Expected



Mime
View raw message