1 22 package org.jboss.test.webservice.samples2; 23 24 import junit.framework.Test; 25 import org.jboss.test.webservice.WebserviceTestBase; 26 27 import javax.naming.InitialContext ; 28 import javax.xml.rpc.Service ; 29 30 36 public class OrderProcessDOCBareTestCase extends WebserviceTestBase 37 { 38 39 public OrderProcessDOCBareTestCase(String name) 40 { 41 super(name); 42 } 43 44 45 public static Test suite() throws Exception 46 { 47 return getDeploySetup(OrderProcessDOCBareTestCase.class, "ws4ee-samples2-docbare.war, ws4ee-samples2-docbare-client.jar"); 48 } 49 50 51 public void testValidAccess() throws Exception 52 { 53 InitialContext iniCtx = getClientContext(); 54 Service service = (Service )iniCtx.lookup("java:comp/env/service/OrderProcess"); 55 OrderProcessBare endpoint = (OrderProcessBare)service.getPort(OrderProcessBare.class); 56 57 Person p = new Person("Tom", 3); 58 OrderItem i0 = new OrderItem("Ferrari", 1); 59 OrderItem i1 = new OrderItem("Twix", 10); 60 OrderItem i2 = new OrderItem("IceCream", 3); 61 62 OrderProcess_processOrder_RequestStruct reqStr = new OrderProcess_processOrder_RequestStruct(new OrderItem[] { i0, i1, i2 }, p); 63 OrderProcess_processOrder_ResponseStruct resStr = endpoint.processOrder(reqStr); 64 OrderResponse res = resStr.getResult(); 65 assertEquals(3, res.getItems().length); 66 assertEquals(i0, res.getItems()[0]); 67 assertEquals(i1, res.getItems()[1]); 68 assertEquals(i2, res.getItems()[2]); 69 assertEquals("approved", res.getMessage()); 70 } 71 72 73 public void testNullPerson() throws Exception 74 { 75 InitialContext iniCtx = getClientContext(); 76 Service service = (Service )iniCtx.lookup("java:comp/env/service/OrderProcess"); 77 OrderProcessBare endpoint = (OrderProcessBare)service.getPort(OrderProcessBare.class); 78 79 OrderItem i1 = new OrderItem("Ferrari", 1); 80 OrderItem i2 = new OrderItem("Twix", 10); 81 OrderItem i3 = new OrderItem("IceCream", 3); 82 83 try 84 { 85 OrderProcess_processOrder_RequestStruct reqStr = new OrderProcess_processOrder_RequestStruct(new OrderItem[] { i1, i2, i3 }, null); 86 endpoint.processOrder(reqStr); 87 fail("OrderException expected"); 88 } 89 catch (OrderException e) 90 { 91 } 93 } 94 95 96 public void testTooManyItems() throws Exception 97 { 98 InitialContext iniCtx = getClientContext(); 99 Service service = (Service )iniCtx.lookup("java:comp/env/service/OrderProcess"); 100 OrderProcessBare endpoint = (OrderProcessBare)service.getPort(OrderProcessBare.class); 101 102 Person p = new Person("Tom", 3); 103 OrderItem i1 = new OrderItem("Ferrari", 1); 104 OrderItem i2 = new OrderItem("Twix", 10); 105 OrderItem i3 = new OrderItem("IceCream", 3); 106 OrderItem i4 = new OrderItem("GameBoy", 1); 107 108 try 109 { 110 OrderProcess_processOrder_RequestStruct reqStr = new OrderProcess_processOrder_RequestStruct(new OrderItem[] { i1, i2, i3, i4 }, p); 111 endpoint.processOrder(reqStr); 112 fail("OrderException expected"); 113 } 114 catch (OrderException e) 115 { 116 } 118 } 119 } 120 | Popular Tags |