diff options
Diffstat (limited to 'branches/sca-java-integration/sca/extensions/axis2/binding/src/test')
7 files changed, 0 insertions, 886 deletions
diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderTestCase.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderTestCase.java deleted file mode 100644 index 4cb40b0a23..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderTestCase.java +++ /dev/null @@ -1,229 +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.binding.axis2; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.wsdl.extensions.soap.SOAPAddress; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; - -/** - * Tests for the WebServicebindingLoader class - */ -@SuppressWarnings("deprecation") -public class Axis2BindingBuilderTestCase extends TestCase { - - private CompositeComponent parent; - - private static final String NAME = "MyService"; - private static final URI COMPOSITE_NAME = URI.create("MyComposite"); - private static final URI COMPOSITE_NAME2 = URI.create("MyComposite2"); - private static final String BASE_URI = "http://localhost/services"; - - public void testDefaultURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(null, null, null, null, null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/MyService", uri.toString()); - } - - public void testDefaultURIMultiServices() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(null, null, null, null, null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME2, NAME, parent); - assertEquals("http://localhost/services/MyComposite2/MyService", uri.toString()); - } - - public void testExplicitURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(null, null, null, null, null, "http://foo/bar"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://foo/bar", uri.toString()); - } - - public void testExplicitWSDL() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("http://my/wsdl/uri"), "myService", "myPort", null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://my/wsdl/uri", uri.toString()); - } - - public void testExplicitWSDLExplicitURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("http://my/wsdl/uri"), "myService", "myPort", null, "foo"); - try { - builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - public void testExplicitWSDLBindingExplicitURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDLBinding("http://my/wsdl/uri"), null, null, "myBinding", "http://my/uri"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - - // explicit URI should be used as the WSDL binding is used not the wsdl service/port - assertEquals("http://my/uri", uri.toString()); - } - - public void testExplicitWSDLBindingExplicitRelativeURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDLBinding("http://my/wsdl/uri"), null, null, "myBinding", "x/y"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/x/y", uri.toString()); - } - - public void testExplicitWSDLBindingExplicitRelativeURIWithDot() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDLBinding("http://my/wsdl/uri"), null, null, "myBinding", "x/./y"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/x/y", uri.toString()); - } - - public void testExplicitWSDLBindingExplicitRelativeURIWithDots() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDLBinding("http://my/wsdl/uri"), null, null, "myBinding", "../x/y"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/x/y", uri.toString()); - } - - public void testExplicitRelativeWSDL() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("foo/bar"), "myService", "myPort", null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/MyService/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLMultiServices() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("foo/bar"), "myService", "myPort", null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME2, NAME, parent); - assertEquals("http://localhost/services/MyComposite2/MyService/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLWithDots() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("../foo/bar"), "myService", "myPort", null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLWithDotsMultiService() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("../foo/bar"), "myService", "myPort", null, null); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME2, NAME, parent); - assertEquals("http://localhost/services/MyComposite2/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLExplicitURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("foo/bar"), "myService", "myPort", null, "http://my/wsdl/uri"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://my/wsdl/uri/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLWithDotsExplicitURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("../foo/bar"), "myService", "myPort", null, "http://my/wsdl/uri"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://my/wsdl/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLExplicitRelativeURI() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("foo/bar"), "myService", "myPort", null, "x/y"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/MyComposite/x/y/foo/bar", uri.toString()); - } - - public void testExplicitRelativeWSDLExplicitRelativeURIWithDots() throws Exception { - Axis2BindingBuilder builder = new Axis2BindingBuilder(); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition("myNS", createMockWSDL("foo/bar"), "myService", "myPort", null, "../x/y"); - URI uri = builder.computeActualURI(wsBinding, BASE_URI, COMPOSITE_NAME, NAME, parent); - assertEquals("http://localhost/services/x/y/foo/bar", uri.toString()); - } - - protected Definition createMockWSDL(String endpoint) { - Definition mockDef = createMock(Definition.class); - - Service wsdlService = createMock(Service.class); - expect(wsdlService.getQName()).andReturn(new QName("myNS", "myService")); - - Port wsdlPort = createMock(Port.class); - List<SOAPAddress> ees = new ArrayList<SOAPAddress>(); - SOAPAddress sa = createMock(SOAPAddress.class); - expect(sa.getLocationURI()).andReturn(endpoint); - ees.add(sa); - expect(wsdlPort.getExtensibilityElements()).andReturn(ees); - - expect(wsdlService.getPort("myPort")).andReturn(wsdlPort); - - Map<String, Service> services = new HashMap<String, Service>(); - services.put("myService", wsdlService); - expect(mockDef.getServices()).andReturn(services); - - replay(mockDef); - replay(wsdlService); - replay(wsdlPort); - replay(sa); - return mockDef; - } - protected Definition createMockWSDLBinding(String endpoint) { - Definition mockDef = createMock(Definition.class); - replay(mockDef); - return mockDef; - } - - protected void setUp() { - parent = createMock(CompositeComponent.class); - Component comp1 = createMock(Component.class); - Component comp2 = createMock(Component.class); - Collection wires1 = new ArrayList(); - wires1.add("dummy1"); - Collection wires2 = new ArrayList(); - wires2.add("dummy1"); - wires2.add("dummy2"); - expect(comp1.getInboundWires()).andReturn(wires1); - expect(comp2.getInboundWires()).andReturn(wires2); - expect(parent.getChild(COMPOSITE_NAME.toString())).andReturn(comp1); - expect(parent.getChild(COMPOSITE_NAME2.toString())).andReturn(comp2); - replay(comp1); - replay(comp2); - replay(parent); - } -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java deleted file mode 100755 index e8f1f29034..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java +++ /dev/null @@ -1,111 +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.binding.axis2; - -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; - -import java.lang.reflect.Type; -import java.net.URL; -import java.util.HashMap; - -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.idl.wsdl.WSDLServiceContract; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; -import org.easymock.EasyMock; -import org.xml.sax.InputSource; - -public class Axis2ReferenceTestCase extends TestCase { - - public void testInvokeService() throws Exception { - Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); - ServiceContract contract = new JavaServiceContract(); - Operation operation = new Operation<Type>("sayHi", null, null, null, false, null, NO_CONVERSATION); - TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(contract, operation); - assertNotNull(targetInvoker); - assertFalse(targetInvoker instanceof Axis2AsyncTargetInvoker); - } - - public void testAsyncTargetInvoker() throws Exception { - Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); - //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class - InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class); - JavaServiceContract contract = new JavaServiceContract(Greeter.class); - contract.setCallbackName(""); - contract.setCallbackClass(GreetingCallback.class); - Operation<Type> callbackOp = - new Operation<Type>("sayHiCallback", null, null, null, true, null, NO_CONVERSATION); - HashMap<String, Operation<Type>> callbackOps = new HashMap<String, Operation<Type>>(); - callbackOps.put("sayHiCallback", callbackOp); - contract.setCallbackOperations(callbackOps); - EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes(); - EasyMock.replay(inboundWire); - - axis2Reference.setInboundWire(inboundWire); - Operation operation = new Operation<Type>("sayHi", null, null, null, true, null, NO_CONVERSATION); - TargetInvoker asyncTargetInvoker = axis2Reference.createTargetInvoker(contract, operation); - assertNotNull(asyncTargetInvoker); - assertTrue(asyncTargetInvoker instanceof Axis2AsyncTargetInvoker); - } - - @SuppressWarnings("unchecked") - private Axis2ReferenceBinding createAxis2Reference(String webAppName, String serviceName) throws Exception { - //Create WebServiceBindingDefinition - String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; - URL url = getClass().getResource(wsdlLocation); - assertNotNull("Could not find wsdl " + url.toString(), url); - - WSDLFactory factory = WSDLFactory.newInstance(); - WSDLReader reader = factory.newWSDLReader(); - reader.setFeature("javax.wsdl.verbose", false); - InputSource input = new InputSource(url.openStream()); - Definition wsdlDef = reader.readWSDL(url.toString(), input); - Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", - "SOAPService")); - Port port = wsdlService.getPort("SoapPort"); - WebServiceBindingDefinition wsBinding = - new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); - //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. - WireService wireService = EasyMock.createNiceMock(WireService.class); - EasyMock.replay(wireService); - CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class); - // TODO figure out what to do with the service contract - ServiceContract<?> contract = new WSDLServiceContract(); - contract.setInterfaceClass(Greeter.class); - return new Axis2ReferenceBinding(serviceName, - parent, - wsBinding, - contract, - null, - null); - } -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java deleted file mode 100755 index 03340275b3..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java +++ /dev/null @@ -1,153 +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.binding.axis2; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import javax.servlet.Servlet; -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; - -import org.xml.sax.InputSource; - -import org.apache.tuscany.spi.host.ServletHost; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -public class Axis2ServiceTestCase extends TestCase { - - public void testInvokeService() throws Exception { - TestServletHost tomcatHost = new TestServletHost(); - Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, false); - axis2Service.start(); - - if (true) return; - Servlet servlet = tomcatHost.getMapping("testWebAppName/serviceBindings/testServiceName"); - assertNotNull(servlet); - - //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet - //To be done: - - } - - public void testAsyncMessageReceiver() throws Exception { - - TestServletHost tomcatHost = new TestServletHost(); - Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, true); - axis2Service.start(); - } - - @SuppressWarnings("unchecked") - private Axis2ServiceBinding createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback) - throws Exception { - //Create WebServiceBindingDefinition - String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; - URL url = getClass().getResource(wsdlLocation); - assertNotNull("Could not find wsdl " + url.toString(), url); - - WSDLFactory factory = WSDLFactory.newInstance(); - WSDLReader reader = factory.newWSDLReader(); - reader.setFeature("javax.wsdl.verbose", false); - InputSource input = new InputSource(url.openStream()); - Definition wsdlDef = reader.readWSDL(url.toString(), input); - Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", - "SOAPService")); - Port port = wsdlService.getPort("SoapPort"); - WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); - - //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. - WireService wireService = EasyMock.createNiceMock(WireService.class); - wireService.createProxy(EasyMock.isA(Class.class), EasyMock.isA(InboundWire.class)); - EasyMock.expectLastCall().andReturn(null); - EasyMock.replay(wireService); - - //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class - InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class); - JavaServiceContract contract = new JavaServiceContract(Greeter.class); - Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>(); - for (Method m : Greeter.class.getMethods()) { - opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null)); - } - contract.setOperations(opMap); - EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes(); - if (callback) { - contract.setCallbackName(""); - } - EasyMock.replay(inboundWire); - - OutboundWire outboundWire = EasyMock.createNiceMock(OutboundWire.class); - Map<Operation<?>, OutboundInvocationChain> map = new HashMap<Operation<?>, OutboundInvocationChain>(); - EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once(); - EasyMock.replay(outboundWire); - - TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); - ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext(); - Axis2ServiceBinding axis2Service = - new Axis2ServiceBinding(serviceName, - contract, - null, - null, - wsBinding, - tomcatHost, - configurationContext, new WorkContextImpl()); - axis2Service.setInboundWire(inboundWire); - axis2Service.setOutboundWire(outboundWire); - - return axis2Service; - } - - protected class TestServletHost implements ServletHost { - private Map<String, Servlet> mappings = new HashMap<String, Servlet>(); - - public void registerMapping(String mapping, Servlet servlet) { - mappings.put(mapping, servlet); - } - - public Servlet unregisterMapping(String mapping) { - return mappings.remove(mapping); - } - - public Servlet getMapping(String mapping) { - return mappings.get(mapping); - } - - public boolean isMappingRegistered(String mapping) { - return mappings.containsKey(mapping); - } - - } - -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java deleted file mode 100755 index 39fccdadd3..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java +++ /dev/null @@ -1,31 +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.binding.axis2; - -public interface Greeter { - - String sayHi(); - - String greetMe(String requestType); - - void greetMeOneWay(String requestType); - - void greetMeWithCallback(String requestType); - -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java deleted file mode 100644 index 4c3b3304ea..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java +++ /dev/null @@ -1,24 +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.binding.axis2; - -public interface GreetingCallback { - - void greetMeCallback(String greetMeResponse); -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/WebServicebindingLoaderTestCase.java b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/WebServicebindingLoaderTestCase.java deleted file mode 100644 index 75a848b88e..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/java/org/apache/tuscany/binding/axis2/WebServicebindingLoaderTestCase.java +++ /dev/null @@ -1,187 +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.binding.axis2; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -import java.util.HashMap; -import java.util.Map; - -import javax.wsdl.Binding; -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry; -import org.easymock.EasyMock; - -/** - * Tests for the WebServicebindingLoader class - */ -@SuppressWarnings("deprecation") -public class WebServicebindingLoaderTestCase extends TestCase { - - public void testCreateWSBinding() throws Exception { - WSDLDefinitionRegistry wsdlReg = createMock(WSDLDefinitionRegistry.class); - Definition mockDef = createMock(Definition.class); - expect(wsdlReg.getDefinition("myNS")).andReturn(mockDef); - replay(wsdlReg); - - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, wsdlReg); - - WebServiceBindingDefinition binding = loader.createWSBinding("myNS#wsdl.service(myService)", null, null, null); - assertEquals(mockDef, binding.getWSDLDefinition()); - - EasyMock.verify(wsdlReg); - } - - public void testCreateWSBindingWsdlService() throws Exception { - WSDLDefinitionRegistry wsdlReg = createMock(WSDLDefinitionRegistry.class); - Definition mockDef = createMock(Definition.class); - - Service wsdlService = createMock(Service.class); - expect(wsdlService.getQName()).andReturn(new QName("myNS", "myService")); - - Map<String, Service> services = new HashMap<String, Service>(); - services.put("myService", wsdlService); - expect(mockDef.getServices()).andReturn(services); - - expect(wsdlReg.getDefinition("myNS")).andReturn(mockDef); - - replay(wsdlService); - replay(wsdlReg); - replay(mockDef); - - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, wsdlReg); - - WebServiceBindingDefinition binding = loader.createWSBinding("myNS#wsdl.service(myService)", null, null, null); - assertEquals(mockDef, binding.getWSDLDefinition()); - - assertEquals(wsdlService, binding.getWSDLService()); - - EasyMock.verify(wsdlService); - EasyMock.verify(wsdlReg); - EasyMock.verify(mockDef); - } - - public void testCreateWSBindingWsdlPort() throws Exception { - WSDLDefinitionRegistry wsdlReg = createMock(WSDLDefinitionRegistry.class); - Definition mockDef = createMock(Definition.class); - - Service wsdlService = createMock(Service.class); - expect(wsdlService.getQName()).andReturn(new QName("myNS", "myService")); - - Port wsdlPort = createMock(Port.class); - expect(wsdlService.getPort("myPort")).andReturn(wsdlPort); - - Map<String, Service> services = new HashMap<String, Service>(); - services.put("myService", wsdlService); - expect(mockDef.getServices()).andReturn(services); - - expect(wsdlReg.getDefinition("myNS")).andReturn(mockDef); - - replay(wsdlService); - replay(wsdlReg); - replay(mockDef); - - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, wsdlReg); - - WebServiceBindingDefinition binding = loader.createWSBinding("myNS#wsdl.port(myService/myPort)", null, null, null); - assertEquals(mockDef, binding.getWSDLDefinition()); - - assertEquals(wsdlPort, binding.getWSDLPort()); - - EasyMock.verify(wsdlService); - EasyMock.verify(wsdlReg); - EasyMock.verify(mockDef); - } - - public void testCreateWSBindingWsdlBinding() throws Exception { - WSDLDefinitionRegistry wsdlReg = createMock(WSDLDefinitionRegistry.class); - Definition mockDef = createMock(Definition.class); - - Binding wsdlBinding = createMock(Binding.class); - QName bindingQN = new QName("myNS", "myBinding"); - expect(mockDef.getBinding(bindingQN)).andReturn(wsdlBinding); - - expect(wsdlReg.getDefinition("myNS")).andReturn(mockDef); - - replay(wsdlReg); - replay(mockDef); - - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, wsdlReg); - - WebServiceBindingDefinition binding = loader.createWSBinding("myNS#wsdl.binding(myBinding)", null, null, null); - assertEquals(mockDef, binding.getWSDLDefinition()); - - assertEquals(wsdlBinding, binding.getBinding()); - - EasyMock.verify(wsdlReg); - EasyMock.verify(mockDef); - } - - public void testGetWSDLElementURIValue() throws Exception { - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, null); - assertEquals("myValue", loader.getWSDLElementURIValue("myNs#wsdl.foo(myValue)", "wsdl.foo")); - assertNull(loader.getWSDLElementURIValue("myNs#wsdl.XXX(myValue)", "wsdl.foo")); - } - - public void testBadGetWSDLElementURIValue() throws Exception { - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, null); - try { - loader.getWSDLElementURIValue("myNs#wsdl.foo(myValue", "wsdl.foo"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - public void testGetWSDLNamespace() throws Exception { - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, null); - assertEquals("myNS", loader.getWSDLNamespace("myNS#bla")); - } - - public void testNullGetWSDLNamespace() throws Exception { - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, null); - assertNull(loader.getWSDLNamespace("")); - assertNull(loader.getWSDLNamespace(null)); - } - - public void testBadGetWSDLNamespace() throws Exception { - WebServiceBindingLoader loader = new WebServiceBindingLoader(null, null); - try { - loader.getWSDLNamespace("bla"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - try { - loader.getWSDLNamespace("#bla"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - -} diff --git a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/resources/wsdl/hello_world_doc_lit.wsdl b/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/resources/wsdl/hello_world_doc_lit.wsdl deleted file mode 100755 index d0958f282e..0000000000 --- a/branches/sca-java-integration/sca/extensions/axis2/binding/src/test/resources/wsdl/hello_world_doc_lit.wsdl +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http" - xmlns="http://schemas.xmlsoap.org/wsdl/" - xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" - xmlns:tns="http://objectweb.org/hello_world_soap_http" - xmlns:x1="http://objectweb.org/hello_world_soap_http/types" - xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <wsdl:types> - <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types" - xmlns="http://www.w3.org/2001/XMLSchema" - xmlns:tns="http://objectweb.org/hello_world_soap_http/types" - elementFormDefault="qualified"> - <simpleType name="MyStringType"> - <restriction base="string"> - <maxLength value="30" /> - </restriction> - </simpleType> - - <element name="sayHi"> - <complexType/> - </element> - <element name="sayHiResponse"> - <complexType> - <sequence> - <element name="responseType" type="string"/> - </sequence> - </complexType> - </element> - <element name="greetMe"> - <complexType> - <sequence> - <element name="requestType" type="tns:MyStringType"/> - </sequence> - </complexType> - </element> - <element name="greetMeResponse"> - <complexType> - <sequence> - <element name="responseType" type="string"/> - </sequence> - </complexType> - </element> - <element name="greetMeOneWay"> - <complexType> - <sequence> - <element name="requestType" type="string"/> - </sequence> - </complexType> - </element> - <element name="pingMe"> - <complexType/> - </element> - <element name="pingMeResponse"> - <complexType/> - </element> - <element name="faultDetail"> - <complexType> - <sequence> - <element name="minor" type="short"/> - <element name="major" type="short"/> - </sequence> - </complexType> - </element> - </schema> - </wsdl:types> - <wsdl:message name="sayHiRequest"> - <wsdl:part element="x1:sayHi" name="in"/> - </wsdl:message> - <wsdl:message name="sayHiResponse"> - <wsdl:part element="x1:sayHiResponse" name="out"/> - </wsdl:message> - <wsdl:message name="greetMeRequest"> - <wsdl:part element="x1:greetMe" name="in"/> - </wsdl:message> - <wsdl:message name="greetMeResponse"> - <wsdl:part element="x1:greetMeResponse" name="out"/> - </wsdl:message> - <wsdl:message name="greetMeOneWayRequest"> - <wsdl:part element="x1:greetMeOneWay" name="in"/> - </wsdl:message> - - <wsdl:portType name="Greeter"> - <wsdl:operation name="sayHi"> - <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/> - <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/> - </wsdl:operation> - - <wsdl:operation name="greetMe"> - <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/> - <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/> - </wsdl:operation> - - <wsdl:operation name="greetMeOneWay"> - <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/> - </wsdl:operation> - - <wsdl:operation name="greetMeWithCallback"> - <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/> - <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/> - </wsdl:operation> - - </wsdl:portType> - <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter"> - <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> - - <wsdl:operation name="sayHi"> - <soap:operation soapAction="" style="document"/> - <wsdl:input name="sayHiRequest"> - <soap:body use="literal"/> - </wsdl:input> - <wsdl:output name="sayHiResponse"> - <soap:body use="literal"/> - </wsdl:output> - </wsdl:operation> - - <wsdl:operation name="greetMe"> - <soap:operation soapAction="" style="document"/> - <wsdl:input name="greetMeRequest"> - <soap:body use="literal"/> - </wsdl:input> - <wsdl:output name="greetMeResponse"> - <soap:body use="literal"/> - </wsdl:output> - </wsdl:operation> - - <wsdl:operation name="greetMeOneWay"> - <soap:operation soapAction="" style="document"/> - <wsdl:input name="greetMeOneWayRequest"> - <soap:body use="literal"/> - </wsdl:input> - </wsdl:operation> - - <wsdl:operation name="greetMeWithCallback"> - <soap:operation soapAction="" style="document"/> - <wsdl:input name="greetMeRequest"> - <soap:body use="literal"/> - </wsdl:input> - <wsdl:output name="greetMeResponse"> - <soap:body use="literal"/> - </wsdl:output> - </wsdl:operation> - - </wsdl:binding> - <wsdl:service name="SOAPService"> - <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort"> - <soap:address location="http://localhost:9000/SoapContext/SoapPort"/> - </wsdl:port> - </wsdl:service> -</wsdl:definitions> - |