KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > interop3 > docLit > DocLitTestCase


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

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