1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
package test.inheritance;
import junit.framework.TestCase;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
public class TestInheritance extends TestCase {
private AxisServer server;
private LocalTransport transport;
public TestInheritance(String s) {
super(s);
}
protected void setUp() throws Exception {
SimpleProvider config = new SimpleProvider();
SOAPService service = new SOAPService(new RPCProvider());
service.setOption("className", "test.inheritance.Child");
service.setOption("allowedMethods", "*");
config.deployService("inheritanceTest", service);
server = new AxisServer(config);
transport = new LocalTransport(server);
transport.setRemoteService("inheritanceTest");
}
public void testInheritance() throws Exception {
Call call = new Call(new Service());
call.setTransport(transport);
String ret = (String)call.invoke("inherited", null);
assertEquals("Inherited method returned bad result",
Parent.HELLO_MSG, ret);
ret = (String)call.invoke("normal", null);
assertEquals("Child method returned bad result",
Child.HELLO_MSG, ret);
ret = (String)call.invoke("overloaded", new Object [] { "test" });
assertTrue("Overloaded (String) method returned bad result",
ret.startsWith(Parent.OVERLOAD_MSG));
ret = (String)call.invoke("overloaded",
new Object [] { new Integer(5) });
assertTrue("Overloaded (int) method returned bad result",
ret.startsWith(Child.OVERLOAD_MSG));
}
}
|