Debian Codegraph @

test/wsdl/interop3/compound2/Compound2TestCase.java

raw
1 package test.wsdl.interop3.compound2;
2
3
4 import test.wsdl.interop3.compound2.Compound2Locator;
5 import test.wsdl.interop3.compound2.SoapInteropCompound2PortType;
6 import test.wsdl.interop3.compound2.xsd.Employee;
7 import test.wsdl.interop3.compound2.xsd.Person;
8
9 import java.net.URL;
10
11 /*
12 <!-- SOAP Builder's round III web services -->
13 <!-- interoperability testing: import1 -->
14 <!-- (see http://www.whitemesa.net/r3/plan.html) -->
15 <!-- Step 1. Start with predefined WSDL -->
16 <!-- Step 2. Generate client from predefined WSDL -->
17 <!-- Step 3. Test generated client against -->
18 <!-- pre-built server -->
19 <!-- Step 4. Generate server from predefined WSDL -->
20 <!-- Step 5. Test generated client against -->
21 <!-- generated server -->
22 <!-- Step 6. Generate second client from -->
23 <!-- generated server's WSDL (some clients -->
24 <!-- can do this dynamically) -->
25 <!-- Step 7. Test second generated client against -->
26 <!-- generated server -->
27 <!-- Step 8. Test second generated client against -->
28 <!-- pre-built server -->
29 */
30
31 public class Compound2TestCase extends junit.framework.TestCase {
32 static URL url;
33
34 public Compound2TestCase(String name) {
35 super(name);
36 }
37
38 protected void setUp() throws Exception {
39 }
40
41 public void testStep3() {
42 SoapInteropCompound2PortType binding;
43 try {
44 if (url != null) {
45 binding = new Compound2Locator().getSoapInteropCompound2Port(url);
46 } else {
47 binding = new Compound2Locator().getSoapInteropCompound2Port();
48 }
49 }
50 catch (javax.xml.rpc.ServiceException jre) {
51 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
52 }
53 assertTrue("binding is null", binding != null);
54
55 try {
56 Employee emp = new Employee();
57 Person person = new Person();
58 person.setMale(true);
59 person.setName("Joe Blow");
60 emp.setPerson(person);
61 emp.setID(314159);
62 emp.setSalary(100000.50);
63
64 Employee result = binding.echoEmployee(emp);
65
66 if (!emp.equals(result)) {
67 System.out.println("Expected:");
68 System.out.println(printEmployee(emp));
69 System.out.println("Received:");
70 System.out.println(printEmployee(result));
71 }
72 assertTrue("Results did not match", result.equals(emp));
73
74 }
75 catch (java.rmi.RemoteException re) {
76 throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
77 }
78 }
79
80 String printEmployee(Employee e) {
81 String result = new String();
82
83 result += " ID: " + e.getID() + "\r\n";
84 result += " Salary: " + e.getSalary() + "\r\n";
85 Person p = e.getPerson();
86 result += " Person:\r\n";
87 result += " Name: " + p.getName() + "\r\n";
88 result += " Male: " + p.isMale() + "\r\n";
89
90 return result;
91 }
92
93
94 public static void main(String[] args) {
95 if (args.length == 1) {
96 try {
97 url = new URL(args[0]);
98 } catch (Exception e) {
99 }
100 }
101
102 junit.textui.TestRunner.run(new junit.framework.TestSuite(Compound2TestCase.class));
103 } // main
104 }
105