gdaniels 2002/12/01 11:48:17
Modified: java/test/encoding PackageTests.java
Added: java/test/encoding TestCircularRefs.java
java/test GenericLocalTest.java
Log:
Add a circular references (in Vectors) test, and a framework class which
encapsulates standard local server testing code.
Revision Changes Path
1.26 +1 -0 xml-axis/java/test/encoding/PackageTests.java
Index: PackageTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/PackageTests.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- PackageTests.java 20 Nov 2002 14:59:17 -0000 1.25
+++ PackageTests.java 1 Dec 2002 19:48:17 -0000 1.26
@@ -38,6 +38,7 @@
suite.addTestSuite(TestOmittedValues.class);
suite.addTestSuite(TestMultiRefIdentity.class);
suite.addTestSuite(TestArray.class);
+ suite.addTestSuite(TestCircularRefs.class);
return suite;
}
}
1.1 xml-axis/java/test/encoding/TestCircularRefs.java
Index: TestCircularRefs.java
===================================================================
package test.encoding;
import test.GenericLocalTest;
import java.util.Vector;
import org.apache.axis.client.Call;
public class TestCircularRefs extends GenericLocalTest {
public TestCircularRefs() {
super("foo");
}
public TestCircularRefs(String s) {
super(s);
}
public void testCircularVectors() throws Exception {
Call call = getCall();
Object result = call.invoke("getCircle", null);
// This just tests that we don't get exceptions during deserialization
// for now. We're still getting nulls for some reason, and once that's
// fixed we should uncomment this next line
// assertTrue("Result wasn't an array", result.getClass().isArray());
}
/**
* Service method. Return a Vector containing an object graph with a loop.
*
* @return a Vector with circular references
*/
public Vector getCircle() {
Vector vector1 = new Vector();
vector1.addElement("AString");
Vector vector2 = new Vector();
vector2.addElement(vector1);
vector1.addElement(vector2);
return vector2;
}
}
1.1 xml-axis/java/test/GenericLocalTest.java
Index: GenericLocalTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test;
import org.apache.axis.server.AxisServer;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.transport.local.LocalTransport;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.configuration.BasicServerConfig;
import junit.framework.TestCase;
/**
* This is a framework class which handles all the basic stuff necessary
* to set up a local "roundtrip" test to an AxisServer.
*
* To use it - extend this class with your own test. Make sure if you
* override setUp() that you call super.setUp() so that the engine gets
* initialized correctly. The method deploy() needs to be called to deploy
* a target service and set up the transport to talk to it - note that this
* is done by default in the no-argument setUp(). If you don't want this
* behavior, or want to tweak names/classes, just call super.setUp(false)
* instead of super.setUp() and the deploy() call won't happen.
*
* Then you get a Call object by calling getCall() and you're ready to rock.
*
* @author Glen Daniels ([EMAIL PROTECTED])
*/
public class GenericLocalTest extends TestCase {
protected AxisServer server;
protected SimpleProvider config;
protected LocalTransport transport;
public GenericLocalTest(String s) {
super(s);
}
/**
* Default setUp, which automatically deploys the current class
* as a service named "service". Override to switch this off.
*
* @throws Exception
*/
protected void setUp() throws Exception {
setUp(true);
}
/**
* setUp which allows controlling whether or not deploy() is called.
*
* @param deploy indicates whether we should call deploy()
* @throws Exception
*/
protected void setUp(boolean deploy) throws Exception {
super.setUp();
config = new BasicServerConfig();
server = new AxisServer(config);
transport = new LocalTransport(server);
if (deploy)
deploy();
}
/**
* Get an initialized Call, ready to invoke us over the local transport.
*
* @return an initialized Call object.
*/
public Call getCall() {
Call call = new Call(new Service());
call.setTransport(transport);
return call;
}
/**
* Convenience method to deploy ourselves as a service
*/
public void deploy() {
deploy("service", this.getClass());
}
/**
* Deploy a service to the local server we've set up, and point the
* cached local transport object to the desired service name.
*
* @param serviceName the name under which to deploy the service.
* @param target class of the service.
*/
public void deploy(String serviceName, Class target) {
String className = target.getName();
SOAPService service = new SOAPService(new RPCProvider());
service.setOption("className", className);
service.setOption("allowedMethods", "*");
config.deployService(serviceName, service);
transport.setRemoteService(serviceName);
}
}