You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2008/12/03 14:23:03 UTC

svn commit: r722879 - /tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/

Author: edwardsmj
Date: Wed Dec  3 05:23:03 2008
New Revision: 722879

URL: http://svn.apache.org/viewvc?rev=722879&view=rev
Log:
Testcases moved back to interface-wsdl-xml from interface-wsdl in the 2.0 stream, as a fix for Tuscany 2704.

Added:
    tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/
    tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
    tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
    tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java
    tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java

Added: tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java?rev=722879&view=auto
==============================================================================
--- tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java (added)
+++ tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java Wed Dec  3 05:23:03 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl.
+ *
+ * @version $Rev: 656600 $ $Date: 2008-05-15 12:57:26 +0100 (Thu, 15 May 2008) $
+ */
+public class WSDLInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
+    private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+    private PortType portType;
+    private WSDLDefinition definition;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+    }
+
+    @SuppressWarnings("unchecked")
+    public final void testIntrospectPortType() throws InvalidInterfaceException {
+        WSDLInterface contract = wsdlFactory.createWSDLInterface(portType, definition, resolver);
+        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());
+    }
+
+}

Added: tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java?rev=722879&view=auto
==============================================================================
--- tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java (added)
+++ tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java Wed Dec  3 05:23:03 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl;
+
+/**
+ * Test case for WSDLOperation.
+ *
+ * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $
+ */
+public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase {
+    private static final QName PORTTYPE_NAME =
+        new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+
+    @SuppressWarnings("unchecked")
+    public final void testWrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+
+        WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+
+        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");
+        WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("unwrapped-stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+
+        Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+        WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+        Assert.assertFalse(op.isWrapperStyle());
+        Assert.assertEquals(1, op.getInputType().getLogical().size());
+
+        operation = portType.getOperation("getLastTradePrice2", null, null);
+        op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+        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");
+        WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("invalid-stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+        WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+
+        try {
+            op.isWrapperStyle();
+            fail("InvalidWSDLException should have been thrown");
+        } catch (InvalidInterfaceException e) {
+            // Expected
+        }
+
+    }
+
+}

Added: tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java?rev=722879&view=auto
==============================================================================
--- tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java (added)
+++ tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java Wed Dec  3 05:23:03 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl.
+ *
+ * @version $Rev: 665985 $ $Date: 2008-06-10 06:35:33 +0100 (Tue, 10 Jun 2008) $
+ */
+public class WSDLPolicyAnnotatedInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
+    private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+    private static final QName INTENT = new QName("http://example.com/stockquote.wsdl", "PolicyIntent");
+
+    private PortType portType;
+    private WSDLDefinition definition;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        URL url = getClass().getResource("/policy/stockquote_policy.wsdl");
+        definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+    }
+
+    @SuppressWarnings("unchecked")
+    public final void testIntrospectPortType() throws InvalidInterfaceException {
+        WSDLInterface contract = wsdlFactory.createWSDLInterface(portType, definition, resolver);
+        Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType");
+        Assert.assertTrue(contract.isConversational());
+        
+        boolean foundIntent = false;
+        
+        for(Intent intent : contract.getRequiredIntents()) {
+            if(INTENT.equals(intent.getName())) {
+                foundIntent = true;
+            }
+        }
+        
+        Assert.assertTrue(foundIntent);
+        
+        for(Operation operation : contract.getOperations()) {
+            if(operation.getName().equals("cancel")) {
+                Assert.assertEquals(operation.getConversationSequence(), ConversationSequence.CONVERSATION_END);
+            }
+        }
+        
+    }
+}

Added: tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java?rev=722879&view=auto
==============================================================================
--- tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java (added)
+++ tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java Wed Dec  3 05:23:03 2008
@@ -0,0 +1,70 @@
+/*
+ * 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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl;
+
+/**
+ * Test case for WSDLOperation.
+ *
+ * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $
+ */
+public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase {
+    private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+    public final void testWrappedOperation() throws Exception {
+        URL url = getClass().getResource("../xml/stockquote.wsdl");
+        WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice", null, null);
+        WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+        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");
+        WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("unwrapped-stockquote.wsdl"), url);
+        resolver.addModel(definition);
+        definition = resolver.resolveModel(WSDLDefinition.class, definition);
+        PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+        Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+        WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+        Assert.assertFalse(op.isWrapperStyle());
+        operation = portType.getOperation("getLastTradePrice2", null, null);
+        op = new WSDLOperationIntrospectorImpl(xsdFactory, operation, definition, "org.w3c.dom.Node", resolver);
+        Assert.assertFalse(op.isWrapperStyle());
+    }
+
+}