KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > inheritance > TestInheritance


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