diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:06:58 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:06:58 +0000 |
commit | 3dd7e2c4da9c80b8182a2d04dc129a67aa7910df (patch) | |
tree | 71b970aa1c5987564405511d3912044387118fd4 /branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect | |
parent | 0f3f9b59b310833f31ba234ee4aefa808649833c (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835121 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect')
4 files changed, 0 insertions, 398 deletions
diff --git a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java b/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java deleted file mode 100644 index 3c160a3bfa..0000000000 --- a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A default implementation of an artifact resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map<Object, Object> map = new HashMap<Object, Object>(); - - public TestModelResolver() { - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - -} diff --git a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java b/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java deleted file mode 100644 index 275f2fa8d8..0000000000 --- a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 junit.framework.TestCase; - -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -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.DefaultWSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver; - -/** - * Test case for InterfaceWSDLIntrospectorImpl - */ -public class WSDLInterfaceIntrospectorTestCase extends TestCase { - private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); - - private WSDLDocumentProcessor registry; - private WSDLFactory wsdlFactory; - private PortType portType; - private ModelResolver resolver; - private WSDLDefinition definition; - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint(); - wsdlFactory = new DefaultWSDLFactory(); - factories.addFactory(wsdlFactory); - javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance(); - factories.addFactory(wsdl4jFactory); - registry = new WSDLDocumentProcessor(factories); - resolver = new TestModelResolver(); - URL url = getClass().getResource("../xml/stockquote.wsdl"); - definition = registry.read(null, new URI("stockquote.wsdl"), url); - WSDLModelResolver wsdlResolver = new WSDLModelResolver(null, factories); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - } - - @SuppressWarnings("unchecked") - public final void testIntrospectPortType() throws InvalidInterfaceException { - WSDLInterface contract = wsdlFactory.createWSDLInterface(portType, definition.getInlinedSchemas(), 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()); - } - -} diff --git a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java deleted file mode 100644 index 91586f7440..0000000000 --- a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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 junit.framework.TestCase; - -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -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.DefaultWSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver; - -/** - * Test case for WSDLOperation - */ -public class WSDLOperationIntrospectorTestCase extends TestCase { - private static final QName PORTTYPE_NAME = - new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); - - private WSDLDocumentProcessor processor; - private WSDLModelResolver wsdlResolver; - private ModelResolver resolver; - private WSDLFactory wsdlFactory; - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - wsdlFactory = new DefaultWSDLFactory(); - ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint(); - factories.addFactory(wsdlFactory); - javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance(); - factories.addFactory(wsdl4jFactory); - processor = new WSDLDocumentProcessor(factories); - wsdlResolver = new WSDLModelResolver(null, factories); - resolver = new TestModelResolver(); - } - - @SuppressWarnings("unchecked") - public final void testWrappedOperation() throws Exception { - URL url = getClass().getResource("../xml/stockquote.wsdl"); - WSDLDefinition definition = processor.read(null, new URI("stockquote.wsdl"), url); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); - PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice", null, null); - - WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "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 = processor.read(null, new URI("unwrapped-stockquote.wsdl"), url); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); - PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - - Operation operation = portType.getOperation("getLastTradePrice1", null, null); - WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "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(wsdlFactory, operation, definition.getInlinedSchemas(), "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 = processor.read(null, new URI("invalid-stockquote.wsdl"), url); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); - PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - - Operation operation = portType.getOperation("getLastTradePrice", null, null); - WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); - - try { - op.isWrapperStyle(); - fail("InvalidWSDLException should have been thrown"); - } catch (InvalidInterfaceException e) { - // Expected - } - - } - -} diff --git a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java b/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java deleted file mode 100644 index 1960bcbca7..0000000000 --- a/branches/sca-java-0.99/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 junit.framework.TestCase; - -import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; -import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; -import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver; - -/** - * 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 ModelResolver resolver; - private WSDLFactory wsdlFactory; - private WSDLModelResolver wsdlResolver; - - /** - * @see junit.framework.TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint(); - wsdlFactory = new DefaultWSDLFactory(); - factories.addFactory(wsdlFactory); - javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance(); - factories.addFactory(wsdl4jFactory); - registry = new WSDLDocumentProcessor(factories); - resolver = new TestModelResolver(); - wsdlResolver = new WSDLModelResolver(null, factories); - } - - public final void testWrappedOperation() throws Exception { - URL url = getClass().getResource("../xml/stockquote.wsdl"); - WSDLDefinition definition = registry.read(null, new URI("stockquote.wsdl"), url); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); - PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice", null, null); - WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "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 = registry.read(null, new URI("unwrapped-stockquote.wsdl"), url); - wsdlResolver.addModel(definition); - definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); - PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice1", null, null); - WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); - Assert.assertFalse(op.isWrapperStyle()); - operation = portType.getOperation("getLastTradePrice2", null, null); - op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); - Assert.assertFalse(op.isWrapperStyle()); - } - -} |