You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2008/04/22 14:59:38 UTC

svn commit: r650504 - in /incubator/tuscany/java/sca/modules/binding-ws-xml/src/test: java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite

Author: antelder
Date: Tue Apr 22 05:59:34 2008
New Revision: 650504

URL: http://svn.apache.org/viewvc?rev=650504&view=rev
Log:
TUSCANY-2241: Apply patch from Vamsavardhana Reddy to add a testcase for EndpointReference in binding.ws when wsdlElement is not of 'Binding' form

Added:
    incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite
Modified:
    incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java?rev=650504&r1=650503&r2=650504&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java Tue Apr 22 05:59:34 2008
@@ -44,6 +44,7 @@
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
 import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
@@ -132,4 +133,23 @@
         //new PrintUtil(System.out).print(composite);
     }
 
+    /**
+     * This test makes sure that an exception is thrown when a bad wsdlElement is present along with EndpointReference.
+     *
+     * Ref: Web Service Binding Specification v1.0 - Sec 2.1 - Lines 61 to 65.
+     * When an EndpointReference is present along with the wsdlElement attribute on the parent element, the wsdlElement attribute value MUST
+     * be of the 'Binding' form.
+     */
+    public void testReadBadWsdlElement() throws Exception {
+        CompositeProcessor compositeProcessor = new CompositeProcessor(new DefaultContributionFactory(), assemblyFactory, policyFactory, staxProcessor);
+        InputStream is = getClass().getResourceAsStream("Calculator-bad-wsdlElement.composite");
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+        try {
+            Composite composite = compositeProcessor.read(reader);
+            fail("ContributionReadException expected.");
+        } catch(ContributionReadException e) {
+            // Expected
+            assertNotSame(-1, e.getMessage().indexOf("must use wsdl.binding when using wsa:EndpointReference"));
+        }
+    }
 }

Added: incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite?rev=650504&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite Tue Apr 22 05:59:34 2008
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+    xmlns:calc="http://sample.calculator"
+    targetNamespace="http://calc"
+    xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+    name="Calculator-bad-wsdlElement">
+
+    <service name="CalculatorService" promote="CalculatorServiceComponent">
+        <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+        <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)">
+            <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+                <wsa:Address>http://localhost:8085/Calculator</wsa:Address>
+            </wsa:EndpointReference>
+        </binding.ws>
+    </service>
+
+    <component name="CalculatorServiceComponent">
+        <implementation.java class="calculator.CalculatorServiceImpl"/>
+        <reference name="addService" target="AddServiceComponent"/>
+        <reference name="subtractService" target="SubtractServiceComponent"/>
+        <reference name="multiplyService" target="MultiplyServiceComponent"/>
+        <reference name="divideService" target="DivideServiceComponent"/>
+    </component>
+
+    <component name="AddServiceComponent">
+        <implementation.java class="calculator.AddServiceImpl"/>
+    </component>
+
+    <component name="SubtractServiceComponent">
+        <implementation.java class="calculator.SubtractServiceImpl"/>
+    </component>
+
+    <component name="MultiplyServiceComponent">
+        <implementation.java class="calculator.MultiplyServiceImpl"/>
+    </component>
+
+    <component name="DivideServiceComponent">
+        <implementation.java class="calculator.DivideServiceImpl"/>
+    </component>
+
+</composite>