You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/07/14 20:41:37 UTC

svn commit: r676679 - in /ode/branches/APACHE_ODE_1.X/axis2/src: main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java test/resources/http-binding-validator.wsdl

Author: midon
Date: Mon Jul 14 11:41:36 2008
New Revision: 676679

URL: http://svn.apache.org/viewvc?rev=676679&view=rev
Log:
stop trying to have an exhaustive list of supported content types

Added:
    ode/branches/APACHE_ODE_1.X/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java
Modified:
    ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
    ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl

Modified: ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java?rev=676679&r1=676678&r2=676679&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java Mon Jul 14 11:41:36 2008
@@ -84,9 +84,6 @@
             if (StringUtils.isEmpty(outputContent.getType())) {
                 throw new IllegalArgumentException(httpMsgs.msgEmptyContentType(binding, bindingOperation));
             }
-            if (!outputContent.getType().endsWith("text/xml")) {
-                throw new IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding, bindingOperation));
-            }
         }
 
         BindingInput input = bindingOperation.getBindingInput();
@@ -103,9 +100,6 @@
             if (StringUtils.isEmpty(inputContentType)) {
                 throw new IllegalArgumentException(httpMsgs.msgEmptyContentType(binding, bindingOperation));
             }
-            if (!inputContentType.endsWith("text/xml") && !PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(inputContentType)) {
-                throw new IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding, bindingOperation));
-            }
         }
 
         if (WsdlUtils.useUrlReplacement(input)) {

Added: ode/branches/APACHE_ODE_1.X/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java?rev=676679&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java (added)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpHelperTest.java Mon Jul 14 11:41:36 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.ode.axis2.httpbinding;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ */
+public class HttpHelperTest extends TestCase {
+    private static final String[] IS_XML = new String[]{
+            "application/atom+xml"
+            , "text/xml"
+            , "application/xml"
+            , "application/xhtml+xml"
+            , "image/foo+xml"
+    };
+    private static final String[] IS_TEXT = new String[]{
+            "text/xml-external-parsed-entity"
+            , "text/plain"
+            , "text/css"
+            , "text/csv"
+    };
+    private static final String[] IS_IMAGE = new String[]{
+            "image/jpeg"
+            , "image/png"
+            , "image/gif"
+    };
+
+
+    public void testIsXml() {
+
+        for (String s : IS_XML) {
+            assertTrue(HttpHelper.isXml(s));
+        }
+        for (String s : IS_TEXT) {
+            assertFalse(HttpHelper.isXml(s));
+        }
+        for (String s : IS_IMAGE) {
+            assertFalse(HttpHelper.isXml(s));
+        }
+
+    }
+
+    public void testIsText() {
+        for (String s : IS_TEXT) {
+            assertTrue("", HttpHelper.isText(s));
+        }
+        for (String s : IS_XML) {
+            assertFalse(HttpHelper.isText(s));
+        }
+        for (String s : IS_IMAGE) {
+            assertFalse(HttpHelper.isXml(s));
+        }
+    }
+}

Modified: ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl?rev=676679&r1=676678&r2=676679&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl Mon Jul 14 11:41:36 2008
@@ -370,33 +370,78 @@
     <!-- ###################################### -->
     <!-- Content-Type tests-->
     <!-- ###################################### -->
-    <wsdl:binding name="DummyServiceHttpBinding_put+whatever-content-type" type="ns1:DummyServicePortType">
+    <wsdl:binding name="DummyServiceHttpBinding_application/atom+xml-content-type" type="ns1:DummyServicePortType">
         <wsdl:documentation>
-            shouldFail # Only application/x-www-form-urlencoded and text/xml should be supported
+            shouldPass # Supported Content-Types are: application/x-www-form-urlencoded, text/*, application/xml, *+xml
         </wsdl:documentation>
         <http:binding verb="PUT"/>
         <wsdl:operation name="hello">
             <http:operation location="DummyService/hello"/>
             <wsdl:input>
-                <mime:content type="whatever-content-type" part="TestPart"/>
+                <mime:content type="application/atom+xml" part="TestPart"/>
             </wsdl:input>
             <wsdl:output>
-                <mime:content type="text/xml" part="TestPart"/>
+                <mime:content type="application/atom+xml" part="TestPart"/>
             </wsdl:output>
         </wsdl:operation>
     </wsdl:binding>
-    <wsdl:binding name="DummyServiceHttpBinding_post+whatever-content-type" type="ns1:DummyServicePortType">
+    <wsdl:binding name="DummyServiceHttpBinding_application/.*+xml-content-type" type="ns1:DummyServicePortType">
         <wsdl:documentation>
-            shouldFail # Only application/x-www-form-urlencoded and text/xml should be supported
+            shouldPass # Supported Content-Types are: application/x-www-form-urlencoded, text/*, application/xml, *+xml
         </wsdl:documentation>
-        <http:binding verb="POST"/>
+        <http:binding verb="PUT"/>
+        <wsdl:operation name="hello">
+            <http:operation location="DummyService/hello"/>
+            <wsdl:input>
+                <mime:content type="application/atom+xml" part="TestPart"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="application/atom+xml" part="TestPart"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="DummyServiceHttpBinding_application/xml-*-content-type" type="ns1:DummyServicePortType">
+        <wsdl:documentation>
+            shouldPass # Supported Content-Types are: application/x-www-form-urlencoded, text/*, application/xml, *+xml
+        </wsdl:documentation>
+        <http:binding verb="PUT"/>
+        <wsdl:operation name="hello">
+            <http:operation location="DummyService/hello"/>
+            <wsdl:input>
+                <mime:content type="application/xml-dtd" part="TestPart"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="application/atom+xml" part="TestPart"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="DummyServiceHttpBinding_application/xml-content-type" type="ns1:DummyServicePortType">
+        <wsdl:documentation>
+            shouldPass # Supported Content-Types are: application/x-www-form-urlencoded, text/*, application/xml, *+xml
+        </wsdl:documentation>
+        <http:binding verb="PUT"/>
+        <wsdl:operation name="hello">
+            <http:operation location="DummyService/hello"/>
+            <wsdl:input>
+                <mime:content type="application/xml" part="TestPart"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="application/xml" part="TestPart"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="DummyServiceHttpBinding_text/plain-content-type" type="ns1:DummyServicePortType">
+        <wsdl:documentation>
+            shouldPass # Supported Content-Types are: application/x-www-form-urlencoded, text/*, application/xml, *+xml
+        </wsdl:documentation>
+        <http:binding verb="PUT"/>
         <wsdl:operation name="hello">
             <http:operation location="DummyService/hello"/>
             <wsdl:input>
-                <mime:content type="whatever-content-type" part="TestPart"/>
+                <mime:content type="text/plain" part="TestPart"/>
             </wsdl:input>
             <wsdl:output>
-                <mime:content type="text/xml" part="TestPart"/>
+                <mime:content type="text/plain" part="TestPart"/>
             </wsdl:output>
         </wsdl:operation>
     </wsdl:binding>