KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > polymorphism > PolymorphismTest_ServiceTestCase


1 /**
2  * PolymorphismTest_ServiceTestCase.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis WSDL2Java emitter.
6  */

7
8 package test.wsdl.polymorphism;
9
10 public class PolymorphismTest_ServiceTestCase extends junit.framework.TestCase {
11     public PolymorphismTest_ServiceTestCase(String JavaDoc name) {
12         super(name);
13     }
14
15     public void testPolymorphismTestWSDL() throws Exception JavaDoc {
16         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
17         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.polymorphism.PolymorphismTest_ServiceLocator().getPolymorphismTestAddress() + "?WSDL");
18         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.polymorphism.PolymorphismTest_ServiceLocator().getServiceName());
19         assertTrue(service != null);
20     }
21
22     public void test1PolymorphismTestGetBAsA() {
23         test.wsdl.polymorphism.PolymorphismTest_Port binding;
24         try {
25             binding = new test.wsdl.polymorphism.PolymorphismTest_ServiceLocator().getPolymorphismTest();
26         }
27         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
28             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
29         }
30         assertTrue("binding is null", binding != null);
31
32         try {
33             test.wsdl.polymorphism.A value = null;
34
35             // Passing false here gets us a "B"
36
value = binding.getBAsA(false);
37
38             // Check out the return value for correctness.
39
assertTrue("Return value wasn't a 'B'!", value instanceof B);
40             B myB = (B)value;
41             assertEquals("B field didn't match",
42                          PolymorphismTestSoapImpl.B_TEXT,
43                          myB.getB());
44             assertEquals("A field didn't match",
45                          PolymorphismTestSoapImpl.A_TEXT,
46                          myB.getA());
47         }
48         catch (java.rmi.RemoteException JavaDoc re) {
49             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
50         }
51     }
52
53     public void test1PolymorphismTestGetCAsA() {
54         test.wsdl.polymorphism.PolymorphismTest_Port binding;
55         try {
56             binding = new test.wsdl.polymorphism.PolymorphismTest_ServiceLocator().getPolymorphismTest();
57         }
58         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
59             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
60         }
61         assertTrue("binding is null", binding != null);
62
63         try {
64             test.wsdl.polymorphism.A value = null;
65
66             // Passing true here gets us a "C" on the server side, but since
67
// there's no type mapping for that we should just get the "A"
68
// part.
69
value = binding.getBAsA(true);
70
71             // Check out the return value for correctness.
72
assertTrue("Return value wasn't an 'A'!", value instanceof A);
73             assertEquals("A field didn't match",
74                          PolymorphismTestSoapImpl.A_TEXT,
75                          value.getA());
76         }
77         catch (java.rmi.RemoteException JavaDoc re) {
78             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
79         }
80     }
81
82 }
83
Popular Tags