1 57 58 package shop; 59 60 import java.util.Collection ; 61 import java.util.HashMap ; 62 import java.util.Iterator ; 63 64 import junit.framework.Test; 65 import junit.framework.TestCase; 66 import junit.framework.TestSuite; 67 68 import org.apache.wsif.WSIFMessage; 69 import org.apache.wsif.WSIFOperation; 70 import org.apache.wsif.WSIFPort; 71 import org.apache.wsif.WSIFService; 72 import org.apache.wsif.WSIFServiceFactory; 73 import util.TestUtilities; 74 75 86 87 public class ShoppingCartTest extends TestCase { 88 89 private boolean debugMode = true; 90 private String wsdlPath; 92 93 97 public static void main(java.lang.String [] args) { 98 TestUtilities.startListeners(); 99 junit.textui.TestRunner.run (suite()); 100 TestUtilities.stopListeners(); 101 } 102 103 public static Test suite() { 104 return new TestSuite(ShoppingCartTest.class); 105 } 106 107 public ShoppingCartTest(String arg0) { 108 super(arg0); 109 } 110 111 protected void setUp() { 112 wsdlPath = TestUtilities.getWsdlPath("java\\test\\shop"); 113 } 114 115 private void printOrder(Order order) { 116 HashMap items = null; 117 Iterator it = null; 118 Collection entries = null; 119 Item item = null; 120 Object obj = null; 121 122 debug("\nOrder " + order.getConfirmationNumber()); 123 items = order.getItems(); 124 entries = items.values(); 125 it = entries.iterator(); 126 while (it.hasNext()) { 127 debug(it.next()); 128 } 129 } 130 131 private void printOrders(Orders orders) { 132 int size = orders.size(); 133 134 for (int i = 0; i < size; i++) { 135 printOrder((Order) orders.get(i)); 136 } 137 } 138 139 142 public void testWSDL_Java() throws Exception { 143 debug("\n*** TEST JAVA BINDING ***"); 144 145 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 146 WSIFService service = 147 factory 148 .getService( 149 wsdlPath + "ShoppingCartAll.wsdl", 150 "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 151 "ShoppingCart_JavaService", "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 154 "ShoppingCart_JavaPortType" ); 157 158 Iterator it = service.getAvailablePortNames(); 159 { 160 System.out.println("Available ports for the service are: "); 161 while (it.hasNext()) { 162 System.out.println((String ) it.next()); 163 } 164 } 165 166 WSIFPort port = service.getPort(); 167 168 WSIFOperation operation; 169 WSIFMessage inputMessage; 170 WSIFMessage outputMessage; 171 WSIFMessage faultMessage; 172 173 String customerNumber; 174 String tempString; 175 Address address; 176 ShoppingCart_Java shoppingCart; 177 Item item; 178 CreditCardInfo creditCardInfo; 179 AirMilesContainer airMilesContainer; 180 Integer currentTotal = null; 181 Long orderConfirmationNumber; 182 Integer itemQuantity; 183 Object part; 184 boolean operationSucceeded; 185 186 operation = port.createOperation("createOperation"); 188 inputMessage = operation.createInputMessage(); 189 outputMessage = operation.createOutputMessage(); 190 faultMessage = operation.createFaultMessage(); 191 192 debug("\n---> Invocation: public ShoppingCart_Java(String firstName, String lastName, Address address, String customerNumber)"); 193 194 tempString = "Albert"; 195 inputMessage.setObjectPart("firstName", tempString); 196 197 tempString = "Einstein"; 198 inputMessage.setObjectPart("lastName", tempString); 199 200 address = new Address("Berlin", "Unter den Linden"); 201 inputMessage.setObjectPart("address", address); 202 203 customerNumber = "AE001"; 204 inputMessage.setObjectPart("customerNumber", customerNumber); 205 206 operationSucceeded = 207 operation.executeRequestResponseOperation( 208 inputMessage, 209 outputMessage, 210 faultMessage); 211 212 assertTrue("Failed to create a ShoppingCart", operationSucceeded); 213 214 operation = port.createOperation("addItemOperation"); 216 inputMessage = operation.createInputMessage(); 217 outputMessage = operation.createOutputMessage(); 218 faultMessage = operation.createFaultMessage(); 219 220 debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)"); 221 222 tempString = "100123"; 223 inputMessage.setObjectPart("itemNumber", tempString); 224 225 item = new Item(); 226 228 tempString = "Pocket calculator"; 229 inputMessage.setObjectPart("itemName", tempString); 230 231 itemQuantity = new Integer (1); 232 inputMessage.setObjectPart("itemQuantity", itemQuantity); 233 234 operationSucceeded = 235 operation.executeRequestResponseOperation( 236 inputMessage, 237 outputMessage, 238 faultMessage); 239 240 assertTrue("addItem test failed", operationSucceeded); 241 242 if (operationSucceeded) { 243 assertTrue("Part is not an Item!!!", 244 outputMessage.getObjectPart("item") instanceof Item); 245 debug(outputMessage.getObjectPart("item")); 246 } else { 247 } 249 250 operation = port.createOperation("addItemOperation"); 252 inputMessage = operation.createInputMessage(); 253 outputMessage = operation.createOutputMessage(); 254 faultMessage = operation.createFaultMessage(); 255 256 debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)"); 257 258 tempString = "234123"; 259 inputMessage.setObjectPart("itemNumber", tempString); 260 261 item = new Item(); 262 inputMessage.setObjectPart("item", item); 263 264 tempString = "Pencil"; 265 inputMessage.setObjectPart("itemName", tempString); 266 267 itemQuantity = new Integer (12); 268 inputMessage.setObjectPart("itemQuantity", itemQuantity); 269 270 operationSucceeded = 271 operation.executeRequestResponseOperation( 272 inputMessage, 273 outputMessage, 274 faultMessage); 275 276 assertTrue( 277 "addItem succeeded when it should have thrown a outOfStockException", 278 !operationSucceeded); 279 280 if (operationSucceeded) { 281 debug(outputMessage.getObjectPart("item")); 282 } else { 283 assertNotNull( 284 "outputMessage should have contained outOfStockException", 285 faultMessage.getObjectPart("outOfStockException")); 286 287 300 } 301 302 operation = port.createOperation("addItemOperation"); 304 inputMessage = operation.createInputMessage(); 305 outputMessage = operation.createOutputMessage(); 306 faultMessage = operation.createFaultMessage(); 307 308 debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)"); 309 310 inputMessage.setObjectPart("itemNumber", "234123"); 311 312 item = new Item(); 313 inputMessage.setObjectPart("item", item); 314 315 inputMessage.setObjectPart("itemName", "Pencil"); 316 317 inputMessage.setIntPart("itemQuantity", 8); 318 319 operationSucceeded = 320 operation.executeRequestResponseOperation( 321 inputMessage, 322 outputMessage, 323 faultMessage); 324 325 assertTrue("addItem failed when it should have succeeded", operationSucceeded); 326 327 344 345 operation = port.createOperation("submitOrderOperation"); 347 inputMessage = operation.createInputMessage(); 348 outputMessage = operation.createOutputMessage(); 349 faultMessage = operation.createFaultMessage(); 350 351 debug("\n---> Invocation: public long submitOrder(CreditCardInfo creditCardInfo, AirMilesContainer airMilesContainer)"); 352 353 creditCardInfo = new CreditCardInfo(); 354 inputMessage.setObjectPart("creditCardInfo", creditCardInfo); 355 356 airMilesContainer = new AirMilesContainer(); 357 inputMessage.setObjectPart("airMilesContainer", airMilesContainer); 358 359 inputMessage.setLongPart("orderConfirmationNumber", 0); 360 361 operationSucceeded = 362 operation.executeRequestResponseOperation( 363 inputMessage, 364 outputMessage, 365 faultMessage); 366 367 assertTrue( 368 "submitOrderOperation failed when it should have succeeded.", 369 operationSucceeded); 370 371 debug( 372 "order confirmation no. = " 373 + outputMessage.getObjectPart("orderConfirmationNumber")); 374 debug(airMilesContainer); 375 376 operation = port.createOperation("queryOrdersOperation"); 378 inputMessage = operation.createInputMessage(); 379 outputMessage = operation.createOutputMessage(); 380 faultMessage = operation.createFaultMessage(); 381 382 debug("\n---> Invocation: public static Orders queryOrders(String customerNumber)"); 383 384 inputMessage.setObjectPart("customerNumber", "AE001"); 385 386 operationSucceeded = 387 operation.executeRequestResponseOperation( 388 inputMessage, 389 outputMessage, 390 faultMessage); 391 392 assertTrue( 393 "queryOrdersOperation failed when it should have succeeded.", 394 operationSucceeded); 395 396 printOrders((Orders) outputMessage.getObjectPart("orders")); 397 398 } 400 401 404 public void testWSDL_EJB() throws Exception { 405 if (!TestUtilities.areWeTesting("ejb")) 406 return; 407 408 debug("\n*** TEST EJB BINDING ***"); 409 410 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 411 WSIFService service = 412 factory.getService(wsdlPath + "ShoppingCartAll.wsdl", "http://www.shoppingcart.com/definitions/ShoppingCartInterface", "ShoppingCart_EJBService", "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 416 "ShoppingCart_EJBPortType" ); 419 420 Iterator it = service.getAvailablePortNames(); 421 { 422 System.out.println("Available ports for the service are: "); 423 while (it.hasNext()) { 424 System.out.println((String ) it.next()); 425 } 426 } 427 428 WSIFPort port = service.getPort(); 429 WSIFOperation operation; 430 WSIFMessage inputMessage; 431 WSIFMessage outputMessage; 432 WSIFMessage faultMessage; 433 434 String customerNumber; 435 String tempString; 436 Address address; 437 ShoppingCart shoppingCart; 438 Item item = null; 439 CreditCardInfo creditCardInfo; 440 AirMilesContainer airMilesContainer; 441 Integer currentTotal = null; 442 Long orderConfirmationNumber; 443 Integer itemQuantity; 444 Object part; 445 boolean operationSucceeded; 446 447 operation = port.createOperation("createOperation"); 449 inputMessage = operation.createInputMessage(); 450 outputMessage = operation.createOutputMessage(); 451 faultMessage = operation.createFaultMessage(); 452 453 debug("\n---> Invocation (home): public ShoppingCart create(java.lang.String firstName, java.lang.String lastName, org.apache.wsif.ejb.sample.shop.Address address, java.lang.String customerNumber) throws org.apache.wsif.ejb.sample.shop.CreateException, javax.ejb.CreateException, java.rmi.RemoteException"); 454 455 inputMessage.setObjectPart("firstName", "Albert"); 456 457 inputMessage.setObjectPart("lastName", "Einstein"); 458 459 address = new Address("Berlin", "Unter den Linden"); 460 inputMessage.setObjectPart("address", address); 461 462 inputMessage.setObjectPart("customerNumber", "AE001"); 463 464 operationSucceeded = 465 operation.executeRequestResponseOperation( 466 inputMessage, 467 outputMessage, 468 faultMessage); 469 470 assertTrue("createOperation failed!!", operationSucceeded); 471 472 operation = port.createOperation("addItemOperation"); 474 inputMessage = operation.createInputMessage(); 475 outputMessage = operation.createOutputMessage(); 476 faultMessage = operation.createFaultMessage(); 477 478 debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException"); 479 480 inputMessage.setObjectPart("itemNumber", "100123"); 481 482 inputMessage.setObjectPart("itemName", "Pocket calculator"); 483 484 inputMessage.setIntPart("itemQuantity", 1); 485 486 operationSucceeded = 487 operation.executeRequestResponseOperation( 488 inputMessage, 489 outputMessage, 490 faultMessage); 491 492 assertTrue("addItemOperation failed!!", operationSucceeded); 493 494 if (operationSucceeded) { 495 assertTrue( 496 "addItemOperation (EJB) did not return an Item Object!!", 497 outputMessage.getObjectPart("item") instanceof Item); 498 debug(outputMessage.getObjectPart("item")); 499 } else { 500 part = faultMessage.getObjectPart("invalidItemException"); 501 if (part != null) { 502 debug(faultMessage.getName() + ":\n" + part); 503 } else { 504 part = faultMessage.getObjectPart("outOfStockException"); 505 if (part != null) { 506 debug(faultMessage.getName() + ":\n" + part); 507 } else { 508 debug("ERROR: Unknown fault message!"); 509 } 510 } 511 } 512 513 operation = port.createOperation("addItemOperation"); 515 inputMessage = operation.createInputMessage(); 516 outputMessage = operation.createOutputMessage(); 517 faultMessage = operation.createFaultMessage(); 518 519 debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException"); 520 521 inputMessage.setObjectPart("itemNumber", "234123"); 522 523 inputMessage.setObjectPart("itemName", "Pencil"); 524 525 inputMessage.setIntPart("itemQuantity", 12); 526 527 operationSucceeded = 528 operation.executeRequestResponseOperation( 529 inputMessage, 530 outputMessage, 531 faultMessage); 532 533 assertTrue( 534 "addItemOperation succeeded when it should have thrown an outOfStockException", 535 !operationSucceeded); 536 537 if (operationSucceeded) { 538 assertTrue( 539 "addItemOperation (EJB) did not return an Item Object!!", 540 outputMessage.getObjectPart("item") instanceof Item); 541 debug(outputMessage.getObjectPart("item")); 542 } else { 543 assertNotNull( 544 "outputMessage should have contained outOfStockException", 545 faultMessage.getObjectPart("outOfStockException")); 546 547 559 } 560 561 operation = port.createOperation("addItemOperation"); 563 inputMessage = operation.createInputMessage(); 564 outputMessage = operation.createOutputMessage(); 565 faultMessage = operation.createFaultMessage(); 566 567 debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException"); 568 569 inputMessage.setObjectPart("itemNumber", "234123"); 570 571 inputMessage.setObjectPart("itemName", "Pencil"); 572 573 inputMessage.setIntPart("itemQuantity", 8); 574 575 operationSucceeded = 576 operation.executeRequestResponseOperation( 577 inputMessage, 578 outputMessage, 579 faultMessage); 580 581 assertTrue("addItemOperation failed!!", operationSucceeded); 582 583 if (operationSucceeded) { 584 assertTrue( 585 "addItemOperation (EJB) did not return an Item Object!!", 586 outputMessage.getObjectPart("item") instanceof Item); 587 debug(outputMessage.getObjectPart("item")); 588 } else { 589 part = faultMessage.getObjectPart("invalidItemException"); 590 if (part != null) { 591 debug(faultMessage.getName() + ":\n" + part); 592 } else { 593 part = faultMessage.getObjectPart("outOfStockException"); 594 if (part != null) { 595 debug(faultMessage.getName() + ":\n" + part); 596 } else { 597 debug("ERROR: Unknown fault message!"); 598 } 599 } 600 } 601 602 operation = port.createOperation("submitOrderOperation"); 604 inputMessage = operation.createInputMessage(); 605 outputMessage = operation.createOutputMessage(); 606 faultMessage = operation.createFaultMessage(); 607 608 debug("\n---> Invocation (remote): public SubmitOrderResult submitOrder(org.apache.wsif.ejb.sample.shop.CreditCardInfo creditCardInfo, org.apache.wsif.ejb.sample.shop.AirMilesContainer airMilesContainer) throws java.rmi.RemoteException"); 609 610 creditCardInfo = new CreditCardInfo(); 611 inputMessage.setObjectPart("creditCardInfo", creditCardInfo); 612 613 airMilesContainer = new AirMilesContainer(); 614 inputMessage.setObjectPart("airMilesContainer", airMilesContainer); 615 616 inputMessage.setLongPart("orderConfirmationNumber", 0); 617 618 operationSucceeded = 619 operation.executeRequestResponseOperation( 620 inputMessage, 621 outputMessage, 622 faultMessage); 623 624 assertTrue("submitOrderOperation failed!!", operationSucceeded); 625 626 debug(outputMessage.getObjectPart("submitOrderResult")); 627 628 630 } 631 632 635 public void testWSDL_Java_InputOnly() throws Exception { 636 debug("\n*** TEST INPUT ONLY OPERATION USING JAVA BINDING ***"); 637 638 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 639 WSIFService service = 640 factory 641 .getService( 642 wsdlPath + "ShoppingCartAll.wsdl", 643 "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 644 "ShoppingCart_JavaService", "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 647 "ShoppingCart_JavaPortType" ); 650 651 WSIFPort port = service.getPort(); 652 653 WSIFOperation operation; 654 WSIFMessage inputMessage; 655 WSIFMessage outputMessage; 656 WSIFMessage faultMessage; 657 658 String customerNumber; 659 String tempString; 660 Address address; 661 ShoppingCart_Java shoppingCart; 662 Item item; 663 CreditCardInfo creditCardInfo; 664 AirMilesContainer airMilesContainer; 665 Integer currentTotal = null; 666 Long orderConfirmationNumber; 667 Integer itemQuantity; 668 Object part; 669 boolean operationSucceeded; 670 671 operation = port.createOperation("createOperation"); 673 inputMessage = operation.createInputMessage(); 674 675 debug("\n---> Invocation: public ShoppingCart_Java(String firstName, String lastName, Address address, String customerNumber)"); 676 677 inputMessage.setObjectPart("firstName", "Albert"); 678 679 inputMessage.setObjectPart("lastName", "Einstein"); 680 681 address = new Address("Berlin", "Unter den Linden"); 682 inputMessage.setObjectPart("address", address); 683 684 inputMessage.setObjectPart("customerNumber", "AE001"); 685 686 operation.executeInputOnlyOperation(inputMessage); 687 688 operation = port.createOperation("addItemOperation"); 691 inputMessage = operation.createInputMessage(); 692 outputMessage = operation.createOutputMessage(); 693 faultMessage = operation.createFaultMessage(); 694 695 debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)"); 696 697 inputMessage.setObjectPart("itemNumber", "100123"); 698 699 item = new Item(); 700 inputMessage.setObjectPart("item", item); 701 702 inputMessage.setObjectPart("itemName", "Pocket calculator"); 703 704 inputMessage.setIntPart("itemQuantity", 1); 705 706 operationSucceeded = 707 operation.executeRequestResponseOperation( 708 inputMessage, 709 outputMessage, 710 faultMessage); 711 712 assertTrue("addItem test failed", operationSucceeded); 713 714 if (operationSucceeded) { 715 assertTrue( 716 "addItemOperation (EJB) did not return an Item Object!!", 717 outputMessage.getObjectPart("item") instanceof Item); 718 debug(outputMessage.getObjectPart("item")); 719 debug("Current total = " + outputMessage.getObjectPart("currentTotal")); 720 } else { 721 } 723 724 operation = port.createOperation("emptyOrderOperation"); 727 inputMessage = operation.createInputMessage(); 728 729 debug("\n---> Invocation: public void emptyOrder(String customerNumber)"); 730 731 inputMessage.setObjectPart("customerNumber", "AE001"); 732 733 operation.executeInputOnlyOperation(inputMessage); 734 735 operation = port.createOperation("addItemOperation"); 738 inputMessage = operation.createInputMessage(); 739 outputMessage = operation.createOutputMessage(); 740 faultMessage = operation.createFaultMessage(); 741 742 debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)"); 743 744 inputMessage.setObjectPart("itemNumber", "100123"); 745 746 item = new Item(); 747 inputMessage.setObjectPart("item", item); 748 749 inputMessage.setObjectPart("itemName", "Pocket calculator"); 750 751 inputMessage.setIntPart("itemQuantity", 5); 752 753 operationSucceeded = 754 operation.executeRequestResponseOperation( 755 inputMessage, 756 outputMessage, 757 faultMessage); 758 759 assertTrue("addItem test failed", operationSucceeded); 760 761 if (operationSucceeded) { 762 assertTrue( 763 "addItemOperation (EJB) did not return an Item Object!!", 764 outputMessage.getObjectPart("item") instanceof Item); 765 debug(outputMessage.getObjectPart("item")); 766 debug("Current total = " + outputMessage.getObjectPart("currentTotal")); 767 } else { 768 } 770 } 771 772 775 public void testWSDL_EJB_InputOnly() throws Exception { 776 if (!TestUtilities.areWeTesting("ejb")) 777 return; 778 779 debug("\n*** TEST INPUT ONLY OPERATION USING EJB BINDING ***"); 780 781 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 782 WSIFService service = 783 factory 784 .getService( 785 wsdlPath + "ShoppingCartAll.wsdl", 786 "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 787 "ShoppingCart_EJBService", "http://www.shoppingcart.com/definitions/ShoppingCartInterface", 790 "ShoppingCart_EJBPortType" ); 793 794 WSIFPort port = service.getPort(); 795 796 WSIFOperation operation; 797 WSIFMessage inputMessage; 798 WSIFMessage outputMessage; 799 WSIFMessage faultMessage; 800 801 String customerNumber; 802 String tempString; 803 Address address; 804 ShoppingCart shoppingCart; 805 Item item = null; 806 CreditCardInfo creditCardInfo; 807 AirMilesContainer airMilesContainer; 808 Integer currentTotal = null; 809 Long orderConfirmationNumber; 810 Integer itemQuantity; 811 Object part; 812 boolean operationSucceeded; 813 814 operation = port.createOperation("createOperation"); 816 inputMessage = operation.createInputMessage(); 817 outputMessage = operation.createOutputMessage(); 818 faultMessage = operation.createFaultMessage(); 819 820 debug("\n---> Invocation (home): public ShoppingCart create(java.lang.String firstName, java.lang.String lastName, org.apache.wsif.ejb.sample.shop.Address address, java.lang.String customerNumber) throws org.apache.wsif.ejb.sample.shop.CreateException, javax.ejb.CreateException, java.rmi.RemoteException"); 821 822 inputMessage.setObjectPart("firstName", "Albert"); 823 824 inputMessage.setObjectPart("lastName", "Einstein"); 825 826 address = new Address("Berlin", "Unter den Linden"); 827 inputMessage.setObjectPart("address", address); 828 829 inputMessage.setObjectPart("customerNumber", "AE001"); 830 831 operationSucceeded = 832 operation.executeRequestResponseOperation( 833 inputMessage, 834 outputMessage, 835 faultMessage); 836 837 assertTrue("createOperation failed!!", operationSucceeded); 838 839 operation = port.createOperation("addItemOperation"); 842 inputMessage = operation.createInputMessage(); 843 outputMessage = operation.createOutputMessage(); 844 faultMessage = operation.createFaultMessage(); 845 846 debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException"); 847 848 inputMessage.setObjectPart("itemNumber", "100123"); 849 850 inputMessage.setObjectPart("itemName", "Pocket calculator"); 851 852 inputMessage.setIntPart("itemQuantity", 1); 853 854 operationSucceeded = 855 operation.executeRequestResponseOperation( 856 inputMessage, 857 outputMessage, 858 faultMessage); 859 860 assertTrue("addItemOperation failed!!", operationSucceeded); 861 862 if (operationSucceeded) { 863 assertTrue( 864 "addItemOperation (EJB) did not return an Item Object!!", 865 outputMessage.getObjectPart("item") instanceof Item); 866 debug(outputMessage.getObjectPart("item")); 867 } else { 868 part = faultMessage.getObjectPart("invalidItemException"); 869 if (part != null) { 870 debug(faultMessage.getName() + ":\n" + part); 871 } else { 872 part = faultMessage.getObjectPart("outOfStockException"); 873 if (part != null) { 874 debug(faultMessage.getName() + ":\n" + part); 875 } else { 876 debug("ERROR: Unknown fault message!"); 877 } 878 } 879 } 880 881 operation = port.createOperation("emptyOrderOperation"); 884 inputMessage = operation.createInputMessage(); 885 886 debug("\n---> Invocation: public void emptyOrder(String customerNumber)"); 887 888 inputMessage.setObjectPart("customerNumber", "AE001"); 889 890 operation.executeInputOnlyOperation(inputMessage); 891 892 operation = port.createOperation("addItemOperation"); 895 inputMessage = operation.createInputMessage(); 896 outputMessage = operation.createOutputMessage(); 897 faultMessage = operation.createFaultMessage(); 898 899 debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException"); 900 901 inputMessage.setObjectPart("itemNumber", "100123"); 902 903 inputMessage.setObjectPart("itemName", "Pocket calculator"); 904 905 inputMessage.setIntPart("itemQuantity", 5); 906 907 operationSucceeded = 908 operation.executeRequestResponseOperation( 909 inputMessage, 910 outputMessage, 911 faultMessage); 912 913 assertTrue("addItemOperation failed!!", operationSucceeded); 914 915 if (operationSucceeded) { 916 assertTrue( 917 "addItemOperation (EJB) did not return an Item Object!!", 918 outputMessage.getObjectPart("item") instanceof Item); 919 debug(outputMessage.getObjectPart("item")); 920 } else { 921 part = faultMessage.getObjectPart("invalidItemException"); 922 if (part != null) { 923 debug(faultMessage.getName() + ":\n" + part); 924 } else { 925 part = faultMessage.getObjectPart("outOfStockException"); 926 if (part != null) { 927 debug(faultMessage.getName() + ":\n" + part); 928 } else { 929 debug("ERROR: Unknown fault message!"); 930 } 931 } 932 } 933 } 934 935 private void debug(Object s) { 936 if (debugMode) 937 System.out.println(s); 938 } 939 940 } 941 | Popular Tags |