You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wo...@apache.org on 2008/03/03 19:48:24 UTC
svn commit: r633234 [4/24] - in /webservices/axis2/trunk/java: ./
modules/jaxws-integration/ modules/jaxws-integration/test/
modules/jaxws-integration/test/client/ modules/jaxws-integration/test/org/
modules/jaxws-integration/test/org/apache/ modules/j...
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/AnnotationDescriptionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/AnnotationDescriptionTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/AnnotationDescriptionTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/AnnotationDescriptionTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+
+/**
+ * Directly test the Description classes built via annotations without a WSDL file.
+ * These tests focus on combinations of the following:
+ * - A generic service (no annotations)
+ * - A generated service (annotations)
+ * - An SEI
+ */
+public class AnnotationDescriptionTests extends TestCase {
+
+ /*
+ * ========================================================================
+ * ServiceDescription Tests
+ * ========================================================================
+ */
+ public void testCreateService() {
+ String namespaceURI= "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoServiceAnnotated";
+ Service service = Service.create(null, new QName(namespaceURI, localPart));
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ ServiceDescription serviceDescription = serviceDelegate.getServiceDescription();
+ String portLocalPart = "EchoServiceAnnotatedPort";
+ QName portQName = new QName(namespaceURI, portLocalPart);
+ DocLitWrappedProxy dlwp = service.getPort(portQName, DocLitWrappedProxy.class);
+
+ // Validate that the Endpoint and EndpointInterface Descriptions were created correctly
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(portQName);
+ assertNotNull("Endpoint not created ", endpointDescription);
+ EndpointInterfaceDescription endpointInterfaceDescription = endpointDescription.getEndpointInterfaceDescription();
+ assertNotNull("EndpointInterface not created", endpointInterfaceDescription);
+ // Verify we can get the same endpoint description based on the SEI class
+ EndpointDescription[] fromSEIClass = serviceDescription.getEndpointDescription(DocLitWrappedProxy.class);
+ assertEquals(1,fromSEIClass.length);
+ assertEquals(endpointDescription, fromSEIClass[0]);
+
+ // Test getOperation methods parameter validation
+ OperationDescription[] operationResultArray = endpointInterfaceDescription.getOperation((QName) null);
+ assertNull(operationResultArray);
+ operationResultArray = endpointInterfaceDescription.getOperation(new QName("",""));
+ assertNull(operationResultArray);
+ OperationDescription operationResult = endpointInterfaceDescription.getOperation((Method) null);
+ assertNull(operationResult);
+
+ // Test getOperations(): Number of methods on SEI should match number of operationDescriptions
+ Method[] seiMethods = DocLitWrappedProxy.class.getMethods();
+ operationResultArray = endpointInterfaceDescription.getOperations();
+ assertEquals("Number of SEI methods and operations did not match", seiMethods.length, operationResultArray.length);
+
+ // Test getOperation(QName)
+ // Verify @WebMethod.name is used if present. See the SEI class annotations for more information
+ // The SEI has @WebMethod annotations that override the name of "invokeAsync", so none should be found.
+ QName javaMethodQName = new QName("", "invokeAsync");
+ operationResultArray = endpointInterfaceDescription.getOperation(javaMethodQName);
+ assertNull(operationResultArray);
+ // The SEI has @WebMethod annotations that name three operations "invoke"
+ javaMethodQName = new QName("", "invoke");
+ operationResultArray = endpointInterfaceDescription.getOperation(javaMethodQName);
+ assertNotNull(operationResultArray);
+ assertEquals(3, operationResultArray.length);
+
+ // Test getOperation(Method)
+ // Verify an SEI method lookup works
+ operationResult = endpointInterfaceDescription.getOperation(seiMethods[0]);
+ assertNotNull(operationResult);
+ // Verify a non-SEI method returns a null
+ operationResult = endpointInterfaceDescription.getOperation(this.getClass().getMethods()[0]);
+ assertNull(operationResult);
+ }
+
+
+ /*
+ * TO TEST
+ * - Invalid namespace. TNS in annotation doesn't match one from getPort
+ * - Multiple service.getPort() calls with same SEI and different QName, and that serviceDesc.getEndpointDesc(Class) returns multielement array
+ * - Test service.getPort(..) with same QName; should return same descrpption
+ */
+/*
+ public void testValidServiceGetEndpoint() {
+ QName validPortQname = new QName("http://ws.apache.org/axis2/tests", "EchoPort");
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(validPortQname);
+ assertNotNull("EndpointDescription should be found", endpointDescription);
+ }
+
+ public void testInvalidLocalpartServiceGetEndpoint() {
+ QName validPortQname = new QName("http://ws.apache.org/axis2/tests", "InvalidEchoPort");
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(validPortQname);
+ assertNull("EndpointDescription should not be found", endpointDescription);
+ }
+
+ public void testInvalidNamespaceServiceGetEndpoint() {
+ QName validPortQname = new QName("http://ws.apache.org/axis2/tests/INVALID", "EchoPort");
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(validPortQname);
+ assertNull("EndpointDescription should not be found", endpointDescription);
+ }
+*/
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTests.java Mon Mar 3 10:47:38 2008
@@ -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.axis2.jaxws.description;
+
+import javax.jws.HandlerChain;
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceClient;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * Test that the annotations valid on a service requester can be
+ * processed.
+ */
+public class ClientAnnotationTests extends TestCase {
+ private String namespaceURI = "http://org.apache.axis2.jaxws.description.ClientAnnotationTests";
+ private String svcLocalPart = "svcLocalPart";
+ private String portLocalPart = "portLocalPart";
+
+ public void testSEIAnnotations() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ Service service = new ClientAnnotationTestsService(null, serviceQName);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+ ClientAnnotationTestsSEI port = service.getPort(portQName, ClientAnnotationTestsSEI.class);
+ }
+
+}
+
+@WebServiceClient
+class ClientAnnotationTestsService extends javax.xml.ws.Service {
+ protected ClientAnnotationTestsService(URL wsdlDocumentLocation, QName serviceName) {
+ super(wsdlDocumentLocation, serviceName);
+ }
+}
+
+@WebService
+@HandlerChain(file="ClientAnnotationTestsHandler.xml")
+interface ClientAnnotationTestsSEI {
+
+ @WebMethod
+ @WebResult
+ public String echo(@WebParam
+ String arg);
+
+ @Oneway
+ public void oneWay();
+
+ @ResponseWrapper
+ @RequestWrapper
+ public String echoWrap(String art);
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTestsHandler.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTestsHandler.xml?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTestsHandler.xml (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ClientAnnotationTestsHandler.xml Mon Mar 3 10:47:38 2008
@@ -0,0 +1,28 @@
+<!--
+ ~ 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.
+ -->
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-class>org.apache.axis2.jaxws.spi.handler.DummySOAPHandler</jws:handler-class>
+ </jws:handler>
+ <jws:handler>
+ <jws:handler-class>org.apache.axis2.jaxws.spi.handler.DummyLogicalHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+</jws:handler-chains>
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,142 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.ws.Service;
+
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.axis2.jaxws.TestLogger;
+
+/**
+ *
+ */
+public class DescriptionTestUtils2 {
+
+ /*
+ * ========================================================================
+ * Test utility methods
+ * ========================================================================
+ */
+
+ static public URL getWSDLURL() {
+ return getWSDLURL("WSDLTests.wsdl");
+
+ }
+
+ static public String getWSDLLocation(String wsdlFileName) {
+ // Get the URL to the WSDL file. Note that 'basedir' is setup by Maven
+ String basedir = System.getProperty("basedir");
+ String urlString = "file://localhost/" + basedir + "/test-resources/wsdl/" + wsdlFileName;
+ return urlString;
+ }
+
+ static public URL getWSDLURL(String wsdlFileName) {
+ URL wsdlURL = null;
+ String urlString = getWSDLLocation(wsdlFileName);
+ try {
+ wsdlURL = new URL(urlString);
+ } catch (Exception e) {
+ TestLogger.logger.debug(
+ "Caught exception creating WSDL URL :" + urlString + "; exception: " +
+ e.toString());
+ }
+ return wsdlURL;
+ }
+
+ static Definition createWSDLDefinition(URL wsdlURL) {
+ Definition wsdlDefinition = null;
+ try {
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ wsdlDefinition = reader.readWSDL(wsdlURL.toString());
+ }
+ catch (Exception e) {
+ TestLogger.logger
+ .debug("*** ERROR ***: Caught exception trying to create WSDL Definition: " +
+ e);
+ e.printStackTrace();
+ }
+
+ return wsdlDefinition;
+ }
+
+ static public ServiceDelegate getServiceDelegate(Service service) {
+ // Need to get to the private Service._delegate field in order to get to the ServiceDescription to test
+ ServiceDelegate returnServiceDelegate = null;
+ try {
+ try {
+ Field serviceDelgateField = service.getClass().getDeclaredFields()[0];
+ serviceDelgateField.setAccessible(true);
+ returnServiceDelegate = (ServiceDelegate) serviceDelgateField.get(service);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // This may be a generated service subclass, so get the delegate from the superclass
+ Field serviceDelegateField = service.getClass().getSuperclass().getDeclaredFields()[0];
+ serviceDelegateField.setAccessible(true);
+ returnServiceDelegate = (ServiceDelegate) serviceDelegateField.get(service);
+ }
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return returnServiceDelegate;
+ }
+
+ static public DescriptionBuilderComposite getServiceDescriptionComposite(ServiceDescription svcDesc) {
+ DescriptionBuilderComposite returnComposite = null;
+ // Need to get the composite off the implementation using the getter method, but it is all
+ // packaged protected and not part of the interface.
+ try {
+ Method getComposite = svcDesc.getClass().getDeclaredMethod("getDescriptionBuilderComposite");
+ getComposite.setAccessible(true);
+ returnComposite = (DescriptionBuilderComposite) getComposite.invoke(svcDesc, null);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return returnComposite;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DocLitWrappedProxy.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DocLitWrappedProxy.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DocLitWrappedProxy.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/DocLitWrappedProxy.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,249 @@
+
+/*
+ * 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.axis2.jaxws.description;
+
+import java.util.concurrent.Future;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebParam.Mode;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Holder;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.Response;
+import javax.xml.ws.ResponseWrapper;
+
+import org.test.proxy.doclitwrapped.FinOpResponse;
+import org.test.proxy.doclitwrapped.FinancialOperation;
+import org.test.proxy.doclitwrapped.ReturnType;
+import org.test.proxy.doclitwrapped.TwoWayHolder;
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "DocLitWrappedProxy", targetNamespace = "http://ws.apache.org/axis2/tests")
+public interface DocLitWrappedProxy {
+
+
+ /**
+ *
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @Oneway
+ @RequestWrapper(localName = "oneWayVoid", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.OneWayVoid")
+ public void oneWayVoid();
+
+ /**
+ *
+ * @param onewayStr
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @Oneway
+ @RequestWrapper(localName = "oneWay", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.sei.OneWay")
+ public void oneWay(
+ @WebParam(name = "oneway_str", targetNamespace = "")
+ String onewayStr);
+
+ /**
+ *
+ * @param twoWayHolderInt
+ * @param twoWayHolderStr
+ * @return
+ * returns javax.xml.ws.Response<org.apache.axis2.proxy.doclitwrapped.sei.TwoWayHolder>
+ */
+ @WebMethod(operationName = "twoWayHolder", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ @ResponseWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ public Response<TwoWayHolder> twoWayHolderAsync(
+ @WebParam(name = "twoWayHolder_str", targetNamespace = "")
+ String twoWayHolderStr,
+ @WebParam(name = "twoWayHolder_int", targetNamespace = "")
+ int twoWayHolderInt);
+
+ /**
+ *
+ * @param twoWayHolderInt
+ * @param asyncHandler
+ * @param twoWayHolderStr
+ * @return
+ * returns java.util.concurrent.Future<? extends java.lang.Object>
+ */
+ @WebMethod(operationName = "twoWayHolder", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ @ResponseWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ public Future<?> twoWayHolderAsync(
+ @WebParam(name = "twoWayHolder_str", targetNamespace = "")
+ String twoWayHolderStr,
+ @WebParam(name = "twoWayHolder_int", targetNamespace = "")
+ int twoWayHolderInt,
+ @WebParam(name = "asyncHandler", targetNamespace = "")
+ AsyncHandler<TwoWayHolder> asyncHandler);
+
+ /**
+ *
+ * @param twoWayHolderInt
+ * @param twoWayHolderStr
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ @ResponseWrapper(localName = "twoWayHolder", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWayHolder")
+ public void twoWayHolder(
+ @WebParam(name = "twoWayHolder_str", targetNamespace = "", mode = Mode.INOUT)
+ Holder<String> twoWayHolderStr,
+ @WebParam(name = "twoWayHolder_int", targetNamespace = "", mode = Mode.INOUT)
+ Holder<Integer> twoWayHolderInt);
+
+ /**
+ *
+ * @param twowayStr
+ * @return
+ * returns javax.xml.ws.Response<org.apache.axis2.proxy.doclitwrapped.sei.ReturnType>
+ */
+ @WebMethod(operationName = "twoWay", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "twoWay", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWay")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.sei.ReturnType")
+ public Response<ReturnType> twoWayAsync(
+ @WebParam(name = "twoway_str", targetNamespace = "")
+ String twowayStr);
+
+ /**
+ *
+ * @param twowayStr
+ * @param asyncHandler
+ * @return
+ * returns java.util.concurrent.Future<? extends java.lang.Object>
+ */
+ @WebMethod(operationName = "twoWay", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "twoWay", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWay")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.ReturnType")
+ public Future<?> twoWayAsync(
+ @WebParam(name = "twoway_str", targetNamespace = "")
+ String twowayStr,
+ @WebParam(name = "asyncHandler", targetNamespace = "")
+ AsyncHandler<ReturnType> asyncHandler);
+
+ /**
+ *
+ * @param twowayStr
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @WebResult(name = "return_str", targetNamespace = "")
+ @RequestWrapper(localName = "twoWay", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.TwoWay")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.ReturnType")
+ public String twoWay(
+ @WebParam(name = "twoway_str", targetNamespace = "")
+ String twowayStr);
+
+
+ /**
+ *
+ * @param invokeStr
+ * @return
+ * returns javax.xml.ws.Response<org.apache.axis2.jaxws.proxy.doclitwrapped.sei.ReturnType>
+ */
+ @WebMethod(operationName = "invoke", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "invoke", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.Invoke")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.ReturnType")
+ public Response<ReturnType> invokeAsync(
+ @WebParam(name = "invoke_str", targetNamespace = "")
+ String invokeStr);
+
+ /**
+ *
+ * @param invokeStr
+ * @param asyncHandler
+ * @return
+ * returns java.util.concurrent.Future<? extends java.lang.Object>
+ */
+ @WebMethod(operationName = "invoke", action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @RequestWrapper(localName = "invoke", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.Invoke")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.ReturnType")
+ public Future<?> invokeAsync(
+ @WebParam(name = "invoke_str", targetNamespace = "")
+ String invokeStr,
+ @WebParam(name = "asyncHandler", targetNamespace = "")
+ AsyncHandler<ReturnType> asyncHandler);
+
+ /**
+ *
+ * @param invokeStr
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/twoWayReturn")
+ @WebResult(name = "return_str", targetNamespace = "")
+ @RequestWrapper(localName = "invoke", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.Invoke")
+ @ResponseWrapper(localName = "ReturnType", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.ReturnType")
+ public String invoke(
+ @WebParam(name = "invoke_str", targetNamespace = "")
+ String invokeStr);
+
+ /**
+ *
+ * @param op
+ * @return
+ * returns javax.xml.ws.Response<org.apache.axis2.proxy.doclitwrapped.sei.FinOpResponse>
+ */
+ @WebMethod(operationName = "finOp", action = "http://org.apache.axis2.proxy.doclitwrapped/finOp")
+ @RequestWrapper(localName = "finOp", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOp")
+ @ResponseWrapper(localName = "finOpResponse", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOpResponse")
+ public Response<FinOpResponse> finOpAsync(
+ @WebParam(name = "op", targetNamespace = "")
+ FinancialOperation op);
+
+ /**
+ *
+ * @param op
+ * @param asyncHandler
+ * @return
+ * returns java.util.concurrent.Future<? extends java.lang.Object>
+ */
+ @WebMethod(operationName = "finOp", action = "http://org.apache.axis2.proxy.doclitwrapped/finOp")
+ @RequestWrapper(localName = "finOp", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOp")
+ @ResponseWrapper(localName = "finOpResponse", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOpResponse")
+ public Future<?> finOpAsync(
+ @WebParam(name = "op", targetNamespace = "")
+ FinancialOperation op,
+ @WebParam(name = "asyncHandler", targetNamespace = "")
+ AsyncHandler<FinOpResponse> asyncHandler);
+
+ /**
+ *
+ * @param op
+ * @return
+ * returns org.apache.axis2.proxy.doclitwrapped.sei.FinancialOperation
+ */
+ @WebMethod(action = "http://org.apache.axis2.proxy.doclitwrapped/finOp")
+ @WebResult(name = "response", targetNamespace = "")
+ @RequestWrapper(localName = "finOp", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOp")
+ @ResponseWrapper(localName = "finOpResponse", targetNamespace = "http://org.apache.axis2.proxy.doclitwrapped", className = "org.test.proxy.doclitwrapped.FinOpResponse")
+ public FinancialOperation finOp(
+ @WebParam(name = "op", targetNamespace = "")
+ FinancialOperation op);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/GetDescFromBindingProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/GetDescFromBindingProviderTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/GetDescFromBindingProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/GetDescFromBindingProviderTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,199 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.lang.reflect.Proxy;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
+import junit.framework.TestCase;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.spi.BindingProvider;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.ws.axis2.tests.EchoPort;
+
+/**
+ * Test that the EndpointDescription can be gotten from
+ * the Binding Provider impl class and that the AxisService can be
+ * gotten from the EndpointDesc. Note that the BindingProvider class is NOT
+ * the jaxws API one; it is the internal implementation BindingProvider class.
+ */
+public class GetDescFromBindingProviderTests extends TestCase {
+
+ private static final String wsdlSOAPAddress = "http://localhost:6060/axis2/services/EchoService";
+
+ public void testForProxy() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+
+ Service service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPort");
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ BindingProvider bindingProvider = (BindingProvider)Proxy.getInvocationHandler(echoPort);
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+
+ // The endpoint address should match what is in the WSDL
+ String endpointAddress = endpointDesc.getEndpointAddress();
+ assertEquals(wsdlSOAPAddress, endpointAddress);
+ }
+
+ public void testForDispatch() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+
+ Service service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPort");
+ Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+
+ BindingProvider bindingProvider = (BindingProvider) dispatch;
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+
+ // The endpoint address should match what is in the WSDL
+ String endpointAddress = endpointDesc.getEndpointAddress();
+ assertEquals(wsdlSOAPAddress, endpointAddress);
+ }
+
+ public void testForAddPort() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+
+ Service service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPortAdded");
+ service.addPort(validPortQName, null, null);
+ Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+
+ BindingProvider bindingProvider = (BindingProvider) dispatch;
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+ // The endpoint address should be null since it wasn't specified on the addPort
+ String endpointAddress = endpointDesc.getEndpointAddress();
+ assertNull(endpointAddress);
+
+ QName validPortQName2 = new QName(namespaceURI, "EchoPortAdded2");
+ final String port2EndpointAddress = "http://testAddress:6060/my/test/address";
+ service.addPort(validPortQName2, null, port2EndpointAddress);
+ dispatch = service.createDispatch(validPortQName2, String.class, null);
+ assertNotNull(dispatch);
+ bindingProvider = (BindingProvider) dispatch;
+ endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ // The endpoint address should be as set on the addPort above.
+ endpointAddress = endpointDesc.getEndpointAddress();
+ assertEquals(port2EndpointAddress, endpointAddress);
+ }
+
+ public void testForProxyNoWSDL() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ Service service = Service.create(null, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPort");
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ BindingProvider bindingProvider = (BindingProvider)Proxy.getInvocationHandler(echoPort);
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+ // The endpoint address should be null since there was no WSDL and it hasn't been set yet
+ String endpointAddress = endpointDesc.getEndpointAddress();
+ assertNull(endpointAddress);
+ }
+ public void testForDispatchNoWSDL() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ Service service = Service.create(null, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPort");
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+
+ BindingProvider bindingProvider = (BindingProvider) dispatch;
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+ }
+ public void testForAddPortNoWSDL() {
+ String namespaceURI = "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+
+ Service service = Service.create(null, new QName(namespaceURI, localPart));
+ assertNotNull(service);
+
+ QName validPortQName = new QName(namespaceURI, "EchoPortAdded");
+ service.addPort(validPortQName, null, null);
+ Dispatch<String> dispatch = service.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+
+ BindingProvider bindingProvider = (BindingProvider) dispatch;
+ ServiceDelegate serviceDelegate = bindingProvider.getServiceDelegate();
+ assertNotNull(serviceDelegate);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ assertNotNull(endpointDesc);
+ AxisService axisService = endpointDesc.getAxisService();
+ assertNotNull(axisService);
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/PortSelectionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/PortSelectionTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/PortSelectionTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/PortSelectionTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,126 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Port;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.spi.BindingProvider;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.ws.axis2.tests.EchoPort;
+
+/**
+ *
+ */
+public class PortSelectionTests extends TestCase {
+ private static String VALID_SERVICE_NAMESPACE = "http://org/test/addnumbers";
+ private static String VALID_SERVICE_LOCALPART_3 = "AddNumbersService3";
+
+ public void testServiceDescPortSelectionMethods() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+
+ ServiceDescriptionWSDL serviceDescWSDL = (ServiceDescriptionWSDL) serviceDesc;
+
+ Map allPorts = serviceDescWSDL.getWSDLPorts();
+ assertEquals(4, allPorts.size());
+
+ QName portTypeQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortType");
+ List<Port> portsUsingPortType = serviceDescWSDL.getWSDLPortsUsingPortType(portTypeQName);
+ assertEquals(3, portsUsingPortType.size());
+
+ QName otherPortTypeQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortTypeOtherPT");
+ List<Port> portsUsingOtherPortType = serviceDescWSDL.getWSDLPortsUsingPortType(otherPortTypeQName);
+ assertEquals(1, portsUsingOtherPortType.size());
+
+ List<Port> portsUsingSOAPAddress = serviceDescWSDL.getWSDLPortsUsingSOAPAddress(portsUsingPortType);
+ assertEquals(2, portsUsingSOAPAddress.size());
+ }
+
+ public void testPortSelection() {
+ // Test the Service.getPort call
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ AddNumbersPortType selectPort = service.getPort(AddNumbersPortType.class);
+ BindingProvider bindingProvider = (BindingProvider)Proxy.getInvocationHandler(selectPort);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ QName selectedPortQName = endpointDesc.getPortQName();
+ assertNotNull(selectedPortQName);
+ // We expect the first port in the WSDL which uses the PortType for the SEI AddNumbersPortType to be selected
+ // UNFORTUNATELY! WSDL4J Service.getPorts(), which returns a Map of ports under the service DOES NOT return
+ // them in the order defined in the WSDL. Therefore, we can't necessarily predict which one we'll get back.
+ // So, the following two lines may cause the test to fail.
+// QName expectedQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P2");
+// assertEquals(expectedQName, selectedPortQName);
+ // So, the best we can do is just test that ONE of the valid ports is the one that was selected.
+ boolean testSuccessful = false;
+ QName[] validPorts = new QName[3];
+ validPorts[0] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P2");
+ validPorts[1] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P3");
+ validPorts[2] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P4");
+ for (QName checkPort : validPorts) {
+ if (selectedPortQName.equals(checkPort)) {
+ testSuccessful = true;
+ break;
+ }
+ }
+ assertTrue(testSuccessful);
+ }
+
+ public void testInvalidPortSelection() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ // There should be no ports in the service that use this SEI!
+ try {
+ EchoPort selectPort = service.getPort(EchoPort.class);
+ fail("Shouldn't have found a port for the given SEI!");
+ }
+ catch (WebServiceException ex) {
+ // Expected code path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception " + ex.toString());
+ }
+
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ServiceTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ServiceTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/ServiceTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,333 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+
+public class ServiceTests extends TestCase {
+ private static String VALID_SERVICE_NAMESPACE = "http://org/test/addnumbers";
+ private static String VALID_SERVICE_LOCALPART_1 = "AddNumbersService1";
+ private static String VALID_SERVICE_LOCALPART_2 = "AddNumbersService2";
+ private static String VALID_PORT_S1P1 = "AddNumbersPortS1P1";
+ private static String VALID_PORT_S1P2 = "AddNumbersPortS1P2";
+ private static String VALID_PORT_S1P3 = "AddNumbersPortS1P3";
+ private static String VALID_PORT_S2P1 = "AddNumbersPortS2P1";
+ private static String VALID_PORT_S2P2 = "AddNumbersPortS2P2";
+ private static String VALID_PORT_S2P3 = "AddNumbersPortS2P3";
+ private static String VALID_PORT_S2P4 = "AddNumbersPortS2P4";
+
+ public void testInvalidServiceNamespace() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+ QName invalidServiceQN = new QName("invalidServiceNamespace", VALID_SERVICE_LOCALPART_1);
+ try {
+ Service invalidService = Service.create(wsdlURL, invalidServiceQN);
+ fail("Created service with invalid namespace");
+ }
+ catch (WebServiceException ex) {
+ // Expected code path
+ }
+ catch (Exception ex) {
+ fail("Caught unexpected exception " + ex.toString());
+ }
+ }
+ public void testInvalidServiceLocalPart() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+ QName invalidServiceQN = new QName(VALID_SERVICE_NAMESPACE, "invalidServiceName");
+ try {
+ Service invalidService = Service.create(wsdlURL, invalidServiceQN);
+ fail("Created service with invalid namespace");
+ }
+ catch (WebServiceException ex) {
+ // Expected code path
+ }
+ catch (Exception ex) {
+ fail("Caught unexpected exception " + ex.toString());
+ }
+ }
+
+ public void testValidSameService() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName validService1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service validService1 = Service.create(wsdlURL, validService1QN);
+ assertNotNull(validService1);
+
+ QName validService2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service validService2 = Service.create(wsdlURL, validService2QN);
+ assertNotNull(validService2);
+
+ }
+
+ public void testValidMultiServices() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName validService1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service validService1 = Service.create(wsdlURL, validService1QN);
+ assertNotNull(validService1);
+
+ QName validService2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+ Service validService2 = Service.create(wsdlURL, validService2QN);
+ assertNotNull(validService2);
+ assertNotSame(validService1, validService2);
+
+ }
+
+ public void testGetServiceDeclaredPorts() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service service1 = Service.create(wsdlURL, service1QN);
+ assertNotNull(service1);
+ ServiceDelegate service1Delegate = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNotNull (service1Delegate);
+ ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+ assertNotNull(service1Desc);
+ List<QName> service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertNotNull(service1PortsList);
+ assertEquals(3, service1PortsList.size());
+ Iterator<QName> service1PortIterator = service1.getPorts();
+ assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+
+ QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+ Service service2 = Service.create(wsdlURL, service2QN);
+ assertNotNull(service2);
+ ServiceDelegate service2Delegate = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNotNull (service2Delegate);
+ ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+ assertNotNull(service2Desc);
+ List<QName> service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertNotNull(service2PortsList);
+ assertEquals(4, service2PortsList.size());
+ Iterator<QName> service2PortIterator = service2.getPorts();
+ assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+ }
+
+ public void testGetServiceAddedPorts() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service service1 = Service.create(wsdlURL, service1QN);
+ assertNotNull(service1);
+ ServiceDelegate service1Delegate = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNotNull (service1Delegate);
+ ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+ assertNotNull(service1Desc);
+ List<QName> service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertNotNull(service1PortsList);
+ assertEquals(3, service1PortsList.size());
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(5, service1PortsList.size());
+ Iterator<QName> service1PortIterator = service1.getPorts();
+ assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+
+ QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+ Service service2 = Service.create(wsdlURL, service2QN);
+ assertNotNull(service2);
+ ServiceDelegate service2Delegate = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNotNull (service2Delegate);
+ ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+ assertNotNull(service2Desc);
+ List<QName> service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertNotNull(service2PortsList);
+ assertEquals(4, service2PortsList.size());
+ service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P1"), null, null);
+ service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P2"), null, null);
+ service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertEquals(6, service2PortsList.size());
+ Iterator<QName> service2PortIterator = service2.getPorts();
+ assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+ }
+
+ public void testGetServiceDeclaredPortsAfterGetPort() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service service1 = Service.create(wsdlURL, service1QN);
+ assertNotNull(service1);
+ ServiceDelegate service1Delegate = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNotNull (service1Delegate);
+ ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+ assertNotNull(service1Desc);
+ List<QName> service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertNotNull(service1PortsList);
+ assertEquals(3, service1PortsList.size());
+ AddNumbersPortType addNumbersPortS1P1 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1), AddNumbersPortType.class);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(3, service1PortsList.size());
+ AddNumbersPortType addNumbersPortS1P3 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P3), AddNumbersPortType.class);
+ assertEquals(3, service1PortsList.size());
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(5, service1PortsList.size());
+ Iterator<QName> service1PortIterator = service1.getPorts();
+ assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+
+ QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+ Service service2 = Service.create(wsdlURL, service2QN);
+ assertNotNull(service2);
+ ServiceDelegate service2Delegate = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNotNull (service2Delegate);
+ ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+ assertNotNull(service2Desc);
+ List<QName> service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertNotNull(service2PortsList);
+ assertEquals(4, service2PortsList.size());
+ AddNumbersPortType addNumbersPortS2P1 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P1), AddNumbersPortType.class);
+ service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertEquals(4, service2PortsList.size());
+ AddNumbersPortType addNumbersPortS2P3 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P3), AddNumbersPortType.class);
+ assertEquals(4, service2PortsList.size());
+ AddNumbersPortType addNumbersPortS2P4 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P4), AddNumbersPortType.class);
+ assertEquals(4, service2PortsList.size());
+ service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P1"), null, null);
+ service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P2"), null, null);
+ service2PortsList = service2Desc.getPorts(service2Delegate);
+ assertEquals(6, service2PortsList.size());
+ Iterator<QName> service2PortIterator = service2.getPorts();
+ assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+ }
+
+ public void testDynamicService() {
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, "DynamicService1");
+ Service service1 = Service.create(null, service1QN);
+ assertNotNull(service1);
+ ServiceDelegate service1Delegate = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNotNull (service1Delegate);
+ ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+ assertNotNull(service1Desc);
+ List<QName> service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertNotNull(service1PortsList);
+ assertTrue(service1PortsList.isEmpty());
+ assertEquals(0, service1PortsList.size());
+ AddNumbersPortType addNumbersPortS1P1 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, "dynamicPortS1P1"), AddNumbersPortType.class);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(1, service1PortsList.size());
+ AddNumbersPortType addNumbersPortS1P3 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, "dynamicPortS1P2"), AddNumbersPortType.class);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(2, service1PortsList.size());
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+ service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+ service1PortsList = service1Desc.getPorts(service1Delegate);
+ assertEquals(4, service1PortsList.size());
+ Iterator<QName> service1PortIterator = service1.getPorts();
+ assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+ }
+
+ public void testCreateDispatchWSDL() {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service service1 = Service.create(wsdlURL, service1QN);
+ assertNotNull(service1);
+ // Create Dispatch should work on a WSDL declared port prior to a getPort
+ // and again after the call to getPort
+ QName validPortQName = new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1);
+ Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+ AddNumbersPortType addNumbersPortS1P1 = service1.getPort(validPortQName, AddNumbersPortType.class);
+ assertNotNull(addNumbersPortS1P1);
+
+ // Create Dispatch should NOT work on a dynamic port that has not been added yet
+ // but should work after it has been added
+ QName addedPort = new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1");
+ try {
+ Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+ fail("Create Dispatch on non-existant port should have thrown an exception");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception thrown " + ex.toString());
+ }
+ service1.addPort(addedPort, null, null);
+ Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+ assertNotNull(dispatch2);
+
+ }
+
+ public void testCreateDispatchNoWSDL() {
+
+ // Note that this test is intentionally using the same names as the WSDL test, even though no WSDL is
+ // provided. This is to verify that using the same names in the abscense of WSDL doesn't cause any
+ // issues.
+
+ QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+ Service service1 = Service.create(service1QN);
+ assertNotNull(service1);
+ // Create Dispatch should NOT work on a dynamic port prior to a getPort
+ // but should work after the getPort causes the port to be added.
+ QName validPortQName = new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1);
+ try {
+ Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+ fail("Create Dispatch on non-existant port should have thrown and exception");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception thrown " + ex.toString());
+ }
+ AddNumbersPortType addNumbersPortS1P1 = service1.getPort(validPortQName, AddNumbersPortType.class);
+ Dispatch<String> dispatch = service1.createDispatch(validPortQName, String.class, null);
+ assertNotNull(dispatch);
+
+ // Create Dispatch should NOT work on a dynamic port that has not been added yet
+ // but should work after it has been added
+ QName addedPort = new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1");
+ try {
+ Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+ fail("Create Dispatch on non-existant port should have thrown an exception");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception thrown " + ex.toString());
+ }
+ service1.addPort(addedPort, null, null);
+ Dispatch<String> dispatch2 = service1.createDispatch(addedPort, String.class, null);
+ assertNotNull(dispatch2);
+ }
+
+ private void assertQNameIteratorSameAsList(Iterator<QName> iterator, List<QName> list) {
+ int iteratorSize = 0;
+ for (QName iteratorElement = null; iterator.hasNext(); ) {
+ iteratorElement = iterator.next();
+ iteratorSize++;
+ assertTrue(list.contains(iteratorElement));
+ }
+ assertEquals(list.size(), iteratorSize);
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,328 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.net.URL;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebParam.Mode;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Holder;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.ws.axis2.tests.EchoPort;
+
+/**
+ * Directly test the Description classes built with a WSDL file.
+ */
+public class WSDLDescriptionTests extends TestCase {
+
+ private Service service;
+ private ServiceDelegate serviceDelegate;
+ private ServiceDescription serviceDescription;
+
+ private static final String VALID_PORT = "EchoPort";
+ private static final String VALID_NAMESPACE = "http://ws.apache.org/axis2/tests";
+ private QName validPortQName = new QName(VALID_NAMESPACE, VALID_PORT);
+
+
+ protected void setUp() {
+ // Create a new service for each test to test various valid and invalid
+ // flows
+ String namespaceURI = VALID_NAMESPACE;
+ String localPart = "EchoService";
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+ service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ serviceDescription = serviceDelegate.getServiceDescription();
+ }
+
+ /*
+ * ========================================================================
+ * ServiceDescription Tests
+ * ========================================================================
+ */
+ public void testInvalidLocalpartServiceGetEndpoint() {
+ QName invalidPortQname = new QName(VALID_NAMESPACE, "InvalidEchoPort");
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(invalidPortQname);
+ assertNull("EndpointDescription should not be found", endpointDescription);
+ }
+
+ public void testInvalidNamespaceServiceGetEndpoint() {
+ QName invalidPortQname = new QName("http://ws.apache.org/axis2/tests/INVALID", VALID_PORT);
+ EndpointDescription endpointDescription = serviceDescription.getEndpointDescription(invalidPortQname);
+ assertNull("EndpointDescription should not be found", endpointDescription);
+ }
+
+ // ========================================================================
+ // EndpointDescription Tests
+ // ========================================================================
+
+ public void testValidGetPortWithClass() {
+ try {
+ EchoPort echoPort = service.getPort(EchoPort.class);
+ }
+ catch (Exception e) {
+ fail("Caught unexpected exception");
+ }
+ }
+
+ public void testValidGetPortWithClassAndQName() {
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ EndpointDescription endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class)[0];
+ assertNotNull(endpointDescViaSEI);
+ assertEquals(endpointDesc, endpointDescViaSEI);
+
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ Class sei = endpointInterfaceDesc.getSEIClass();
+ assertEquals(EchoPort.class, sei);
+ }
+
+ public void testValidMultipleGetPort() {
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ EchoPort echoPort2 = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort2);
+ }
+
+ public void testInvalidMultipleGetPort() {
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ try {
+ EchoPort2 echoPort2 = service.getPort(validPortQName, EchoPort2.class);
+ fail("Should have caught exception");
+ }
+ catch (WebServiceException e) {
+ // Expected flow
+ }
+ catch (Exception e) {
+ fail("Caught unexpected exception" + e);
+ }
+
+ }
+
+ public void testValidAddPort() {
+ QName dispatchPortQN = new QName(VALID_NAMESPACE, "dispatchPort");
+ service.addPort(dispatchPortQN, null, null);
+
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(dispatchPortQN, serviceDelegate);
+ assertNotNull(endpointDesc);
+
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNull(endpointInterfaceDesc);
+ }
+
+ public void testInvalidAddPortExists() {
+ try {
+ service.addPort(validPortQName, null, null);
+ fail("Shouldn't be able to add a port that exists in the WSDL");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ }
+
+ public void testInvalidAddPort() {
+ // Null portQname
+ try {
+ service.addPort(null, null, null);
+ fail("Shouldn't be able to add a port with a null QName");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ catch (Exception e) {
+ fail("Unexpected exception caught " + e);
+ }
+
+ // Empty Port QName
+ try {
+ service.addPort(new QName("", ""), null, null);
+ fail("Shouldn't be able to add an empty port QName");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ catch (Exception e) {
+ fail("Unexpected exception caught " + e);
+ }
+
+ // Empty binding ID
+ try {
+ service.addPort(new QName(VALID_NAMESPACE, "dispatchPort2"), "", null);
+ fail("Shouldn't be able to add a port with an empty binding type");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ catch (Exception e) {
+ fail("Unexpected exception caught " + e);
+ }
+
+ // Invalid binding ID
+ try {
+ service.addPort(new QName(VALID_NAMESPACE, "dispatchPort3"), "InvalidBindingType", null);
+ fail("Shouldn't be able to add a port with an invalid binding type");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ catch (Exception e) {
+ fail("Unexpected exception caught " + e);
+ }
+
+ }
+
+ public void testValidAddAndGetPort() {
+ QName dispatchPortQN = new QName(VALID_NAMESPACE, "dispatchPort");
+ service.addPort(dispatchPortQN, null, null);
+
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ EndpointDescription endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class)[0];
+ assertNotNull(endpointDescViaSEI);
+ assertEquals(endpointDesc, endpointDescViaSEI);
+
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ Class sei = endpointInterfaceDesc.getSEIClass();
+ assertEquals(EchoPort.class, sei);
+
+ EndpointDescription endpointDescDispatch = serviceDescription.getEndpointDescription(dispatchPortQN, serviceDelegate);
+ assertNotNull(endpointDescDispatch);
+
+ EndpointInterfaceDescription endpointInterfaceDescDispatch = endpointDescDispatch.getEndpointInterfaceDescription();
+ assertNull(endpointInterfaceDescDispatch);
+ }
+
+ public void testValidCreateDispatch() {
+ Dispatch<Source> dispatch = service.createDispatch(validPortQName, Source.class, Service.Mode.PAYLOAD);
+ assertNotNull(dispatch);
+
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ // Since ther is no SEI, can not get the endpointDescription based on the sei class
+ EndpointDescription[] endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class);
+ assertNull(endpointDescViaSEI);
+
+ // There will be an EndpointInterfaceDescription because the service was created with
+ // WSDL, however there will be no SEI created because a getPort has not been done
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ assertNull(endpointInterfaceDesc.getSEIClass());
+ }
+
+ public void testValidCreateAndGet() {
+ Dispatch<Source> dispatch = service.createDispatch(validPortQName, Source.class, Service.Mode.PAYLOAD);
+ assertNotNull(dispatch);
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ // Since ther is no SEI, can not get the endpointDescription based on the sei class
+ EndpointDescription[] endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class);
+ assertNull(endpointDescViaSEI);
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ assertNull(endpointInterfaceDesc.getSEIClass());
+
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+ // Since a getPort has been done, should now be able to get things based on the SEI
+ endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ // Since ther is no SEI, can not get the endpointDescription based on the sei class
+ endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class);
+ assertNotNull(endpointDescViaSEI);
+ assertEquals(endpointDesc, endpointDescViaSEI[0]);
+ endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ assertEquals(EchoPort.class, endpointInterfaceDesc.getSEIClass());
+ }
+
+ public void testValidGetAndCreate() {
+ EchoPort echoPort = service.getPort(validPortQName, EchoPort.class);
+ assertNotNull(echoPort);
+ Dispatch<Source> dispatch = service.createDispatch(validPortQName, Source.class, Service.Mode.PAYLOAD);
+ assertNotNull(dispatch);
+
+ // Since a getPort has been done, should now be able to get things based on the SEI
+ EndpointDescription endpointDesc = serviceDescription.getEndpointDescription(validPortQName);
+ assertNotNull(endpointDesc);
+ // Since ther is no SEI, can not get the endpointDescription based on the sei class
+ EndpointDescription[] endpointDescViaSEI = serviceDescription.getEndpointDescription(EchoPort.class);
+ assertNotNull(endpointDescViaSEI);
+ assertEquals(endpointDesc, endpointDescViaSEI[0]);
+ EndpointInterfaceDescription endpointInterfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(endpointInterfaceDesc);
+ assertEquals(EchoPort.class, endpointInterfaceDesc.getSEIClass());
+ }
+ // TODO: Need to add a similar test with no WSDL present; note that it currently would not pass
+ public void testInvalidAddAndGetPort() {
+ // Should not be able to do a getPort on one that was added with addPort
+ QName dispatchPortQN = new QName(VALID_NAMESPACE, "dispatchPort");
+ service.addPort(dispatchPortQN, null, null);
+ try {
+ EchoPort echoPort = service.getPort(dispatchPortQN, EchoPort.class);
+ fail("Should have thrown a WebServiceException");
+ }
+ catch (WebServiceException e) {
+ // Expected path
+ }
+ }
+}
+
+// EchoPort2 is identical to EchoPort, but it should still cause an exception
+// if it is used on a subsequent getPort after getPort(EchoPort.class) is done.
+@WebService(name = "EchoPort", targetNamespace = "http://ws.apache.org/axis2/tests", wsdlLocation = "\\work\\apps\\eclipse\\workspace\\axis2-live\\modules\\jaxws\\test-resources\\wsdl\\WSDLTests.wsdl")
+interface EchoPort2 {
+
+
+ /**
+ *
+ * @param text
+ */
+ @WebMethod(operationName = "Echo", action = "http://ws.apache.org/axis2/tests/echo")
+ @RequestWrapper(localName = "Echo", targetNamespace = "http://ws.apache.org/axis2/tests", className = "org.apache.ws.axis2.tests.Echo")
+ @ResponseWrapper(localName = "EchoResponse", targetNamespace = "http://ws.apache.org/axis2/tests", className = "org.apache.ws.axis2.tests.EchoResponse")
+ public void echo(
+ @WebParam(name = "text", targetNamespace = "", mode = Mode.INOUT)
+ Holder<String> text);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/description/WSDLTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.axis2.jaxws.description;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+
+/**
+ * Tests building a ServiceDescription using WSDL and the JAXWS Service API.
+ * Note that a ServiceDescription is built when a javax.xml.ws.Service is created. Since that is the actual API
+ * that should be used, this test will create Service objects and then use introspection
+ * to check the underlying ServiceDelegate which contains the ServiceDescription.
+ */
+public class WSDLTests extends TestCase {
+
+ public void testValidWSDLService() {
+ Service service = null;
+ ServiceDelegate serviceDelegate = null;
+
+ String namespaceURI= "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService";
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+ service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ assertNotNull("Service not created", service);
+
+ serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull("ServiceDelegate not created", serviceDelegate);
+
+ ServiceDescription serviceDescription = serviceDelegate.getServiceDescription();
+ assertNotNull("ServiceDescription not created", serviceDescription);
+
+// AxisService axisService = serviceDescription.getAxisService();
+// assertNotNull("AxisService not created", axisService);
+ }
+
+ public void testInvalidServiceLocalName() {
+ Service service = null;
+
+ String namespaceURI= "http://ws.apache.org/axis2/tests";
+ String localPart = "BADEchoService";
+ try {
+ URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
+ assertNotNull(wsdlURL);
+ service = Service.create(wsdlURL, new QName(namespaceURI, localPart));
+ fail("Exception should have been thrown for invalid Service name");
+ }
+ catch (WebServiceException e) {
+ // This is the expected flow; it is really more a test of ServiceDelegate that ServiceDescription
+ }
+ }
+
+ public void testNullWSDLLocation() {
+ Service service = null;
+
+ String namespaceURI= "http://ws.apache.org/axis2/tests";
+ String localPart = "EchoService_nullWSDL";
+ service = Service.create(new QName(namespaceURI, localPart));
+ assertNotNull("Service not created", service);
+
+ }
+
+ public void testNullServiceName() {
+ Service service = null;
+
+ try {
+ service = Service.create(null);
+ fail("Exception should have been thrown for null Service name");
+ }
+ catch (WebServiceException e) {
+ // This is the expected flow; it is really more a test of ServiceDelegate that ServiceDescription
+ // but we are verifying expected behavior.
+ }
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org