KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > echo > ComplexEchoServiceTestCase


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

7
8 package test.wsdl.echo;
9
10 public class ComplexEchoServiceTestCase extends junit.framework.TestCase {
11     public ComplexEchoServiceTestCase(String JavaDoc name) {
12         super(name);
13     }
14
15     public void testComplexEchoServiceWSDL() 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.echo.ComplexEchoServiceLocator().getComplexEchoServiceAddress() + "?WSDL");
18         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.echo.ComplexEchoServiceLocator().getServiceName());
19         assertTrue(service != null);
20     }
21
22     public void test1ComplexEchoServiceEcho() {
23         test.wsdl.echo.Echo binding;
24         try {
25             binding = new test.wsdl.echo.ComplexEchoServiceLocator().getComplexEchoService();
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.echo.MyComplexType complexType = new test.wsdl.echo.MyComplexType();
34             test.wsdl.echo.holders.MyComplexTypeHolder complexTypeHolder =
35                     new test.wsdl.echo.holders.MyComplexTypeHolder(complexType);
36             binding.echo(complexTypeHolder);
37             assertTrue(complexTypeHolder.value.getSimpleItem().equals("MY_SIMPLE_ITEM"));
38         }
39         catch (java.rmi.RemoteException JavaDoc re) {
40             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
41         }
42     }
43
44     public void test2ComplexEchoServiceEcho2() throws Exception JavaDoc {
45         test.wsdl.echo.ComplexEchoServiceSoapBindingStub binding;
46         try {
47             binding = (test.wsdl.echo.ComplexEchoServiceSoapBindingStub)
48                     new test.wsdl.echo.ComplexEchoServiceLocator().getComplexEchoService();
49         }
50         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
51             if (jre.getLinkedCause() != null)
52                 jre.getLinkedCause().printStackTrace();
53             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
54         }
55         assertNotNull("binding is null", binding);
56         // Time out after a minute
57
binding.setTimeout(60000);
58         test.wsdl.echo.MyComplexType2 request = new test.wsdl.echo.MyComplexType2();
59         request.setUsername("xxx");
60         request.setPassword("yyy");
61         request.setOptions(new NamedValue[]{
62             new NamedValue("dummy1", "dummy_val1"),
63             new NamedValue("dummy2",
64                     new NamedValueSet (new NamedValue[]{
65                         new NamedValue("dummy2-1", "val2-1"),
66                         new NamedValue("dummy2-2", new Integer JavaDoc(314))
67                     }))
68         });
69         // Test operation
70
test.wsdl.echo.NamedValue[] value = null;
71         value = binding.echo2(request);
72         // TBD - validate results
73
}
74
75     public void test2ComplexEchoServiceEcho21() throws Exception JavaDoc {
76         test.wsdl.echo.ComplexEchoServiceSoapBindingStub binding;
77         try {
78             binding = (test.wsdl.echo.ComplexEchoServiceSoapBindingStub)
79                     new test.wsdl.echo.ComplexEchoServiceLocator().getComplexEchoService();
80         }
81         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
82             if (jre.getLinkedCause() != null)
83                 jre.getLinkedCause().printStackTrace();
84             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
85         }
86         assertNotNull("binding is null", binding);
87         // Time out after a minute
88
binding.setTimeout(60000);
89         test.wsdl.echo.MyComplexType2 request = new test.wsdl.echo.MyComplexType2();
90         request.setUsername("xxx");
91         request.setPassword("yyy");
92         request.setOptions(new NamedValue[]{
93             new NamedValue("dummy1", "dummy_val1"),
94             new NamedValue("dummy2", new NamedValue[]{
95                 new NamedValue("dummy2-1", "val2-1"),
96                 new NamedValue("dummy2-2", new Integer JavaDoc(314))
97             })
98         });
99         // Test operation
100
test.wsdl.echo.NamedValue[] value = null;
101
102         value = binding.echo2(request);
103         // TBD - validate results
104
}
105 }
106
Popular Tags