Author: jkaputin
Date: Tue Jun  6 06:17:23 2006
New Revision: 412115

URL: http://svn.apache.org/viewvc?rev=412115&view=rev
Log:
Initial commit of testcases for HTTP extensions to
BindingMessageReference.

Added:
    
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java
    
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl
Modified:
    incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java

Modified: incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java?rev=412115&r1=412114&r2=412115&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java 
(original)
+++ incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java Tue Jun 
 6 06:17:23 2006
@@ -27,6 +27,7 @@
 import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensionsTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensionsTest;
+import 
org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensionsTest;
 import 
org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensionsTest;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensionsTest;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensionsTest;
@@ -91,6 +92,7 @@
     addTest(HTTPBindingExtensionsTest.suite());
     addTest(HTTPBindingFaultExtensionsTest.suite());
     addTest(HTTPBindingOperationExtensionsTest.suite());
+    addTest(HTTPBindingMessageReferenceExtensionsTest.suite());
     //TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
   }
        

Added: 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java?rev=412115&view=auto
==============================================================================
--- 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java
 (added)
+++ 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java
 Tue Jun  6 06:17:23 2006
@@ -0,0 +1,185 @@
+/**
+ * Copyright 2006 Apache Software Foundation 
+ *
+ * Licensed 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.woden.wsdl20.extensions.http;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.extensions.ComponentExtensions;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+
+/**
+ * Functional verification test of HTTPBindingMessageReferenceExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ * 
+ * @author John Kaputin ([EMAIL PROTECTED])
+ */
+public class HTTPBindingMessageReferenceExtensionsTest extends TestCase {
+
+    private BindingOperation[] fBindOpers = null;
+    private String fWsdlPath = 
+        
"org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl";
+
+    public static Test suite()
+    {
+        return new TestSuite(HTTPBindingMessageReferenceExtensionsTest.class);
+    }
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        WSDLFactory factory = WSDLFactory.newInstance();
+        WSDLReader reader = factory.newWSDLReader();
+        ErrorHandler handler = new TestErrorHandler();
+        //Don't set validation on, as the testcase WSDL is not intended to be 
a valid WSDL 2.0 doc.
+        reader.getErrorReporter().setErrorHandler(handler);
+        
+        URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+        assertNotNull("Failed to find the WSDL document on the classpath using 
the path: " + fWsdlPath + ".", 
+                wsdlURL);
+        
+        DescriptionElement descElem = reader.readWSDL(wsdlURL.toString());
+        assertNotNull("The reader did not return a WSDL description.", 
descElem);
+        Description descComp = descElem.toComponent();
+        
+        Binding[] bindings = descComp.getBindings();
+        assertEquals("The Description should contain 1 Binding component.", 1, 
bindings.length);
+        
+        fBindOpers = bindings[0].getBindingOperations();
+        assertEquals("The Binding should contain 2 BindingOperation 
components.", 2, fBindOpers.length);
+    }
+
+    /**
+     * Testcases for the {http transfer coding} property returned 
+     * by the <code>getHttpTransferCoding</code> method.
+     * <p>
+     * 1. Test that the method returns "compress" if the whttp:transferCoding
+     * attribute parsed from the WSDL contains "compress".
+     * <p>
+     * 2. Test that it defaults to the {http transfer coding default} property
+     * of BindingOperation when the whttp:transferCoding attribute is omitted 
+     * from the WSDL. In this test, whttp:transferCodingDefault is set to
+     * "chunked".
+     */
+    public void testGetHttpTransferCoding() {
+        
+        BindingMessageReference[] bindMsgRefs = 
fBindOpers[0].getBindingMessageReferences();
+        assertEquals("The first BindingOperation should contain 2 
BindingMessageReference components.", 2, bindMsgRefs.length);
+        
+        //1. test that the property is parsed correctly from the WSDL
+        BindingMessageReference inputMsg = bindMsgRefs[0];
+        HTTPBindingMessageReferenceExtensions httpBindMsgRefExts = 
+            (HTTPBindingMessageReferenceExtensions) inputMsg
+                .getComponentExtensionsForNamespace(
+                    ComponentExtensions.URI_NS_HTTP);
+        
+        String actual = httpBindMsgRefExts.getHttpTransferCoding();
+        assertEquals("Unexpected value for http transfer coding.",
+                "compress",
+                actual);
+        
+        //2. test the default 
+        BindingMessageReference outputMsg = bindMsgRefs[1];
+        HTTPBindingMessageReferenceExtensions httpBindMsgRefExts2 = 
+            (HTTPBindingMessageReferenceExtensions) outputMsg
+                .getComponentExtensionsForNamespace(
+                    ComponentExtensions.URI_NS_HTTP);
+        
+        String actual2 = httpBindMsgRefExts2.getHttpTransferCoding();
+        assertEquals("Unexpected default value for http transfer coding.",
+                "chunked",
+                actual2);
+    }
+
+    /**
+     * Testcases for the {http headers} property returned 
+     * by the <code>getHttpHeaders</code> method.
+     * <p>
+     * 1. Test that the method returns an array size 2 when there are
+     * two whttp:header extension elements in the WSDL.
+     * <p>
+     * 2. Test that the method returns an array size 1 when there is
+     * one whttp:header extension element in the WSDL.
+     */
+    public void testGetHttpHeaders() {
+        
+        BindingMessageReference[] bindMsgRefs = 
fBindOpers[0].getBindingMessageReferences();
+        assertEquals("The first BindingOperation should contain 2 
BindingMessageReference components.", 2, bindMsgRefs.length);
+        
+        //1. test for 2 HTTPHeader components
+        BindingMessageReference inputMsg = bindMsgRefs[0];
+        HTTPBindingMessageReferenceExtensions httpBindMsgRefExts = 
+            (HTTPBindingMessageReferenceExtensions) inputMsg
+                .getComponentExtensionsForNamespace(
+                    ComponentExtensions.URI_NS_HTTP);
+        
+        HTTPHeader[] actual = httpBindMsgRefExts.getHttpHeaders();
+        assertEquals("Unexpected size of {http headers}.",
+                2,
+                actual.length);
+        
+        //2. test the default 
+        BindingMessageReference outputMsg = bindMsgRefs[1];
+        HTTPBindingMessageReferenceExtensions httpBindMsgRefExts2 = 
+            (HTTPBindingMessageReferenceExtensions) outputMsg
+                .getComponentExtensionsForNamespace(
+                    ComponentExtensions.URI_NS_HTTP);
+        
+        HTTPHeader[] actual2 = httpBindMsgRefExts2.getHttpHeaders();
+        assertEquals("Unexpected size of {http headers}.",
+                1,
+                actual2.length);
+        
+    }
+    
+    /**
+     * Test that an HTTPBindingMessageReferenceExtensions object is not created
+     * for a binding operation wsdl:input or wsdl:output message that does not 
+     * contain any HTTP extension extension attributes or elements (i.e. the
+     * HTTP extension properties are OPTIONAL in the spec, so even though 
+     * {http transfer coding} defaults to {http transfer coding default} in
+     * BindingOperation, it will not be present if the underlying message ref
+     * element has not HTTP extensions).
+     */
+    public void testOptional() {
+        
+        BindingMessageReference[] bindMsgRefs = 
fBindOpers[1].getBindingMessageReferences();
+        assertEquals("The second BindingOperation should contain 1 
BindingMessageReference components.", 1, bindMsgRefs.length);
+        
+        BindingMessageReference inputMsg = bindMsgRefs[0];
+        HTTPBindingMessageReferenceExtensions httpBindMsgRefExts = 
+            (HTTPBindingMessageReferenceExtensions) inputMsg
+                .getComponentExtensionsForNamespace(
+                    ComponentExtensions.URI_NS_HTTP);
+        
+        assertNull("The BindingMessageReference contained an " +
+                "HTTPBindingMessageReferenceExtensions object.",
+                httpBindMsgRefExts);
+    }
+
+}

Added: 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl?rev=412115&view=auto
==============================================================================
--- 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl
 (added)
+++ 
incubator/woden/java/test/org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl
 Tue Jun  6 06:17:23 2006
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- 
+ * Copyright 2006 Apache Software Foundation 
+ *
+ * Licensed 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.
+-->
+<description xmlns="http://www.w3.org/2006/01/wsdl";
+       targetNamespace="http://ws.apache.woden";
+       xmlns:tns="http://ws.apache.woden";
+       xmlns:xs="http://www.w3.org/2001/XMLSchema";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xmlns:whttp= "http://www.w3.org/2006/01/wsdl/http";
+       xsi:schemaLocation=
+           "http://www.w3.org/2006/01/wsdl 
http://www.w3.org/2006/01/wsdl/wsdl20.xsd 
+           http://www.w3.org/2001/XMLSchema 
http://www.w3.org/2001/XMLSchema.xsd";>
+
+       <documentation>
+           Used by HTTPBindingMessageReferenceExtensionsTest to test the 
+           HTTPBindingMessageReferenceExtensions implementation.
+           This is not a valid WSDL 2.0 document and is not intended to be 
parsed with validation
+           enabled. It contains only the elements and attributes required to 
test that HTTP extensions
+           to the binding operation's wsdl:input and wsdl:output elements are 
parsed 
+           correctly into the expected object model and can be accessed via 
the API. 
+       </documentation>
+
+       <interface name="interface1"> 
+           <operation name="operation1" />
+           <operation name="operation2" />
+       </interface>
+       
+       <binding name="binding1"
+         interface="tns:interface1"
+         type="http://www.w3.org/2006/01/wsdl/http";>
+         
+         <operation ref="tns:operation1"
+             whttp:transferCodingDefault="chunked" >
+             
+             <input messageLabel="IN"
+                 whttp:transferCoding="compress">
+                 <documentation>
+                     {http transfer coding} should be "compress"
+                     {http headers} should contain 2 HTTPHeader components
+                 </documentation>
+                 <whttp:header name="Destination" type="xs:string" 
required="true" />
+                 <whttp:header name="Content" type="xs:string" 
required="false" />
+             </input>
+             
+             <output messageLabel="OUT">
+                 <documentation>
+                     {http transfer coding} should default to {http transfer 
coding default}
+                     in binding operation, which in this testcase is "chunked".
+                     {http headers} should contain 1 HTTPHeader component
+                 </documentation>
+                 <whttp:header name="Destination" type="xs:string" 
required="true" />
+             </output>
+             
+         </operation>
+             
+         <operation ref="tns:operation2"
+             whttp:transferCodingDefault="chunked" >
+             
+             <input messageLabel="IN">
+                 <documentation>
+                     According to the spec Part 2 sect 6.8.2 
+                     {http transfer coding} should default to {http transfer 
coding default}
+                     in binding operation, which in this testcase is "chunked".
+                     However, the spec also defines {http transfer coding} as 
OPTIONAL, so for
+                     this test case there are no HTTP extensions to the input 
message so there
+                     will be no extension properties, default or otherwise!
+                     Test that HTTPBindingMessageReferenceExtensions does NOT 
exist
+                     for the BindingMessageReference representing this input 
message.
+                 </documentation>
+             </input>
+             
+         </operation>
+             
+       </binding>
+    
+</description>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to