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 [15/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/...
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionService.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionService.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,74 @@
+
+/*
+ * 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.resourceinjection.sei;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+@WebServiceClient(name = "ResourceInjectionService", targetNamespace = "http://resourceinjection.sample.test.org", wsdlLocation = "resourceinjection.wsdl")
+public class ResourceInjectionService
+ extends Service
+{
+
+ private final static URL RESOURCEINJECTIONSERVICE_WSDL_LOCATION;
+
+ private static String wsdlLocation="/test/org/apache/axis2/jaxws/resourceinjection/META-INF/resourceinjection.wsdl";
+ static {
+ URL url = null;
+ try {
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir + wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ RESOURCEINJECTIONSERVICE_WSDL_LOCATION = url;
+ }
+
+ public ResourceInjectionService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public ResourceInjectionService() {
+ super(RESOURCEINJECTIONSERVICE_WSDL_LOCATION, new QName("http://resourceinjection.sample.test.org", "ResourceInjectionService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns ResourceInjectionPortType
+ */
+ @WebEndpoint(name = "ResourceInjectionPort")
+ public ResourceInjectionPortType getResourceInjectionPort() {
+ return (ResourceInjectionPortType)super.getPort(new QName("http://resourceinjection.sample.test.org", "ResourceInjectionPort"), ResourceInjectionPortType.class);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/PortTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/PortTypeImpl.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/PortTypeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/PortTypeImpl.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.rpclit.enumtype;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+import org.apache.axis2.jaxws.rpclit.enumtype.sei.PortType;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.rpclit.schema.ElementString;
+
+@WebService(serviceName="RPCLitEnumService",
+ endpointInterface="org.apache.axis2.jaxws.rpclit.enumtype.sei.PortType")
+public class PortTypeImpl implements PortType {
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.rpclit.enumtype.sei.PortType#echoString(javax.xml.ws.Holder)
+ */
+ public void echoString(Holder<ElementString> pString) {
+ ElementString es = pString.value;
+ if(es == es.A){
+ TestLogger.logger.debug("Enum A");
+ }
+ TestLogger.logger.debug("resetting Enum to B");
+ es = es.B;
+ pString.value = es;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/PortType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/PortType.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/PortType.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/PortType.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.rpclit.enumtype.sei;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebParam.Mode;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.ws.Holder;
+import org.test.rpclit.schema.ElementString;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "PortType", targetNamespace = "http://rpclit.test.org")
+@SOAPBinding(style = Style.RPC)
+public interface PortType {
+
+
+ /**
+ *
+ * @param pString
+ */
+ @WebMethod
+ public void echoString(
+ @WebParam(name = "pString", mode = Mode.INOUT, partName = "pString")
+ Holder<ElementString> pString);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/Service.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/Service.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/Service.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/sei/Service.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.rpclit.enumtype.sei;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebServiceClient(name = "RPCLitEnumService", targetNamespace = "http://rpclit.test.org", wsdlLocation = "soapenc.wsdl")
+public class Service
+ extends javax.xml.ws.Service
+{
+
+ private final static URL SERVICE_WSDL_LOCATION;
+
+ private static String wsdlLocation="/test/org/apache/axis2/jaxws/rpclit/enumtype/META-INF/rpclitenum.wsdl";
+ static {
+ URL url = null;
+ try {
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir + wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ SERVICE_WSDL_LOCATION = url;
+ }
+
+ public Service(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public Service() {
+ super(SERVICE_WSDL_LOCATION, new QName("http://rpclit.test.org", "RPCLitEnumService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns PortType
+ */
+ @WebEndpoint(name = "Port")
+ public PortType getPort() {
+ return (PortType)super.getPort(new QName("http://rpclit.test.org", "Port"), PortType.class);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.rpclit.enumtype.tests;
+
+
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+
+import org.apache.axis2.jaxws.rpclit.enumtype.sei.PortType;
+import org.apache.axis2.jaxws.rpclit.enumtype.sei.Service;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.rpclit.schema.ElementString;
+
+import junit.framework.TestCase;
+
+
+public class RPCLitEnumTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/RPCLitEnumService.PortTypeImplPort";
+
+ public void testEnumSimpleType(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ try{
+ Service service = new Service();
+ PortType portType = service.getPort();
+
+ BindingProvider p = (BindingProvider) portType;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ Holder<ElementString> pString = new Holder<ElementString>(ElementString.A);
+ portType.echoString(pString);
+ ElementString es = pString.value;
+ TestLogger.logger.debug("Response =" + es);
+ System.out.print("---------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/EchoImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/EchoImpl.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/EchoImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/EchoImpl.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.rpclit.stringarray;
+
+import javax.jws.WebService;
+
+import org.test.rpclit.stringarray.StringArray;
+
+@WebService(serviceName="RPCLitStringArrayService",
+ endpointInterface="org.apache.axis2.jaxws.rpclit.stringarray.sei.Echo")
+public class EchoImpl {
+
+ public String echoString(String arg0) {
+ return arg0;
+ }
+
+ public StringArray echoStringArray(StringArray arg0){
+ if(arg0 == null){
+ System.out.println("received null parameter");
+ }else{
+ System.out.println("received input parameter stringArray ="+arg0.toString());
+ }
+
+ return arg0;
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/Echo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/Echo.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/Echo.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/Echo.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,66 @@
+
+/*
+ * 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.rpclit.stringarray.sei;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import org.test.rpclit.stringarray.StringArray;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "Echo", targetNamespace = "http://sei.stringarray.rpclit.jaxws.axis2.apache.org")
+@SOAPBinding(style = Style.RPC)
+public interface Echo {
+
+
+ /**
+ *
+ * @param arg0
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(partName = "return")
+ public String echoString(
+ @WebParam(name = "arg0", partName = "arg0")
+ String arg0);
+
+ /**
+ *
+ * @param arg0
+ * @return
+ * returns org.test.rpclit.stringarray.StringArray
+ */
+ @WebMethod
+ @WebResult(partName = "return")
+ public StringArray echoStringArray(
+ @WebParam(name = "arg0", partName = "arg0")
+ StringArray arg0);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/RPCLitStringArrayService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/RPCLitStringArrayService.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/RPCLitStringArrayService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/sei/RPCLitStringArrayService.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,80 @@
+
+/*
+ * 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.rpclit.stringarray.sei;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebServiceClient(name = "RPCLitStringArrayService", targetNamespace = "http://sei.stringarray.rpclit.jaxws.axis2.apache.org", wsdlLocation = "echoservice.wsdl")
+public class RPCLitStringArrayService
+ extends Service
+{
+
+ private final static URL RPCLITSTRINGARRAYSERVICE_WSDL_LOCATION;
+ private static String wsdlLocation =
+ "/test/org/apache/axis2/jaxws/rpclit/stringarray/META-INF/rpclitstringarray.wsdl";
+ static {
+ URL url = null;
+ try {
+ try {
+ String baseDir = new File(System.getProperty("basedir", ".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir + wsdlLocation).getAbsolutePath();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ RPCLITSTRINGARRAYSERVICE_WSDL_LOCATION = url;
+ }
+
+ public RPCLitStringArrayService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public RPCLitStringArrayService() {
+ super(RPCLITSTRINGARRAYSERVICE_WSDL_LOCATION, new QName("http://sei.stringarray.rpclit.jaxws.axis2.apache.org", "RPCLitStringArrayService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns Echo
+ */
+ @WebEndpoint(name = "EchoPort")
+ public Echo getEchoPort() {
+ return (Echo)super.getPort(new QName("http://sei.stringarray.rpclit.jaxws.axis2.apache.org", "EchoPort"), Echo.class);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/tests/RPCLitStringArrayTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/tests/RPCLitStringArrayTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/tests/RPCLitStringArrayTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/stringarray/tests/RPCLitStringArrayTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.rpclit.stringarray.tests;
+
+import java.util.Arrays;
+
+import javax.xml.ws.BindingProvider;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.jaxws.rpclit.stringarray.sei.Echo;
+import org.apache.axis2.jaxws.rpclit.stringarray.sei.RPCLitStringArrayService;
+import org.test.rpclit.stringarray.StringArray;
+
+
+public class RPCLitStringArrayTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/RPCLitStringArrayService.EchoImplPort";
+
+ public void testStringArrayType() {
+ System.out.println("------------------------------");
+ System.out.println("Test : " + getName());
+ try {
+
+ RPCLitStringArrayService service = new RPCLitStringArrayService();
+ Echo portType = service.getEchoPort();
+ BindingProvider p = (BindingProvider) portType;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ String[] strArray= {"str1", "str2", "str3"};
+ StringArray array = new StringArray();
+ array.getItem().addAll(Arrays.asList(strArray));
+ portType.echoStringArray(array);
+
+ System.out.print("---------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,606 @@
+/*
+ * 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.sample;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Response;
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import junit.framework.TestCase;
+
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler2;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler3;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler4;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientProtocolHandler;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerPortType;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerService;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.addnumbershandler.AddNumbersHandlerResponse;
+
+/**
+ * @author rott
+ *
+ */
+public class AddNumbersHandlerTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/AddNumbersHandlerService.AddNumbersHandlerPortTypeImplPort";
+ File requestFile = null;
+
+ public void setUp() throws Exception {
+ String resourceDir = System.getProperty("basedir",".")+
+ File.separator+"test-resources"+File.separator+"xml";
+ requestFile = new File(resourceDir+File.separator+"addnumberstest.xml");
+
+ }
+ /**
+ * Client app sends 10, 10 as params to sum. No client-side handlers are configured
+ * for this scenario. The server-side AddNumbersLogicalHandler is instantiated with a
+ * variable "deduction" with value 1. Upon class initialization using PostConstruct
+ * annotation, that internal variable is changed to value 2. The inbound AddNumbersLogicalHandler
+ * subtracts 1 from the first param, then outbound it subtracts 2 from the result sum.
+ *
+ * This test accomplishes three things (which also carry over to other tests since they all use
+ * the same endpoint and server-side handlers:
+ * 1) PostConstruct annotation honored in the handler framework for handler instantiation
+ * 2) AddNumbersLogicalHandler also sets two message context properties, one with APPLICATION
+ * scope, which the endpoint checks.
+ * 3) Handlers are sharing properties, both APPLICATION scoped and HANDLER scoped
+ * 3) General handler framework functionality; make sure handlers are instantiated and called
+ */
+ public void testAddNumbersHandler() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ int total = proxy.addNumbersHandler(10, 10);
+
+ assertEquals("With handler manipulation, total should be 3 less than a proper sumation.", 17, total);
+ TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+ TestLogger.logger.debug("----------------------------------");
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testAddNumbersHandlerDispatch() {
+ try {
+ QName serviceName =
+ new QName("http://org/test/addnumbershandler", "AddNumbersHandlerService");
+ QName portName =
+ new QName("http://org/test/addnumbershandler", "AddNumbersHandlerPort");
+
+ Service myService = Service.create(serviceName);
+
+ myService.addPort(portName, null, axisEndpoint);
+ Dispatch<Source> myDispatch = myService.createDispatch(portName, Source.class,
+ Service.Mode.MESSAGE);
+
+ // set handler chain for binding provider
+ Binding binding = ((BindingProvider) myDispatch).getBinding();
+
+ // create a new list or use the existing one
+ List<Handler> handlers = binding.getHandlerChain();
+
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ binding.setHandlerChain(handlers);
+
+ //Invoke the Dispatch
+ TestLogger.logger.debug(">> Invoking Async Dispatch");
+ Source response = myDispatch.invoke(createRequestSource());
+ String resString = getString(response);
+ if (!resString.contains("<return>16</return>")) {
+ fail("Response string should contain <return>16</return>, but does not. The resString was: \"" + resString + "\"");
+ }
+
+ TestLogger.logger.debug("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testAddNumbersHandlerDispatchMyResolver() {
+ try {
+ QName serviceName =
+ new QName("http://org/test/addnumbershandler", "AddNumbersHandlerService");
+ QName portName =
+ new QName("http://org/test/addnumbershandler", "AddNumbersHandlerPort");
+
+ Service myService = Service.create(serviceName);
+
+ myService.setHandlerResolver(new MyHandlerResolver());
+
+ myService.addPort(portName, null, axisEndpoint);
+ Dispatch<Source> myDispatch = myService.createDispatch(portName, Source.class,
+ Service.Mode.MESSAGE);
+
+ //Invoke the Dispatch
+ TestLogger.logger.debug(">> Invoking Async Dispatch");
+ Source response = myDispatch.invoke(createRequestSource());
+ String resString = getString(response);
+ if (!resString.contains("<return>16</return>")) {
+ fail("Response string should contain <return>16</return>, but does not. The resString was: \"" + resString + "\"");
+ }
+
+ TestLogger.logger.debug("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /*
+ * JAXWS 9.2.1.1 conformance test
+ */
+ public void testAddNumbersHandlerResolver() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ service.setHandlerResolver(new MyHandlerResolver());
+
+ BindingProvider p = (BindingProvider) proxy;
+
+ /*
+ * despite setting MyHandlerResolver on the service, we should get an empty
+ * list from the getBinding().getHandlerChain() call below. JAXWS 9.2.1.1 conformance
+ */
+ List<Handler> list = p.getBinding().getHandlerChain();
+
+ assertTrue("List should be empty. We've not conformed to JAXWS 9.2.1.1.", list.isEmpty());
+
+ TestLogger.logger.debug("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ // TODO: disabled until handler support is more complete
+ public void testAddNumbersHandlerWithFault() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+ // value 99 triggers the handler to throw an exception, but does
+ // NOT trigger the AddNumbersHandler.handlefault method.
+ // The spec does not call the handlefault method of a handler that
+ // causes a flow reversal
+ int total = proxy.addNumbersHandler(99,10);
+
+ fail("We should have got an exception due to the handler.");
+ } catch(Exception e) {
+ e.printStackTrace();
+ assertTrue("Exception should be SOAPFaultException", e instanceof SOAPFaultException);
+ assertEquals(((SOAPFaultException)e).getMessage(), "AddNumbersLogicalHandler2 was here");
+ }
+ TestLogger.logger.debug("----------------------------------");
+ }
+
+
+ /**
+ * testAddNumbersClientHandler performs the same tests as testAddNumbersHandler, except
+ * that two client-side handlers are also inserted into the flow. The inbound AddNumbersClientLogicalHandler
+ * checks that the properties set here in this method (the client app) and the properties set in the
+ * outbound AddNumbersClientProtocolHandler are accessible. These properties are also checked here in
+ * the client app. AddNumbersClientLogicalHandler also subtracts 1 from the sum on the inbound flow.
+ */
+ public void testAddNumbersClientHandler() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+ p.getRequestContext().put("myClientKey", "myClientVal");
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+ int total = proxy.addNumbersHandler(10,10);
+
+ // see if I can get an APPLICATION scoped property set during outbound flow. I should be able to do this according to 4.2.1
+
+ // TODO: assert is now commented out. This property is set by a client outbound handler, and I don't think it
+ // should be available on the request or response contexts.
+ //assertNotNull("Should be able to retrieve APPLICATION scoped property, but could not.", ((String)p.getRequestContext().get("AddNumbersClientProtocolHandlerOutboundAppScopedProperty")));
+
+ // should NOT be able to get this HANDLER scoped property though
+ assertNull("Should not be able to retrieve HANDLER scoped property, but was able.", (String)p.getResponseContext().get("AddNumbersClientProtocolHandlerOutboundHandlerScopedProperty"));
+ // should be able to get this APPLICATION scoped property set during inbound flow
+ assertNotNull("Should be able to retrieve APPLICATION scoped property, but could not.", (String)p.getResponseContext().get("AddNumbersClientProtocolHandlerInboundAppScopedProperty"));
+ // should NOT be able to get this HANDLER scoped property though
+ assertNull("Should not be able to retrieve HANDLER scoped property, but was able.", (String)p.getResponseContext().get("AddNumbersClientProtocolHandlerInboundHandlerScopedProperty"));
+ // should be able to get this APPLICATION scoped property set by this client
+ assertNotNull("Should be able to retrieve APPLICATION scoped property, but could not.", (String)p.getRequestContext().get("myClientKey"));
+
+ assertEquals("With handler manipulation, total should be 4 less than a proper sumation.", 16, total);
+ TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+ TestLogger.logger.debug("----------------------------------");
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /*
+ * uses a custom HandlerResolver instead of the default. MyHandlerResolver
+ * puts the AddNumbersClientLogicalHandler and AddNumbersClientProtocolHandler
+ * in the flow. Results should be the same as testAddNumbersClientHandler.
+ */
+ public void testAddNumbersClientHandlerMyResolver() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ service.setHandlerResolver(new MyHandlerResolver());
+
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+
+ int total = proxy.addNumbersHandler(10,10);
+
+ assertEquals("With handler manipulation, total should be 4 less than a proper sumation.",
+ 16,
+ total);
+ TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+ TestLogger.logger.debug("----------------------------------");
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testAddNumbersClientProtoAndLogicalHandler() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+ // value 102 triggers an endpoint exception, which will run through the server outbound
+ // handleFault methods, then client inbound handleFault methods
+ int total = proxy.addNumbersHandler(102,10);
+
+ fail("should have got an exception, but didn't");
+ } catch(Exception e) {
+ e.printStackTrace();
+ assertTrue("Exception should be SOAPFaultException", e instanceof SOAPFaultException);
+ //AXIS2-2417 - assertEquals(((SOAPFaultException)e).getMessage(), "AddNumbersLogicalHandler2 was here");
+ assertEquals(((SOAPFaultException)e).getMessage(), "Got value 101. " +
+ "AddNumbersHandlerPortTypeImpl.addNumbersHandler method is " +
+ "correctly throwing this exception as part of testing");
+
+ }
+ TestLogger.logger.debug("----------------------------------");
+ }
+
+ public void testAddNumbersClientHandlerWithFault() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler4());
+ handlers.add(new AddNumbersClientLogicalHandler3());
+ handlers.add(new AddNumbersClientLogicalHandler());
+
+ p.getBinding().setHandlerChain(handlers);
+
+ int total = proxy.addNumbersHandler(99,10);
+
+ fail("Should have got an exception, but we didn't.");
+ TestLogger.logger.debug("----------------------------------");
+ } catch(Exception e) {
+ e.printStackTrace();
+ assertTrue("Exception should be SOAPFaultException", e instanceof SOAPFaultException);
+ assertEquals(((SOAPFaultException)e).getMessage(), "I don't like the value 99");
+ }
+ }
+
+ /**
+ * test results should be the same as testAddNumbersClientHandler, except that
+ * AddNumbersClientLogicalHandler2 doubles the first param on outbound. Async, of course.
+ *
+ */
+ public void testAddNumbersClientHandlerAsync() {
+ try{
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider)proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientLogicalHandler2());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+
+ AddNumbersHandlerAsyncCallback callback = new AddNumbersHandlerAsyncCallback();
+ Future<?> future = proxy.addNumbersHandlerAsync(10, 10, callback);
+
+ while (!future.isDone()) {
+ Thread.sleep(1000);
+ TestLogger.logger.debug("Async invocation incomplete");
+ }
+
+ int total = callback.getResponseValue();
+
+ assertEquals("With handler manipulation, total should be 26.", 26, total);
+ TestLogger.logger.debug("Total (after handler manipulation) = " + total);
+ TestLogger.logger.debug("----------------------------------");
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ public void testOneWay() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider bp = (BindingProvider) proxy;
+ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+ proxy.oneWayInt(11);
+ TestLogger.logger.debug("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testOneWayWithProtocolException() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider) proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ p.getRequestContext().put("myClientKey", "myClientVal");
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+ BindingProvider bp = (BindingProvider) proxy;
+ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ // value 99 will trigger exception from AddNumbersClientLogicalHandler
+ proxy.oneWayInt(99);
+ fail("Should have got an exception, but did not.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertEquals(e.getMessage(), "I don't like the value 99");
+ }
+ TestLogger.logger.debug("----------------------------------");
+ }
+
+ public void testOneWayWithRuntimeException() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider) proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ p.getRequestContext().put("myClientKey", "myClientVal");
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+ BindingProvider bp = (BindingProvider) proxy;
+ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ // value 99 will trigger exception from AddNumbersClientLogicalHandler
+ proxy.oneWayInt(999);
+ fail("Should have got an exception, but did not.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertEquals(e.getMessage(), "I don't like the value 999");
+ }
+ TestLogger.logger.debug("----------------------------------");
+ }
+
+
+ /*
+ * A callback implementation that can be used to collect the exceptions
+ */
+ class AddNumbersHandlerAsyncCallback implements AsyncHandler<AddNumbersHandlerResponse> {
+
+ private Exception exception;
+ private int retVal;
+
+ public void handleResponse(Response<AddNumbersHandlerResponse> response) {
+ try {
+ TestLogger.logger.debug("FaultyAsyncHandler.handleResponse() was called");
+ AddNumbersHandlerResponse r = response.get();
+ TestLogger.logger.debug("No exception was thrown from Response.get()");
+ retVal = r.getReturn();
+ }
+ catch (Exception e) {
+ TestLogger.logger.debug("An exception was thrown: " + e.getClass());
+ exception = e;
+ }
+ }
+
+ public int getResponseValue() {
+ return retVal;
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+ }
+
+ class MyHandlerResolver implements HandlerResolver {
+
+ public List<Handler> getHandlerChain(PortInfo portinfo) {
+ ArrayList<Handler> handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ return handlers;
+ }
+
+ }
+
+ private String getString(Source source) throws Exception {
+ if (source == null) {
+ return null;
+ }
+ StringWriter writer = new StringWriter();
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+ Result result = new StreamResult(writer);
+ t.transform(source, result);
+ return writer.getBuffer().toString();
+
+ }
+
+ /**
+ * Create a Source request to be used by Dispatch<Source>
+ */
+ private Source createRequestSource() throws IOException {
+ FileInputStream fis = new FileInputStream(requestFile);
+ return new StreamSource(fis);
+ }
+
+ public void testAddNumbersHandlerHandlerResolver() {
+ try {
+ System.out.println("----------------------------------");
+ System.out.println("test: " + getName());
+ AddNumbersHandlerService service = new AddNumbersHandlerService(); // will give NPE:
+ List<Handler> handlers = service.getHandlerResolver()
+ .getHandlerChain(null);
+ assertNotNull(
+ "Default handlers list should not be null but empty.",
+ handlers);
+ System.out.println("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.sample;
+
+import java.util.Map;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.handler.MessageContext;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersService;
+import org.apache.axis2.jaxws.TestLogger;
+
+public class AddNumbersTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/AddNumbersService.AddNumbersPortTypeImplPort";
+
+ public void testAddNumbers() throws Exception {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersService service = new AddNumbersService();
+ AddNumbersPortType proxy = service.getAddNumbersPort();
+
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ int total = proxy.addNumbers(10, 10);
+
+ TestLogger.logger.debug("Total =" + total);
+ TestLogger.logger.debug("----------------------------------");
+
+ assertEquals("sum", 20, total);
+ assertEquals("http response code",
+ new Integer(200), p.getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE));
+ Map headers = (Map) p.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
+ // the map should contain some headers
+ assertTrue("http response headers", headers != null && !headers.isEmpty());
+ }
+
+ public void testOneWay() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersService service = new AddNumbersService();
+ AddNumbersPortType proxy = service.getAddNumbersPort();
+
+ BindingProvider bp = (BindingProvider) proxy;
+ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ axisEndpoint);
+ proxy.oneWayInt(11);
+ TestLogger.logger.debug("----------------------------------");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddressBookTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddressBookTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddressBookTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddressBookTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,147 @@
+/*
+ * 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.sample;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.addressbook.AddEntry;
+import org.apache.axis2.jaxws.sample.addressbook.AddEntryResponse;
+import org.apache.axis2.jaxws.sample.addressbook.AddressBook;
+import org.apache.axis2.jaxws.sample.addressbook.AddressBookEntry;
+import org.apache.axis2.jaxws.sample.addressbook.ObjectFactory;
+import org.apache.axis2.jaxws.TestLogger;
+
+/**
+ * This tests the AddressBook same service that exists under
+ * org.apache.axis2.jaxws.sample.addressbook.*
+ */
+public class AddressBookTests extends TestCase {
+
+ private static final String NAMESPACE = "http://org/apache/axis2/jaxws/sample/addressbook";
+ private static final QName QNAME_SERVICE = new QName(
+ NAMESPACE, "AddressBookService");
+ private static final QName QNAME_PORT = new QName(
+ NAMESPACE, "AddressBook");
+ private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/AddressBookService.AddressBookImplPort";
+
+ /**
+ * Test the endpoint by invoking it with a JAX-WS Dispatch.
+ */
+
+ public void testAddressBookWithDispatch() throws Exception {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ JAXBContext jbc = JAXBContext.newInstance("org.apache.axis2.jaxws.sample.addressbook");
+
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+ Dispatch<Object> dispatch = service.createDispatch(
+ QNAME_PORT, jbc, Mode.PAYLOAD);
+
+ // Create the JAX-B object that will hold the data
+ ObjectFactory factory = new ObjectFactory();
+ AddEntry request = factory.createAddEntry();
+ AddressBookEntry content = factory.createAddressBookEntry();
+
+ content.setFirstName("Ron");
+ content.setLastName("Testerson");
+ content.setPhone("512-459-2222");
+
+ // Since this is a doc/lit wrapped WSDL, we need to set the
+ // data inside of a request wrapper element.
+ request.setEntry(content);
+
+ AddEntryResponse response = (AddEntryResponse) dispatch.invoke(request);
+
+ // Validate the results
+ assertNotNull(response);
+ assertTrue(response.isStatus());
+ TestLogger.logger.debug("[pass] - valid response received");
+ TestLogger.logger.debug("[response] - " + response.isStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+
+ /**
+ * Test the "addEntry" operation. This sends a complex type and returns
+ * a simple type.
+ */
+ public void testAddEntry() throws Exception {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ AddressBook ab = service.getPort(QNAME_PORT, AddressBook.class);
+ BindingProvider p1 = (BindingProvider) ab;
+ p1.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL_ENDPOINT);
+
+ ObjectFactory factory = new ObjectFactory();
+ AddressBookEntry content = factory.createAddressBookEntry();
+ content.setFirstName("Foo");
+ content.setLastName("Bar");
+ content.setPhone("512-459-2222");
+
+ boolean added = ab.addEntry(content);
+
+ // Validate the results
+ assertNotNull(added);
+ assertTrue(added);
+ }
+
+ /**
+ * Test the "findEntryByName" operation. This sends a simple type and
+ * returns a complex type.
+ */
+ public void testFindEntryByName() throws Exception {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ AddressBook ab = service.getPort(QNAME_PORT, AddressBook.class);
+ BindingProvider p1 = (BindingProvider) ab;
+ p1.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL_ENDPOINT);
+
+ String fname = "Joe";
+ String lname = "Test";
+ AddressBookEntry result = ab.findEntryByName(fname, lname);
+
+ // Validate the results
+ assertNotNull(result);
+ assertNotNull(result.getFirstName());
+ assertNotNull(result.getLastName());
+ assertTrue(result.getFirstName().equals(fname));
+ assertTrue(result.getLastName().equals(lname));
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AsyncCallback.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AsyncCallback.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AsyncCallback.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AsyncCallback.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.util.concurrent.ExecutionException;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.test.sample.nonwrap.ReturnType;
+import org.test.sample.nonwrap.TwoWayHolder;
+import org.apache.axis2.jaxws.TestLogger;
+
+
+public class AsyncCallback implements AsyncHandler {
+
+ /**
+ *
+ */
+ public AsyncCallback() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.ws.AsyncHandler#handleResponse(javax.xml.ws.Response)
+ */
+ public void handleResponse(Response response) {
+ try{
+ Object obj = response.get();
+ if(obj instanceof ReturnType){
+ ReturnType type = (ReturnType)obj;
+ TestLogger.logger.debug(">>Return String = " + type.getReturnStr());
+ return;
+ }
+ if(obj instanceof TwoWayHolder){
+ TwoWayHolder twh = (TwoWayHolder)obj;
+ TestLogger.logger.debug("AsyncCallback Holder string =" + twh.getTwoWayHolderStr());
+ TestLogger.logger.debug("AsyncCallback Holder int =" + twh.getTwoWayHolderInt());
+ }
+
+ }catch(ExecutionException e){
+ e.printStackTrace();
+ }catch(InterruptedException e){
+ e.printStackTrace();
+ }
+
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/BareTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/BareTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/BareTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/BareTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,105 @@
+/*
+ * 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.sample;
+
+import javax.xml.ws.BindingProvider;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.doclitbare.sei.BareDocLitService;
+import org.apache.axis2.jaxws.sample.doclitbare.sei.DocLitBarePortType;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.log4j.BasicConfigurator;
+
+public class BareTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:6060/axis2/services/BareDocLitService.DocLitBarePortTypeImplPort";
+
+ public void testTwoWaySync(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ try{
+
+ BareDocLitService service = new BareDocLitService();
+ DocLitBarePortType proxy = service.getBareDocLitPort();
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_URI_PROPERTY, "twoWaySimple");
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ String response = proxy.twoWaySimple(10);
+ TestLogger.logger.debug("Sync Response =" + response);
+ TestLogger.logger.debug("------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testTwoWaySyncWithBodyRouting(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ try{
+
+ BareDocLitService service = new BareDocLitService();
+ DocLitBarePortType proxy = service.getBareDocLitPort();
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ String response = proxy.twoWaySimple(10);
+ TestLogger.logger.debug("Sync Response =" + response);
+ TestLogger.logger.debug("------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testOneWayEmpty(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ try{
+
+ BareDocLitService service = new BareDocLitService();
+ DocLitBarePortType proxy = service.getBareDocLitPort();
+ BindingProvider p = (BindingProvider) proxy;
+
+ p.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,
+ Boolean.TRUE);
+ p.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
+ "oneWayEmpty");
+ p.getRequestContext().put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ proxy.oneWayEmpty();
+
+ TestLogger.logger.debug("------------------------------");
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,266 @@
+/*
+ * 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.sample;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axis2.jaxws.dispatch.DispatchTestConstants;
+import org.apache.axis2.jaxws.sample.dlwmin.sei.Greeter;
+import org.apache.axis2.jaxws.sample.dlwmin.sei.TestException;
+import org.apache.axis2.jaxws.sample.dlwmin.sei.TestException2;
+import org.apache.axis2.jaxws.sample.dlwmin.sei.TestException3;
+import org.apache.axis2.jaxws.sample.dlwmin.types.TestBean;
+import org.apache.axis2.jaxws.TestLogger;
+
+import junit.framework.TestCase;
+
+public class DLWMinTests extends TestCase {
+
+ private static final String NAMESPACE = "http://apache.org/axis2/jaxws/sample/dlwmin";
+ private static final QName QNAME_SERVICE = new QName(
+ NAMESPACE, "GreeterService");
+ private static final QName QNAME_PORT = new QName(
+ NAMESPACE, "GreeterPort");
+ private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/GreeterService.GreeterImplPort";
+
+ private Greeter getProxy(String action) {
+ Service service = Service.create(QNAME_SERVICE);
+ Greeter proxy = service.getPort(QNAME_PORT, Greeter.class);
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_URI_PROPERTY, action);
+ p.getRequestContext().put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL_ENDPOINT);
+ return proxy;
+ }
+
+ private Dispatch<String> getDispatch(String action) {
+ // Get a dispatch
+ Service svc = Service.create(QNAME_SERVICE);
+ svc.addPort(QNAME_PORT, null, URL_ENDPOINT);
+ Dispatch<String> dispatch = svc.createDispatch(QNAME_PORT,
+ String.class, Service.Mode.PAYLOAD);
+ BindingProvider p = (BindingProvider) dispatch;
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_URI_PROPERTY, action);
+ return dispatch;
+ }
+
+ /**
+ * Test simple greetMe method
+ * with style doc/lit wrapped without the presence of wrapper classes.
+ */
+ public void testGreetMe() {
+
+ Greeter proxy = getProxy("greetMe");
+
+ String me = "Scheu";
+ String response = proxy.greetMe(me);
+ assertTrue("Hello Scheu".equals(response));
+ }
+
+ /**
+ * Test simple greetMe method with dispatch
+ * with style doc/lit wrapped without the presence of wrapper classes.
+ */
+ public void testGreetMe_Dispatch() {
+
+ Dispatch<String> dispatch = getDispatch("greetMe");
+
+ String request =
+ "<pre:greetMe xmlns:pre='http://apache.org/axis2/jaxws/sample/dlwmin'>" +
+ "<pre:requestType>Scheu</pre:requestType>" +
+ "</pre:greetMe>";
+ TestLogger.logger.debug("Doc/Lit Wrapped Minimal Request =" + request);
+ String response = dispatch.invoke(request);
+ TestLogger.logger.debug("Doc/Lit Wrapped Minimal Response =" + response);
+
+ assertTrue(response.contains("Hello Scheu"));
+ assertTrue(response.contains("dlwmin:greetMeResponse"));
+ assertTrue(response.contains(":responseType") ||
+ response.contains("responseType xmlns=")); // assert that response type is a qualified element
+ assertTrue(!response.contains("xsi:type")); // xsi:type should not be used
+ }
+
+ /**
+ * Test simple greetMe method
+ * with style doc/lit wrapped without the presence of wrapper classes.
+ */
+ public void testUnqualified() {
+
+ Greeter proxy = getProxy("testUnqualified");
+
+ String request = "hello world";
+ String response = proxy.testUnqualified(request);
+ assertTrue("hello world".equals(response));
+ }
+
+ /**
+ * Test simple greetMe method with dispatch
+ * with style doc/lit wrapped without the presence of wrapper classes.
+ */
+ public void testUnqualified_Dispatch() {
+
+ Dispatch<String> dispatch = getDispatch("testUnqualified");
+
+ String request =
+ "<pre:unqualifiedTestResponse xmlns:pre='http://apache.org/axis2/jaxws/sample/dlwmin'>" +
+ "<unqualifiedRequest>hello world</unqualifiedRequest>" +
+ "</pre:unqualifiedTestResponse>";
+ TestLogger.logger.debug("Doc/Lit Wrapped Minimal Request =" + request);
+ String response = dispatch.invoke(request);
+ TestLogger.logger.debug("Doc/Lit Wrapped Minimal Response =" + response);
+
+ assertTrue(response.contains("hello world"));
+ assertTrue(response.contains("dlwmin:testUnqualifiedResponse"));
+ assertTrue(response.contains("<unqualifiedResponse")); // assert that the child element is an uqualified element
+ assertTrue(!response.contains("xsi:type")); // xsi:type should not be used
+ }
+
+ /**
+ * Test echo with complexType
+ */
+ public void testProcess_Echo() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ TestBean response = proxy.process(0, request);
+ assertTrue(response != null);
+ assertTrue(response.getData1().equals("hello world"));
+ assertTrue(response.getData2() == 10);
+ }
+
+ /**
+ * Test throwing checked exception w/o a JAXB Bean
+ */
+ public void testProcess_CheckException() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ try {
+ TestBean response = proxy.process(1, request);
+ fail("Expected TestException thrown");
+ } catch (WebServiceException wse) {
+ // Currently there is no support if the fault bean is missing
+ assertTrue(wse.getMessage().contains("User fault processing is not supported"));
+ } catch (TestException te) {
+ assertTrue(te.getMessage().equals("TestException thrown"));
+ assertTrue(te.getFlag() == 123);
+ } catch (Exception e) {
+ fail("Expected TestException thrown but found " + e.getClass());
+ }
+ }
+
+ /**
+ * Test throwing checked exception that has a JAXB Bean
+ */
+ public void testProcess_CheckException2() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ try {
+ TestBean response = proxy.process(4, request);
+ fail("Expected TestException2 thrown");
+ } catch (TestException2 te) {
+ assertTrue(te.getMessage().equals("TestException2 thrown"));
+ assertTrue(te.getFlag() == 456);
+ } catch (Exception e) {
+ fail("Expected TestException2 thrown but found " + e.getClass());
+ }
+ }
+
+ /**
+ * Test throwing checked exception that is a compliant JAXWS exception
+ */
+ public void testProcess_CheckException3() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ try {
+ TestBean response = proxy.process(5, request);
+ fail("Expected TestException3 thrown");
+ } catch (TestException3 te) {
+ assertTrue(te.getMessage().equals("TestException3 thrown"));
+ assertTrue(te.getFaultInfo().getFlag() == 789);
+ } catch (Exception e) {
+ fail("Expected TestException3 thrown but found " + e.getClass());
+ }
+ }
+
+ /**
+ * Test throwing WebServiceException
+ */
+ public void testProcess_WebServiceException() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ try {
+ TestBean response = proxy.process(2, request);
+ fail("Expected WebServiceException thrown");
+ } catch (WebServiceException wse) {
+ assertTrue(wse.getMessage().equals("WebServiceException thrown"));
+ } catch (Exception e) {
+ fail("Expected WebServiceException thrown but found " + e.getClass());
+ }
+ }
+
+ /**
+ * Test throwing NPE
+ */
+ public void testProcess_NPE() throws Exception {
+
+ Greeter proxy = getProxy("process");
+
+ TestBean request = new TestBean();
+ request.setData1("hello world");
+ request.setData2(10);
+ try {
+ TestBean response = proxy.process(3, request);
+ fail("Expected NullPointerException thrown");
+ } catch (WebServiceException wse) {
+ assertTrue(wse.getMessage().equals("NPE thrown"));
+ } catch (Exception e) {
+ fail("Expected NullPointerException thrown but found " + e.getClass());
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DocLitBareMinTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DocLitBareMinTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DocLitBareMinTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DocLitBareMinTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.sample;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+
+import org.apache.axis2.jaxws.sample.doclitbaremin.sei.BareDocLitMinService;
+import org.apache.axis2.jaxws.sample.doclitbaremin.sei.DocLitBareMinPortType;
+import org.apache.axis2.jaxws.TestLogger;
+
+import junit.framework.TestCase;
+
+
+public class DocLitBareMinTests extends TestCase {
+
+ public void testEcho() throws Exception {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+
+ BareDocLitMinService service = new BareDocLitMinService();
+ DocLitBareMinPortType proxy = service.getBareDocLitMinPort();
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_URI_PROPERTY, "echo");
+ String request = "dlroW elloH";
+ String response = proxy.echo(request);
+
+ assertTrue(request.equals(response));
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org