1 package test.wsdl.inout; 2 3 import org.apache.axis.holders.DateHolder; 4 import test.wsdl.inout.holders.AddressHolder; 5 import test.wsdl.inout.holders.PhoneHolder; 6 7 import javax.xml.rpc.holders.IntHolder ; 8 import javax.xml.rpc.holders.StringHolder ; 9 import java.util.Date ; 10 11 public class InoutSOAPBindingImpl implements Inout 12 { 13 public InoutSOAPBindingImpl() { 14 expectedAddress = new Address(); 15 expectedPhone = new Phone(); 16 expectedDate = new Date (2002-1900, 6, 23); 17 expectedAddress.setStreetNum(1); 18 expectedAddress.setStreetName("University Drive"); 19 expectedAddress.setCity("West Lafayette"); 20 expectedAddress.setState("IN"); 21 expectedAddress.setZip(47907); 22 expectedPhone.setAreaCode(765); 23 expectedPhone.setExchange("494"); 24 expectedPhone.setNumber("4900"); 25 expectedAddress.setPhoneNumber(expectedPhone); 26 27 returnAddress = new Address(); 28 returnPhone = new Phone(); 29 returnDate = new Date (1998-1900, 3, 9); 30 returnAddress.setStreetNum(555); 31 returnAddress.setStreetName("Monroe Street"); 32 returnAddress.setCity("Madison"); 33 returnAddress.setState("WI"); 34 returnAddress.setZip(54444); 35 returnPhone.setAreaCode(999); 36 returnPhone.setExchange("one"); 37 returnPhone.setNumber("two"); 38 returnAddress.setPhoneNumber(returnPhone); 39 } 40 41 private String printAddress (Address ad) { 42 String out; 43 if (ad == null) 44 out = "\t[ADDRESS NOT FOUND!]"; 45 else 46 out ="\t" + ad.getStreetNum () + " " + ad.getStreetName () + "\n\t" + ad.getCity () + ", " + ad.getState () + " " + ad.getZip () + "\n\t" + printPhone (ad.getPhoneNumber ()); 47 return out; 48 49 } 50 51 52 private String printPhone (Phone ph) 53 { 54 String out; 55 if (ph == null) 56 out = "[PHONE NUMBER NOT FOUND!}"; 57 else 58 out ="Phone: (" + ph.getAreaCode () + ") " + ph.getExchange () + "-" + ph.getNumber (); 59 return out; 60 } 61 62 public boolean equals (Address a1, Address a2) 63 { 64 try 65 { 66 return a1.getStreetNum() == a2.getStreetNum() && a1.getZip() == a2.getZip() && equals (a1.getPhoneNumber(), a2.getPhoneNumber()) && ((a1.getStreetName() == null && a2.getStreetName() == null) || a1.getStreetName().equals (a2.getStreetName())) && ((a1.getCity() == null && a2.getCity() == null) || a1.getCity().equals (a2.getCity())) && ((a1.getState() == null && a2.getState() == null) || a1.getState().equals (a2.getState())); 67 } 68 catch (Throwable t) 69 { 70 return false; 71 } 72 } 73 74 public boolean equals (Phone p1, Phone p2) 75 { 76 try 77 { 78 return p1.getAreaCode() == p2.getAreaCode() && ((p1.getExchange() == null && p2.getExchange() == null) || p1.getExchange().equals (p2.getExchange())) && ((p1.getNumber() == null && p2.getNumber() == null) || p1.getNumber().equals (p2.getNumber())); 79 } 80 catch (Throwable t) 81 { 82 return false; 83 } 84 } 85 86 private Phone expectedPhone; 87 private Address expectedAddress; 88 private Date expectedDate; 89 private int expectedNumber = 99; 90 91 private Phone returnPhone; 92 private Address returnAddress; 93 private Date returnDate; 94 private int returnNumber = 66; 95 96 public void out0Inout0In0 () throws org.apache.axis.AxisFault, TestFailed 97 { 98 } 99 100 public void out0Inout0In1 (String name) throws org.apache.axis.AxisFault, TestFailed 101 { 102 if (!"out0Inout0In1".equals (name)) 103 { 104 System.err.println ("Test failure: out0Inout0In1"); 105 System.err.println ("expected name = out0Inout0In1"); 106 System.err.println ("actual name = " + name); 107 throw new TestFailed (); 108 } 109 } 110 111 public void out0Inout0InMany (String name, Address address) throws org.apache.axis.AxisFault, TestFailed 112 { 113 if (!"out0Inout0InMany".equals (name) || !equals (address, expectedAddress)) 114 { 115 System.err.println ("Test failure: out0Inout0InMany"); 116 System.err.println ("expected name = out0Inout0InMany"); 117 System.err.println ("actual name = " + name); 118 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 119 System.err.println ("actual address =\n" + printAddress (address)); 120 throw new TestFailed (); 121 } 122 } 123 124 public void out0Inout1In0 (PhoneHolder phone) throws org.apache.axis.AxisFault, TestFailed 125 { 126 if (equals (phone.value, expectedPhone)) 127 phone.value = returnPhone; 128 else 129 { 130 System.err.println ("Test failure: out0Inout1In0"); 131 System.err.println ("expected phone = " + printPhone (expectedPhone)); 132 System.err.println ("actual phone = " + printPhone (phone.value)); 133 throw new TestFailed (); 134 } 135 } 136 137 public void out0Inout1In1 (StringHolder name, Address address) throws org.apache.axis.AxisFault, TestFailed 138 { 139 if (equals (address, expectedAddress) && "out0Inout1In1".equals (name.value)) 140 name.value = name.value + " yo ho ho!"; 141 else 142 { 143 System.err.println ("Test failure: out0Inout1In1"); 144 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 145 System.err.println ("actual address =\n" + printAddress (address)); 146 System.err.println ("expected name = out0Inout1In1"); 147 System.err.println ("actual name = " + name.value); 148 throw new TestFailed (); 149 } 150 } 151 152 public void out0Inout1InMany (String name, Address address, PhoneHolder phone) throws org.apache.axis.AxisFault, TestFailed 153 { 154 if ("out0Inout1InMany".equals (name) && equals (address, expectedAddress) && equals (phone.value, expectedPhone)) 155 phone.value = returnPhone; 156 else 157 { 158 System.err.println ("Test failure: out0Inout1InMany"); 159 System.err.println ("expected name = out0Inout1InMany"); 160 System.err.println ("actual name = " + name); 161 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 162 System.err.println ("actual address =\n" + printAddress (address)); 163 System.err.println ("expected phone = " + printPhone (expectedPhone)); 164 System.err.println ("actual phone = " + printPhone (phone.value)); 165 throw new TestFailed (); 166 } 167 } 168 169 public void out0InoutManyIn0 (StringHolder name, AddressHolder address) throws org.apache.axis.AxisFault, TestFailed 170 { 171 if ("out0InoutManyIn0".equals (name.value) && equals (address.value, expectedAddress)) 172 { 173 name.value = name.value + " yo ho ho!"; 174 address.value = returnAddress; 175 } 176 else 177 { 178 System.err.println ("Test failure: out0InoutManyIn0"); 179 System.err.println ("expected name = out0InoutManyIn0"); 180 System.err.println ("actual name = " + name.value); 181 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 182 System.err.println ("actual address =\n" + printAddress (address.value)); 183 throw new TestFailed (); 184 } 185 } 186 187 public void out0InoutManyIn1 (StringHolder name, AddressHolder address, Phone phone) throws org.apache.axis.AxisFault, TestFailed 188 { 189 if (equals (phone, expectedPhone) && "out0InoutManyIn1".equals (name.value) && equals (address.value, expectedAddress)) 190 { 191 name.value = name.value + " yo ho ho!"; 192 address.value = returnAddress; 193 } 194 else 195 { 196 System.err.println ("Test failure: out0InoutManyIn1"); 197 System.err.println ("expected phone = " + printPhone (expectedPhone)); 198 System.err.println ("actual phone = " + printPhone (phone)); 199 System.err.println ("expected name = out0InoutManyIn1"); 200 System.err.println ("actual name = " + name.value); 201 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 202 System.err.println ("actual address =\n" + printAddress (address.value)); 203 throw new TestFailed (); 204 } 205 } 206 207 208 public void out0InoutManyInMany (StringHolder name, AddressHolder address, Phone phone, int number) throws org.apache.axis.AxisFault, TestFailed 209 { 210 if (equals (phone, expectedPhone) && expectedNumber == number && "out0InoutManyInMany".equals (name.value) && equals (address.value, expectedAddress)) 211 { 212 name.value = name.value + " yo ho ho!"; 213 address.value = returnAddress; 214 } 215 else 216 { 217 System.err.println ("Test failure: out0InoutManyInMany"); 218 System.err.println ("expected phone = " + printPhone (expectedPhone)); 219 System.err.println ("actual phone = " + printPhone (phone)); 220 System.err.println ("expected number = " + expectedNumber); 221 System.err.println ("actual number = " + number); 222 System.err.println ("expected name = out0InoutManyInMany"); 223 System.err.println ("actual name = " + name.value); 224 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 225 System.err.println ("actual address =\n" + printAddress (address.value)); 226 throw new TestFailed (); 227 } 228 } 229 230 231 public int out1Inout0In0 () throws org.apache.axis.AxisFault, TestFailed 232 { 233 return returnNumber; 234 } 235 236 237 public int out1Inout0In1 (String name) throws org.apache.axis.AxisFault, TestFailed 238 { 239 if ("out1Inout0In1".equals (name)) 240 { 241 return returnNumber; 242 } 243 else 244 { 245 System.err.println ("Test failure: out1Inout0In1"); 246 System.err.println ("expected name = out1Inout0In1"); 247 System.err.println ("actual name = " + name); 248 throw new TestFailed (); 249 } 250 } 251 252 253 public int out1Inout0InMany (String name, Address address) throws org.apache.axis.AxisFault, TestFailed 254 { 255 if ("out1Inout0InMany".equals (name) && equals (address, expectedAddress)) 256 { 257 return returnNumber; 258 } 259 else 260 { 261 System.err.println ("Test failure: out1Inout0InMany"); 262 System.err.println ("expected name = out1Inout0InMany"); 263 System.err.println ("actual name = " + name); 264 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 265 System.err.println ("actual address =\n" + printAddress (address)); 266 throw new TestFailed (); 267 } 268 } 269 270 public Address out1Inout1In0 (StringHolder name) throws org.apache.axis.AxisFault, TestFailed 271 { 272 if ("out1Inout1In0".equals (name.value)) 273 { 274 name.value = name.value + " yo ho ho!"; 275 return returnAddress; 276 } 277 else 278 { 279 System.err.println ("Test failure: out1Inout1In0"); 280 System.err.println ("expected name = out1Inout1In0"); 281 System.err.println ("actual name = " + name.value); 282 throw new TestFailed (); 283 } 284 } 285 286 public String out1Inout1In1 (StringHolder name, Address address) throws org.apache.axis.AxisFault, TestFailed 287 { 288 if (equals (address, expectedAddress) && "out1Inout1In1".equals (name.value)) 289 { 290 name.value = name.value + " yo ho ho!"; 291 return "out1Inout1In1 arghhh!"; 292 } 293 else 294 { 295 System.err.println ("Test failure: out1Inout1In1"); 296 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 297 System.err.println ("actual address =\n" + printAddress (address)); 298 System.err.println ("expected name = out1Inout1In1"); 299 System.err.println ("actual name = " + name.value); 300 throw new TestFailed (); 301 } 302 } 303 304 305 public String out1Inout1InMany (StringHolder name, Address address, Phone phone) throws org.apache.axis.AxisFault, TestFailed 306 { 307 if (equals (address, expectedAddress) && equals (phone, expectedPhone) && "out1Inout1InMany".equals (name.value)) 308 { 309 name.value = name.value + " yo ho ho!"; 310 return "out1Inout1InMany arghhh!"; 311 } 312 else 313 { 314 System.err.println ("Test failure: out1Inout1InMany"); 315 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 316 System.err.println ("actual address =\n" + printAddress (address)); 317 System.err.println ("expected phone = " + printPhone (expectedPhone)); 318 System.err.println ("actual phone = " + printPhone (phone)); 319 System.err.println ("expected name = out1Inout1InMany"); 320 System.err.println ("actual name = " + name.value); 321 throw new TestFailed (); 322 } 323 } 324 325 326 public String out1InoutManyIn0 (StringHolder name, AddressHolder address) throws org.apache.axis.AxisFault, TestFailed 327 { 328 if ("out1InoutManyIn0".equals (name.value) && equals (address.value, expectedAddress)) 329 { 330 name.value = name.value + " yo ho ho!"; 331 address.value = returnAddress; 332 return "out1InoutManyIn0 arghhh!"; 333 } 334 else 335 { 336 System.err.println ("Test failure: out1InoutManyIn0"); 337 System.err.println ("expected name = out1InoutManyIn0"); 338 System.err.println ("actual name = " + name.value); 339 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 340 System.err.println ("actual address =\n" + printAddress (address.value)); 341 throw new TestFailed (); 342 } 343 } 344 345 346 public String out1InoutManyIn1 (StringHolder name, AddressHolder address, Phone phone) throws org.apache.axis.AxisFault, TestFailed 347 { 348 if (equals (phone, expectedPhone) && "out1InoutManyIn1".equals (name.value) && equals (address.value, expectedAddress)) 349 { 350 name.value = name.value + " yo ho ho!"; 351 address.value = returnAddress; 352 return "out1InoutManyIn1 arghhh!"; 353 } 354 else 355 { 356 System.err.println ("Test failure: out1InoutManyIn1"); 357 System.err.println ("expected phone = " + printPhone (expectedPhone)); 358 System.err.println ("actual phone = " + printPhone (phone)); 359 System.err.println ("expected name = out1InoutManyIn1"); 360 System.err.println ("actual name = " + name.value); 361 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 362 System.err.println ("actual address =\n" + printAddress (address.value)); 363 throw new TestFailed (); 364 } 365 } 366 367 368 public String out1InoutManyInMany (StringHolder name, AddressHolder address, Phone phone, int number) throws org.apache.axis.AxisFault, TestFailed 369 { 370 if (equals (phone, expectedPhone) && expectedNumber == number && "out1InoutManyInMany".equals (name.value) && equals (address.value, expectedAddress)) 371 { 372 name.value = name.value + " yo ho ho!"; 373 address.value = returnAddress; 374 return "out1InoutManyInMany arghhh!"; 375 } 376 else 377 { 378 System.err.println ("Test failure: out1InoutManyInMany"); 379 System.err.println ("expected phone = " + printPhone (expectedPhone)); 380 System.err.println ("actual phone = " + printPhone (phone)); 381 System.err.println ("expected number = " + expectedNumber); 382 System.err.println ("actual number = " + number); 383 System.err.println ("expected name = out1InoutManyInMany"); 384 System.err.println ("actual name = " + name.value); 385 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 386 System.err.println ("actual address =\n" + printAddress (address.value)); 387 throw new TestFailed (); 388 } 389 } 390 391 392 public void outManyInout0In0 (StringHolder name, AddressHolder address) throws org.apache.axis.AxisFault, TestFailed 393 { 394 if (name.value == null && address.value == null) { 395 name.value = " arghhh!"; 396 address.value = returnAddress; 397 } 398 else 399 throw new TestFailed (); 400 } 401 402 403 public void outManyInout0In1 (String name, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 404 { 405 if ("outManyInout0In1".equals (name) && otherName.value == null) 406 { 407 number.value = returnNumber; 408 otherName.value = " yo ho ho!"; 409 } 410 else 411 { 412 System.err.println ("Test failure: outManyInout0In1"); 413 System.err.println ("expected name = outManyInout0In1"); 414 System.err.println ("actual name = " + name); 415 throw new TestFailed (); 416 } 417 } 418 419 420 public void outManyInout0InMany (String name, Address address, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 421 { 422 if ("outManyInout0InMany".equals (name) && equals (address, expectedAddress) && otherName.value == null) 423 { 424 number.value = returnNumber; 425 otherName.value = " yo ho ho!"; 426 } 427 else 428 { 429 System.err.println ("Test failure: outManyInout0InMany"); 430 System.err.println ("expected name = outManyInout0InMany"); 431 System.err.println ("actual name = " + name); 432 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 433 System.err.println ("actual address =\n" + printAddress (address)); 434 throw new TestFailed (); 435 } 436 } 437 438 439 public void outManyInout1In0 (StringHolder name, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 440 { 441 if ("outManyInout1In0".equals (name.value) && otherName.value == null) 442 { 443 number.value = returnNumber; 444 name.value = name.value + " yo ho ho!"; 445 otherName.value = " yo ho ho!"; 446 } 447 else 448 { 449 System.err.println ("Test failure: outManyInout1In0"); 450 System.err.println ("expected name = outManyInout1In0"); 451 System.err.println ("actual name = " + name.value); 452 throw new TestFailed (); 453 } 454 } 455 456 457 public void outManyInout1In1 (StringHolder name, Address address, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 458 { 459 if (equals (address, expectedAddress) && "outManyInout1In1".equals (name.value) && otherName.value == null) 460 { 461 number.value = returnNumber; 462 name.value = name.value + " yo ho ho!"; 463 otherName.value = " yo ho ho!"; 464 } 465 else 466 { 467 System.err.println ("Test failure: outManyInout1In1"); 468 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 469 System.err.println ("actual address =\n" + printAddress (address)); 470 System.err.println ("expected name = out1InoutManyInMany"); 471 System.err.println ("actual name = " + name.value); 472 System.err.println ("expected otherName = null"); 473 System.err.println ("actual otherName = " + otherName.value); 474 throw new TestFailed (); 475 } 476 } 477 478 479 public void outManyInout1InMany (String name, Address address, PhoneHolder phone, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 480 { 481 if ("outManyInout1InMany".equals (name) && equals (address, expectedAddress) && equals (phone.value, expectedPhone) && otherName.value == null) 482 { 483 phone.value = returnPhone; 484 number.value = returnNumber; 485 otherName.value = " yo ho ho!"; 486 } 487 else 488 { 489 System.err.println ("Test failure: outManyInout1InMany"); 490 System.err.println ("expected name = outManyInout1InMany"); 491 System.err.println ("actual name = " + name); 492 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 493 System.err.println ("actual address =\n" + printAddress (address)); 494 System.err.println ("expected phone = " + printPhone (expectedPhone)); 495 System.err.println ("actual phone = " + printPhone (phone.value)); 496 throw new TestFailed (); 497 } 498 } 499 500 501 public void outManyInoutManyIn0 (StringHolder name, AddressHolder address, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 502 { 503 if ("outManyInoutManyIn0".equals (name.value) && equals (address.value, expectedAddress) && otherName.value == null) 504 { 505 name.value = name.value + " yo ho ho!"; 506 address.value = returnAddress; 507 number.value = returnNumber; 508 otherName.value = " yo ho ho!"; 509 } 510 else 511 { 512 System.err.println ("Test failure: outManyInoutManyIn0"); 513 System.err.println ("expected name = outManyInoutManyIn0"); 514 System.err.println ("actual name = " + name.value); 515 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 516 System.err.println ("actual address =\n" + printAddress (address.value)); 517 throw new TestFailed (); 518 } 519 } 520 521 522 public void outManyInoutManyIn1 (StringHolder name, AddressHolder address, Phone phone, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 523 { 524 if (equals (phone, expectedPhone) && "outManyInoutManyIn1".equals (name.value) && equals (address.value, expectedAddress) && otherName.value == null) 525 { 526 name.value = name.value + " yo ho ho!"; 527 address.value = returnAddress; 528 number.value = returnNumber; 529 otherName.value = " yo ho ho!"; 530 } 531 else 532 { 533 System.err.println ("Test failure: outManyInoutManyIn1"); 534 System.err.println ("expected phone = " + printPhone (expectedPhone)); 535 System.err.println ("actual phone = " + printPhone (phone)); 536 System.err.println ("expected name = out1InoutManyInMany"); 537 System.err.println ("actual name = " + name.value); 538 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 539 System.err.println ("actual address =\n" + printAddress (address.value)); 540 throw new TestFailed (); 541 } 542 } 543 544 545 public void outManyInoutManyInMany (StringHolder name, AddressHolder address, Phone phone, int otherNumber, IntHolder number, StringHolder otherName) throws org.apache.axis.AxisFault, TestFailed 546 { 547 if (equals (phone, expectedPhone) && expectedNumber == otherNumber && "outManyInoutManyInMany".equals (name.value) && equals (address.value, expectedAddress) && otherName.value == null) 548 { 549 name.value = name.value + " yo ho ho!"; 550 address.value = returnAddress; 551 number.value = returnNumber; 552 otherName.value = " yo ho ho!"; 553 } 554 else 555 { 556 System.err.println ("Test failure: outManyInoutManyInMany"); 557 System.err.println ("expected phone = " + printPhone (expectedPhone)); 558 System.err.println ("actual phone = " + printPhone (phone)); 559 System.err.println ("expected number = " + expectedNumber); 560 System.err.println ("actual number = " + otherNumber); 561 System.err.println ("expected name = outManyInoutManyInMany"); 562 System.err.println ("actual name = " + name.value); 563 System.err.println ("expected address =\n" + printAddress (expectedAddress)); 564 System.err.println ("actual address =\n" + printAddress (address.value)); 565 throw new TestFailed (); 566 } 567 } 568 public void dateInout (DateHolder dateHolder) throws org.apache.axis.AxisFault, TestFailed 569 { 570 Date inDate = dateHolder.value; 571 if (inDate.equals(expectedDate)) 572 { 573 dateHolder.value = returnDate; 574 } else { 575 System.err.println ("Test failure: dateInout"); 576 System.err.println ("expected Date = " + expectedDate); 577 System.err.println ("actual Date = " + inDate); 578 throw new TestFailed (); 579 } 580 } 581 582 } 583 | Popular Tags |