Author: veithen
Date: Sat Sep 29 11:13:38 2012
New Revision: 1391782
URL: http://svn.apache.org/viewvc?rev=1391782&view=rev
Log:
Migrated test/wsdl/rpcParams (AXIS-928) to the Maven build. Also refactored the
test case to use the Call API instead of a manually modified stub.
Added:
axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/
axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsBindingImpl.java
- copied unchanged from r1391765,
axis/axis1/java/trunk/test/wsdl/rpcParams/RpcParamsBindingImpl.java
axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
- copied, changed from r1391765,
axis/axis1/java/trunk/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
axis/axis1/java/trunk/integration/src/test/wsdd/wsdl/rpcParams/
axis/axis1/java/trunk/integration/src/test/wsdd/wsdl/rpcParams/deploy.wsdd
- copied unchanged from r1391765,
axis/axis1/java/trunk/test/wsdl/rpcParams/deploy.wsdd
axis/axis1/java/trunk/integration/src/test/wsdl/rpcParams/
axis/axis1/java/trunk/integration/src/test/wsdl/rpcParams/rpcParams.wsdl
- copied unchanged from r1391765,
axis/axis1/java/trunk/test/wsdl/rpcParams/rpcParams.wsdl
Removed:
axis/axis1/java/trunk/test/wsdl/rpcParams/
Modified:
axis/axis1/java/trunk/integration/pom.xml
Modified: axis/axis1/java/trunk/integration/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/integration/pom.xml?rev=1391782&r1=1391781&r2=1391782&view=diff
==============================================================================
--- axis/axis1/java/trunk/integration/pom.xml (original)
+++ axis/axis1/java/trunk/integration/pom.xml Sat Sep 29 11:13:38 2012
@@ -1020,6 +1020,17 @@
</configuration>
</execution>
<execution>
+ <id>rpcParams</id>
+ <goals>
+ <goal>generate-test-sources</goal>
+ </goals>
+ <configuration>
+ <file>src/test/wsdl/rpcParams/rpcParams.wsdl</file>
+ <generate>server</generate>
+ <!-- Don't generate deploy.wsdd; we supply our own
-->
+ </configuration>
+ </execution>
+ <execution>
<id>session</id>
<goals>
<goal>generate-test-sources</goal>
@@ -1258,6 +1269,7 @@
</goals>
<configuration>
<port>${test.functional.ServicePort}</port>
+ <foregroundPort>8080</foregroundPort>
<wsdds>
<wsdd>
<directory>src/test/wsdd</directory>
Copied:
axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
(from r1391765,
axis/axis1/java/trunk/test/wsdl/rpcParams/RpcParamsServiceTestCase.java)
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java?p2=axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java&p1=axis/axis1/java/trunk/test/wsdl/rpcParams/RpcParamsServiceTestCase.java&r1=1391765&r2=1391782&rev=1391782&view=diff
==============================================================================
--- axis/axis1/java/trunk/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
(original)
+++
axis/axis1/java/trunk/integration/src/test/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
Sat Sep 29 11:13:38 2012
@@ -1,56 +1,134 @@
-/**
- * RpcParamsServiceTestCase.java
+/*
+ * 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
*
- * This file was auto-generated from WSDL
- * by the Apache Axis WSDL2Java emitter.
+ * 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 test.wsdl.rpcParams;
-import javax.xml.rpc.ServiceException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.client.Call;
+import org.apache.axis.constants.Style;
+import org.apache.axis.constants.Use;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.encoding.ser.BeanSerializerFactory;
+import org.apache.axis.soap.SOAPConstants;
+
+import test.HttpTestUtil;
import junit.framework.TestCase;
+/**
+ * Simple test case to test parameter handling in an RPC/Encoded web service.
It tests two
+ * scenarios:
+ * <ol>
+ * <li>Null parameters to an operation may be ommitted.
+ * <li>Parameters to an operation may be sent in any order.
+ * </ol>
+ * To accomplish this, the test uses the {@link Call} API instead of a
generated stub, since
+ * wsdl2Java never reorders or omits null parameters.
+ * <p>
+ * The test case was originally created to validate bug <a
+ * href="https://issues.apache.org/jira/browse/AXIS-928">AXIS-928</a>.
+ */
public class RpcParamsServiceTestCase extends TestCase {
- public RpcParamsServiceTestCase(String name) {
- super(name);
- }
+ private static EchoStruct callEcho(String first, String second, boolean
reverse) throws Exception {
+ OperationDesc operation = new OperationDesc();
+ operation.setName("echo");
+ if (!reverse) {
+ if (first != null) {
+ operation.addParameter(new QName("", "first"), new
QName("http://www.w3.org/2001/XMLSchema", "string"), String.class,
ParameterDesc.IN, false, false);
+ }
+ if (second != null) {
+ operation.addParameter(new QName("", "second"), new
QName("http://www.w3.org/2001/XMLSchema", "string"), String.class,
ParameterDesc.IN, false, false);
+ }
+ } else {
+ if (second != null) {
+ operation.addParameter(new QName("", "second"), new
QName("http://www.w3.org/2001/XMLSchema", "string"), String.class,
ParameterDesc.IN, false, false);
+ }
+ if (first != null) {
+ operation.addParameter(new QName("", "first"), new
QName("http://www.w3.org/2001/XMLSchema", "string"), String.class,
ParameterDesc.IN, false, false);
+ }
+ }
+ operation.setReturnType(new QName("urn:rpcParams.wsdl.test",
"EchoStruct"));
+ operation.setReturnClass(EchoStruct.class);
+ operation.setReturnQName(new QName("", "echoReturn"));
+ operation.setStyle(Style.RPC);
+ operation.setUse(Use.ENCODED);
+
+ Call call = new
Call(HttpTestUtil.getTestEndpoint("http://localhost:8080/axis/services/RpcParams"));
+ call.setOperation(operation);
+ call.setUseSOAPAction(true);
+ call.setSOAPActionURI("");
+ call.setSOAPVersion(SOAPConstants.SOAP11_CONSTANTS);
+ call.setOperationName(new QName("urn:rpcParams.wsdl.test", "echo"));
+ call.registerTypeMapping(EchoStruct.class, new
QName("urn:rpcParams.wsdl.test", "EchoStruct"), BeanSerializerFactory.class,
BeanDeserializerFactory.class, false);
+
+ // add the params we're actually going to send, again ommitting nulls
+ List params = new ArrayList(2);
+ if (!reverse) {
+ if (first != null) {
+ params.add(first);
+ }
+ if (second != null) {
+ params.add(second);
+ }
+ } else {
+ if (second != null) {
+ params.add(second);
+ }
+ if (first != null) {
+ params.add(first);
+ }
+ }
- public void testRpcParamsWSDL() throws Exception {
- javax.xml.rpc.ServiceFactory serviceFactory =
javax.xml.rpc.ServiceFactory.newInstance();
- java.net.URL url = new java.net.URL(new
test.wsdl.rpcParams.RpcParamsServiceLocator().getRpcParamsAddress() + "?WSDL");
- javax.xml.rpc.Service service = serviceFactory.createService(url, new
test.wsdl.rpcParams.RpcParamsServiceLocator().getServiceName());
- assertTrue(service != null);
+ return (EchoStruct)call.invoke(params.toArray());
}
-
+
/**
* Send parameters in the order that they are specified in
* the wsdl. Also omits null parameters.
*/
public void testEcho() throws Exception {
- RpcParamsBindingStub binding = getBinding();
-
EchoStruct result;
// test sending both
- result = binding.echo("first", "second");
+ result = callEcho("first", "second", false);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when both sent",
"first", result.getFirst());
assertEquals("second parameter marshalled wrong when both sent",
"second", result.getSecond());
// test ommitting the first, since it's null
- result = binding.echo(null, "second");
+ result = callEcho(null, "second", false);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertEquals("second parameter marshalled wrong first is null",
"second", result.getSecond());
// test ommitting the second, since it's null
- result = binding.echo("first", null);
+ result = callEcho("first", null, false);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when second is null",
"first", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
// test ommitting both, since they're null
- result = binding.echo(null, null);
+ result = callEcho(null, null, false);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
@@ -61,48 +139,29 @@ public class RpcParamsServiceTestCase ex
* the wsdl. Also omits null parameters.
*/
public void testEchoReverse() throws Exception {
- RpcParamsBindingStub binding = getBinding();
-
EchoStruct result;
// test sending both
- result = binding.echoReverse("first", "second");
+ result = callEcho("first", "second", true);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when both sent",
"first", result.getFirst());
assertEquals("second parameter marshalled wrong when both sent",
"second", result.getSecond());
// test ommitting the first, since it's null
- result = binding.echoReverse(null, "second");
+ result = callEcho(null, "second", true);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertEquals("second parameter marshalled wrong first is null",
"second", result.getSecond());
// test ommitting the second, since it's null
- result = binding.echoReverse("first", null);
+ result = callEcho("first", null, true);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when second is null",
"first", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
// test ommitting both, since they're null
- result = binding.echoReverse(null, null);
+ result = callEcho(null, null, true);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
}
-
- private RpcParamsBindingStub getBinding() {
- RpcParamsBindingStub binding = null;
- try {
- binding = (RpcParamsBindingStub) new
RpcParamsServiceLocator().getRpcParams();
- }
- catch (ServiceException jre) {
- if(jre.getLinkedCause()!=null)
- jre.getLinkedCause().printStackTrace();
- fail("JAX-RPC ServiceException caught: " + jre);
- }
- assertNotNull("binding is null", binding);
-
- // Time out after a minute
- binding.setTimeout(60000);
- return binding;
- }
}