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 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 } } 105 106 | Popular Tags |