KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > interop3 > rpcEnc > RpcEncTestCase


1 package test.wsdl.interop3.rpcEnc;
2
3
4 import test.wsdl.interop3.rpcEnc.xsd.SOAPStruct;
5
6 import java.net.URL JavaDoc;
7
8 /*
9     <!-- SOAP Builder's round III web services -->
10     <!-- interoperability testing: import1 -->
11     <!-- (see http://www.whitemesa.net/r3/plan.html) -->
12     <!-- Step 1. Start with predefined WSDL -->
13     <!-- Step 2. Generate client from predefined WSDL -->
14     <!-- Step 3. Test generated client against -->
15     <!-- pre-built server -->
16     <!-- Step 4. Generate server from predefined WSDL -->
17     <!-- Step 5. Test generated client against -->
18     <!-- generated server -->
19     <!-- Step 6. Generate second client from -->
20     <!-- generated server's WSDL (some clients -->
21     <!-- can do this dynamically) -->
22     <!-- Step 7. Test second generated client against -->
23     <!-- generated server -->
24     <!-- Step 8. Test second generated client against -->
25     <!-- pre-built server -->
26 */

27
28 public class RpcEncTestCase extends junit.framework.TestCase {
29     static URL JavaDoc url;
30
31     public RpcEncTestCase(String JavaDoc name) {
32         super(name);
33     }
34
35     protected void setUp() throws Exception JavaDoc {
36     }
37
38     public void testStep3() throws Exception JavaDoc {
39         WSDLInteropTestRpcEncPortType binding;
40         try {
41             if (url != null) {
42                 binding = new WSDLInteropTestRpcEncServiceLocator().getWSDLInteropTestRpcEncPort(url);
43             } else {
44                 binding = new WSDLInteropTestRpcEncServiceLocator().getWSDLInteropTestRpcEncPort();
45             }
46         }
47         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
48             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
49         }
50         assertNotNull("binding is null", binding);
51
52         String JavaDoc str = "Hello there!";
53         String JavaDoc [] strArray = new String JavaDoc [] { "1", "two", "trois" };
54
55         assertEquals("echoString results differ", binding.echoString(str), str);
56
57         String JavaDoc [] resArray = binding.echoStringArray(strArray);
58         assertEquals("String array lengths differ",
59                      strArray.length,
60                      resArray.length);
61         for (int i = 0; i < strArray.length; i++) {
62             assertEquals("Array members at index " + i + " differ",
63                          strArray[i],
64                          resArray[i]);
65         }
66
67         SOAPStruct struct = new SOAPStruct();
68         struct.setVarFloat(3.14159F);
69         struct.setVarInt(69);
70         struct.setVarString("Struct-o-rama");
71
72         assertTrue("Structs weren't equal",
73                    struct.equals(binding.echoStruct(struct)));
74     }
75
76
77
78     public static void main(String JavaDoc[] args) {
79         if (args.length == 1) {
80             try {
81                 url = new URL JavaDoc(args[0]);
82             } catch (Exception JavaDoc e) {
83             }
84         }
85
86         junit.textui.TestRunner.run(new junit.framework.TestSuite(RpcEncTestCase.class));
87     } // main
88
}
89
90
Popular Tags