KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > interop3 > import3 > Import3TestCase


1 package test.wsdl.interop3.import3;
2
3
4 import test.wsdl.interop3.import3.xsd.SOAPStruct;
5
6 import java.net.URL JavaDoc;
7
8 /*
9     <!-- SOAP Builder's round III web services -->
10     <!-- interoperability testing: import3 -->
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 Import3TestCase extends junit.framework.TestCase {
29     public static URL JavaDoc url;
30
31     public Import3TestCase(String JavaDoc name) {
32         super(name);
33     }
34
35     public void testStep3EchoStruct() {
36         SoapInteropImport3PortType binding;
37         try {
38             if (url == null) {
39                 binding = new Import3Locator().getSoapInteropImport3Port();
40             } else {
41                 binding = new Import3Locator().getSoapInteropImport3Port(url);
42             }
43         }
44         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
45             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
46         }
47         assertTrue("binding is null", binding != null);
48
49         try {
50             SOAPStruct value = new SOAPStruct();
51             value.setVarString("import2 string");
52             value.setVarInt(5);
53             value.setVarFloat(4.5F);
54             SOAPStruct result = binding.echoStruct(value);
55             assertEquals("String members didn't match", value.getVarString(), result.getVarString());
56             assertEquals("int members didn't match", value.getVarInt(), result.getVarInt());
57         }
58         catch (java.rmi.RemoteException JavaDoc re) {
59             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
60         }
61     }
62
63     public void testStep3EchoStructArray() {
64         SoapInteropImport3PortType binding;
65         try {
66             if (url == null) {
67                 binding = new Import3Locator().getSoapInteropImport3Port();
68             } else {
69                 binding = new Import3Locator().getSoapInteropImport3Port(url);
70             }
71         }
72         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
73             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
74         }
75         assertTrue("binding is null", binding != null);
76
77         try {
78             SOAPStruct[] value = null;
79             value = binding.echoStructArray(new SOAPStruct[0]);
80         }
81         catch (java.rmi.RemoteException JavaDoc re) {
82             throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
83         }
84     }
85
86     public static void main(String JavaDoc[] args) {
87         if (args.length == 1) {
88             try {
89                 url = new URL JavaDoc(args[0]);
90             } catch (Exception JavaDoc e) {
91             }
92         }
93
94         junit.textui.TestRunner.run(new junit.framework.TestSuite(Import3TestCase.class));
95     } // main
96

97 }
98
99
Popular Tags