You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/04/11 19:52:12 UTC

svn commit: r527590 - in /incubator/tuscany/java/sca/modules/interface-wsdl-xml/src: main/java/org/apache/tuscany/interfacedef/wsdl/introspect/ test/java/org/apache/tuscany/interfacedef/wsdl/introspect/ test/resources/org/apache/tuscany/interfacedef/ws...

Author: rfeng
Date: Wed Apr 11 10:52:11 2007
New Revision: 527590

URL: http://svn.apache.org/viewvc?view=rev&rev=527590
Log:
Fix the inputType/outType for WSDLOperation and add more test cases

Added:
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/interfacedef/wsdl/introspect/
Modified:
    incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java?view=diff&rev=527590&r1=527589&r2=527590
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java Wed Apr 11 10:52:11 2007
@@ -60,8 +60,8 @@
     protected javax.wsdl.Operation operation;
     protected Operation operationModel;
     protected DataType<List<DataType>> inputType;
-    protected DataType<XMLType> outputType;
-    protected List<DataType<XMLType>> faultTypes;
+    protected DataType outputType;
+    protected List<DataType> faultTypes;
     private String dataBinding;
 
     /**
@@ -145,10 +145,10 @@
      * @return
      * @throws NotSupportedWSDLException
      */
-    public List<DataType<XMLType>> getFaultTypes() throws InvalidWSDLException {
+    public List<DataType> getFaultTypes() throws InvalidWSDLException {
         if (faultTypes == null) {
             Collection faults = operation.getFaults().values();
-            faultTypes = new ArrayList<DataType<XMLType>>();
+            faultTypes = new ArrayList<DataType>();
             for (Object f : faults) {
                 Fault fault = (Fault)f;
                 Message faultMsg = fault.getMessage();
@@ -186,21 +186,13 @@
             boolean oneway = (operation.getOutput() == null);
             operationModel = new OperationImpl();
             operationModel.setName(operation.getName());
-            operationModel.getFaultTypes().addAll(getFaultTypes());
+            operationModel.setFaultTypes(getFaultTypes());
             operationModel.setNonBlocking(oneway);
             operationModel.setConversationSequence(Operation.ConversationSequence.NO_CONVERSATION);
-            if (isWrapperStyle()) {
-                WrapperInfo wrapperInfo = getWrapper().getWrapperInfo();
-                operationModel.setInputType(wrapperInfo.getUnwrappedInputType());
-                operationModel.setOutputType(wrapperInfo.getUnwrappedOutputType());
-            } else {
-                List<DataType> inputTypes = new ArrayList<DataType>();
-                inputTypes.add(getInputType());
-                DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class,
-                                                                               inputTypes);
-                operationModel.setInputType(inputType);
-                operationModel.setOutputType(getOutputType());
-            }
+            operationModel.setInputType(getInputType());
+            operationModel.setOutputType(getOutputType());
+            
+            // FIXME: Need to set the wrapper style flag on the operation 
         }
         return operationModel;
     }

Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java?view=auto&rev=527590
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java Wed Apr 11 10:52:11 2007
@@ -0,0 +1,82 @@
+/*
+ * 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.tuscany.interfacedef.wsdl.introspect;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl
+ */
+public class DefaultWSDLInterfaceIntrospectorTestCase extends TestCase {
+    private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+    private WSDLDocumentProcessor registry;
+    private XMLSchemaRegistry schemaRegistry;
+    private PortType portType;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        registry = new WSDLDocumentProcessor();
+        schemaRegistry = new DefaultXMLSchemaRegistry();
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        Definition definition = registry.read(url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        portType = definition.getPortType(PORTTYPE_NAME);
+    }
+
+    public final void testIntrospectPortType() throws InvalidInterfaceException {
+        DefaultWSDLInterfaceIntrospector introspector = new DefaultWSDLInterfaceIntrospector(schemaRegistry);
+        WSDLInterface contract = introspector.introspect(portType);
+        Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType");
+        List<Operation> operations = contract.getOperations();
+        Assert.assertEquals(1, operations.size());
+        Operation operation = operations.get(0);
+        Assert.assertEquals("getLastTradePrice", operation.getName());
+        DataType<List<DataType>> inputType = operation.getInputType();
+        Assert.assertEquals(1, inputType.getLogical().size());
+        DataType<XMLType> returnType = operation.getOutputType();
+        Assert.assertNotNull(returnType);
+        Assert.assertEquals(0, operation.getFaultTypes().size());
+        // Assert.assertEquals(1,
+        // operation.getWrapper().getInputChildElements().size());
+        // Assert.assertEquals(1,
+        // operation.getWrapper().getOutputChildElements().size());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java?view=auto&rev=527590
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java Wed Apr 11 10:52:11 2007
@@ -0,0 +1,120 @@
+/*
+ * 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.tuscany.interfacedef.wsdl.introspect;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+
+/**
+ * Test case for WSDLOperation
+ */
+public class WSDLOperationTestCase extends TestCase {
+    private static final QName PORTTYPE_NAME =
+        new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+    private WSDLDocumentProcessor processor;
+    private XMLSchemaRegistry schemaRegistry;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        processor = new WSDLDocumentProcessor();
+        this.schemaRegistry = new DefaultXMLSchemaRegistry();
+    }
+
+    public final void testWrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        Definition definition = processor.read(url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+
+        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+
+        DataType<List<DataType>> inputType = op.getInputType();
+        Assert.assertEquals(1, inputType.getLogical().size());
+        DataType<XMLType> type = inputType.getLogical().get(0);
+        Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), type.getLogical().getElementName());
+
+        DataType<XMLType> outputType = op.getOutputType();
+        Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"),
+                            outputType.getLogical().getElementName());
+        Assert.assertTrue(op.isWrapperStyle());
+
+        DataType<List<DataType>> unwrappedInputType = op.getWrapper().getWrapperInfo().getUnwrappedInputType();
+        List<DataType> childTypes = unwrappedInputType.getLogical();
+        Assert.assertEquals(1, childTypes.size());
+        DataType<XMLType> childType = childTypes.get(0);
+        Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName());
+
+        childType = op.getWrapper().getWrapperInfo().getUnwrappedOutputType();
+        Assert.assertEquals(new QName(null, "price"), childType.getLogical().getElementName());
+    }
+
+    public final void testUnwrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
+        Definition definition = processor.read(url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        PortType portType = definition.getPortType(PORTTYPE_NAME);
+
+        Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        Assert.assertFalse(op.isWrapperStyle());
+        Assert.assertEquals(1, op.getInputType().getLogical().size());
+
+        operation = portType.getOperation("getLastTradePrice2", null, null);
+        op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        Assert.assertFalse(op.isWrapperStyle());
+        Assert.assertEquals(2, op.getInputType().getLogical().size());
+    }
+
+    public final void testInvalidWSDL() throws Exception {
+        URL url = getClass().getResource("../xml/invalid-stockquote.wsdl");
+        Definition definition = processor.read(url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        PortType portType = definition.getPortType(PORTTYPE_NAME);
+
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+
+        try {
+            op.isWrapperStyle();
+            fail("InvalidWSDLException should have been thrown");
+        } catch (InvalidWSDLException e) {
+            // Expected
+        }
+
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java?view=auto&rev=527590
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java Wed Apr 11 10:52:11 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.tuscany.interfacedef.wsdl.introspect;
+
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+
+/**
+ * Test case for WSDLOperation
+ */
+public class WrapperStyleOperationTestCase extends TestCase {
+    private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+    private WSDLDocumentProcessor registry;
+    private XMLSchemaRegistry schemaRegistry;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        registry = new WSDLDocumentProcessor();
+        this.schemaRegistry = new DefaultXMLSchemaRegistry();
+    }
+
+    public final void testWrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        Definition definition = registry.read( url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        Assert.assertTrue(op.isWrapperStyle());
+        Assert.assertEquals(1, op.getWrapper().getInputChildElements().size());
+        Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size());
+    }
+
+    public final void testUnwrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
+        Definition definition = registry.read( url).getDefinition();
+        schemaRegistry.loadSchemas(definition);
+        PortType portType = definition.getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+        WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        Assert.assertFalse(op.isWrapperStyle());
+        operation = portType.getOperation("getLastTradePrice2", null, null);
+        op = new WSDLOperation(operation, "org.w3c.dom.Node", schemaRegistry);
+        Assert.assertFalse(op.isWrapperStyle());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org