| 1 |
/** |
| 2 |
* AddrBookServiceImplServiceTestCase.java |
| 3 |
* |
| 4 |
* This file was auto-generated from WSDL |
| 5 |
* by the Apache Axis #axisVersion# #today# WSDL2Java emitter. |
| 6 |
*/ |
| 7 |
|
| 8 |
package test.wsdl.arrays3; |
| 9 |
|
| 10 |
import junit.framework.AssertionFailedError; |
| 11 |
|
| 12 |
public class AddrBookServiceImplServiceTestCase extends junit.framework.TestCase { |
| 13 |
public AddrBookServiceImplServiceTestCase(java.lang.String name) { |
| 14 |
super(name); |
| 15 |
} |
| 16 |
|
| 17 |
public void testAddressBookWSDL() throws Exception { |
| 18 |
javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); |
| 19 |
java.net.URL url = new java.net.URL(new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getarrays3Address() + "?WSDL"); |
| 20 |
javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getServiceName()); |
| 21 |
assertTrue(service != null); |
| 22 |
} |
| 23 |
|
| 24 |
public void testFunctional() throws Exception { |
| 25 |
test.wsdl.arrays3.testclient.Arrays3SoapBindingStub binding; |
| 26 |
try { |
| 27 |
binding = (test.wsdl.arrays3.testclient.Arrays3SoapBindingStub) |
| 28 |
new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getarrays3(); |
| 29 |
} |
| 30 |
catch (javax.xml.rpc.ServiceException jre) { |
| 31 |
if(jre.getLinkedCause()!=null) |
| 32 |
jre.getLinkedCause().printStackTrace(); |
| 33 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 34 |
} |
| 35 |
assertNotNull("binding is null", binding); |
| 36 |
|
| 37 |
test.wsdl.arrays3.testclient.Phone ph1 = new test.wsdl.arrays3.testclient.Phone(); |
| 38 |
ph1.setAreaCode(765); |
| 39 |
ph1.setExchange("494"); |
| 40 |
ph1.setNumber("4900"); |
| 41 |
|
| 42 |
test.wsdl.arrays3.testclient.Phone ph2 = new test.wsdl.arrays3.testclient.Phone(); |
| 43 |
ph2.setAreaCode(765); |
| 44 |
ph2.setExchange("494"); |
| 45 |
ph2.setNumber("4901"); |
| 46 |
|
| 47 |
test.wsdl.arrays3.testclient.Phone ph3 = new test.wsdl.arrays3.testclient.Phone(); |
| 48 |
ph3.setAreaCode(765); |
| 49 |
ph3.setExchange("494"); |
| 50 |
ph3.setNumber("4902"); |
| 51 |
|
| 52 |
test.wsdl.arrays3.testclient.StateType state = new test.wsdl.arrays3.testclient.StateType(); |
| 53 |
state.setState("IN"); |
| 54 |
|
| 55 |
test.wsdl.arrays3.testclient.Address addr = new test.wsdl.arrays3.testclient.Address(); |
| 56 |
addr.setCity("West Lafayette"); |
| 57 |
addr.setState(state); |
| 58 |
addr.setStreetName("University Drive"); |
| 59 |
addr.setStreetNum(1); |
| 60 |
addr.setZip(47907); |
| 61 |
addr.setPhoneNumber(ph1); |
| 62 |
addr.setOtherPhones(new test.wsdl.arrays3.testclient.Phone[] { ph2, ph3}); |
| 63 |
|
| 64 |
test.wsdl.arrays3.testclient.Address[] addrs = null; |
| 65 |
|
| 66 |
addrs = binding.getAddressFromNames(null); |
| 67 |
assertNull("addrs is not null", addrs); |
| 68 |
// if (addrs != null) System.out.println("addrs.length = " + addrs.length); |
| 69 |
|
| 70 |
addrs = binding.getAddressFromNames(new String[] { }); |
| 71 |
assertNull("addrs is not null", addrs); |
| 72 |
// if (addrs != null) System.out.println("addrs.length = " + addrs.length); |
| 73 |
|
| 74 |
addrs = binding.getAddressFromNames(new String[] { "unknown", "unregistered" }); |
| 75 |
assertEquals("addrs.length should be 2", addrs.length, 2); |
| 76 |
System.out.println("addrs.length = " + addrs.length); |
| 77 |
|
| 78 |
|
| 79 |
binding.addEntry("Purdue Boilermaker", addr); |
| 80 |
test.wsdl.arrays3.testclient.Address retAddr1 = |
| 81 |
binding.getAddressFromName("Purdue Boilermaker"); |
| 82 |
|
| 83 |
binding.addEntry("Boilermaker Purdue", addr); |
| 84 |
test.wsdl.arrays3.testclient.Address retAddrs[] = |
| 85 |
binding.getAddressFromNames(new String[] { "Purdue Boilermaker", "Boilermaker Purdue" }); |
| 86 |
|
| 87 |
retAddrs = binding.echoAddresses(null); |
| 88 |
assertNull("retAddrs is not null", retAddrs); |
| 89 |
|
| 90 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { }); |
| 91 |
assertNull("retAddrs is not null", retAddrs); |
| 92 |
|
| 93 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr }); |
| 94 |
assertEquals("retAddrs.length should be 1", 1, retAddrs.length); |
| 95 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[0])); |
| 96 |
|
| 97 |
addr.setOtherPhones(null); |
| 98 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr }); |
| 99 |
assertEquals("retAddrs.length should be 1", 1, retAddrs.length); |
| 100 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[0])); |
| 101 |
assertNull("retAddrs[0].getOtherPhones() should be null", retAddrs[0].getOtherPhones()); |
| 102 |
test.wsdl.arrays3.testclient.Phone[] arrph = new test.wsdl.arrays3.testclient.Phone[] { }; |
| 103 |
addr.setOtherPhones(arrph); |
| 104 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr }); |
| 105 |
assertEquals("retAddrs.length should be 1", 1, retAddrs.length); |
| 106 |
|
| 107 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[0])); |
| 108 |
//assertNull("retAddrs[0].getOtherPhones() should be null", retAddrs[0].getOtherPhones()); |
| 109 |
|
| 110 |
addr.setOtherPhones(arrph); |
| 111 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr }); |
| 112 |
assertEquals("addrs.length should be 1", 1, retAddrs.length); |
| 113 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[0])); |
| 114 |
|
| 115 |
retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr, addr }); |
| 116 |
assertEquals("addrs.length should be 2", 2, retAddrs.length); |
| 117 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[0])); |
| 118 |
assertTrue("addr does not match", compareAddress(addr, retAddrs[1])); |
| 119 |
|
| 120 |
test.wsdl.arrays3.testclient.Address[] retAddrs2 = binding.echoAddresses(retAddrs); |
| 121 |
assertEquals("addrs.length should be 2", 2, retAddrs2.length); |
| 122 |
assertTrue("addr does not match", compareAddress(retAddrs[0], retAddrs2[0])); |
| 123 |
assertTrue("addr does not match", compareAddress(retAddrs[1], retAddrs2[1])); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
public boolean compareAddress(test.wsdl.arrays3.testclient.Address addr1, test.wsdl.arrays3.testclient.Address addr2) { |
| 128 |
if (addr1 == null && addr2 != null) { |
| 129 |
throw new AssertionFailedError(""); |
| 130 |
} |
| 131 |
if (addr1 != null && addr2 == null) { |
| 132 |
throw new AssertionFailedError(""); |
| 133 |
} |
| 134 |
if (addr1 == null && addr2 == null) { |
| 135 |
return true; |
| 136 |
} |
| 137 |
|
| 138 |
if (!addr1.getCity().equals(addr2.getCity())) { |
| 139 |
throw new AssertionFailedError(""); |
| 140 |
} |
| 141 |
|
| 142 |
if (!addr1.getStreetName().equals(addr2.getStreetName())) { |
| 143 |
throw new AssertionFailedError(""); |
| 144 |
} |
| 145 |
|
| 146 |
if (addr1.getStreetNum() != addr2.getStreetNum()) { |
| 147 |
throw new AssertionFailedError(""); |
| 148 |
} |
| 149 |
|
| 150 |
if (addr1.getZip() != addr2.getZip()) { |
| 151 |
throw new AssertionFailedError(""); |
| 152 |
} |
| 153 |
|
| 154 |
if (!comparePhone(addr1.getPhoneNumber(), addr2.getPhoneNumber())) { |
| 155 |
throw new AssertionFailedError(""); |
| 156 |
} |
| 157 |
|
| 158 |
if (!compareStateType(addr1.getState(), addr2.getState())) { |
| 159 |
throw new AssertionFailedError(""); |
| 160 |
} |
| 161 |
|
| 162 |
if (!comparePhoneArray(addr1.getOtherPhones(), addr2.getOtherPhones())) { |
| 163 |
throw new AssertionFailedError(""); |
| 164 |
} |
| 165 |
|
| 166 |
return true; |
| 167 |
} |
| 168 |
|
| 169 |
public boolean comparePhoneArray(test.wsdl.arrays3.testclient.Phone[] arr1, |
| 170 |
test.wsdl.arrays3.testclient.Phone[] arr2) { |
| 171 |
if (arr1 == null && arr2 != null) { |
| 172 |
throw new AssertionFailedError(""); |
| 173 |
} |
| 174 |
if (arr1 != null && arr2 == null) { |
| 175 |
throw new AssertionFailedError(""); |
| 176 |
} |
| 177 |
if (arr1 == null && arr2 == null) { |
| 178 |
return true; |
| 179 |
} |
| 180 |
if (arr1.length != arr2.length) { |
| 181 |
throw new AssertionFailedError(""); |
| 182 |
} |
| 183 |
for (int i = 0; i < arr1.length; i++) { |
| 184 |
if (comparePhone(arr1[i], arr2[i]) == false) { |
| 185 |
throw new AssertionFailedError(""); |
| 186 |
} |
| 187 |
} |
| 188 |
return true; |
| 189 |
} |
| 190 |
|
| 191 |
public boolean comparePhone(test.wsdl.arrays3.testclient.Phone phone1, test.wsdl.arrays3.testclient.Phone phone2) { |
| 192 |
if (phone1 == null && phone2 != null) { |
| 193 |
throw new AssertionFailedError(""); |
| 194 |
} |
| 195 |
if (phone1 != null && phone2 == null) { |
| 196 |
throw new AssertionFailedError(""); |
| 197 |
} |
| 198 |
if (phone1 == null && phone2 == null) { |
| 199 |
return true; |
| 200 |
} |
| 201 |
|
| 202 |
if (phone1.getAreaCode() != phone2.getAreaCode()) { |
| 203 |
throw new AssertionFailedError(""); |
| 204 |
} |
| 205 |
|
| 206 |
if (!phone1.getExchange().equals(phone2.getExchange())) { |
| 207 |
throw new AssertionFailedError(""); |
| 208 |
} |
| 209 |
if (!phone1.getNumber().equals(phone2.getNumber())) { |
| 210 |
throw new AssertionFailedError(""); |
| 211 |
} |
| 212 |
|
| 213 |
return true; |
| 214 |
} |
| 215 |
|
| 216 |
public boolean compareStateType(test.wsdl.arrays3.testclient.StateType st1, test.wsdl.arrays3.testclient.StateType st2) { |
| 217 |
if (st1 == null && st2 != null) { |
| 218 |
throw new AssertionFailedError(""); |
| 219 |
} |
| 220 |
if (st1 != null && st2 == null) { |
| 221 |
throw new AssertionFailedError(""); |
| 222 |
} |
| 223 |
if (st1 == null && st2 == null) { |
| 224 |
return true; |
| 225 |
} |
| 226 |
if (!st1.getState().equals(st2.getState())) { |
| 227 |
throw new AssertionFailedError(""); |
| 228 |
} |
| 229 |
return true; |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
} |