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 OrderProcessDOCTestCase extends WebserviceTestBase 37 { 38 39 public OrderProcessDOCTestCase(String name) 40 { 41 super(name); 42 } 43 44 45 public static Test suite() throws Exception 46 { 47 return getDeploySetup(OrderProcessDOCTestCase.class, "ws4ee-samples2-doc.war, ws4ee-samples2-doc-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 OrderProcess endpoint = (OrderProcess)service.getPort(OrderProcess.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 OrderResponse res = endpoint.processOrder(new OrderItem[] { i0, i1, i2 }, p); 63 assertEquals(3, res.getItems().length); 64 assertEquals(i0, res.getItems()[0]); 65 assertEquals(i1, res.getItems()[1]); 66 assertEquals(i2, res.getItems()[2]); 67 assertEquals("approved", res.getMessage()); 68 } 69 70 71 public void testNullPerson() throws Exception 72 { 73 InitialContext iniCtx = getClientContext(); 74 Service service = (Service )iniCtx.lookup("java:comp/env/service/OrderProcess"); 75 OrderProcess endpoint = (OrderProcess)service.getPort(OrderProcess.class); 76 77 OrderItem i1 = new OrderItem("Ferrari", 1); 78 OrderItem i2 = new OrderItem("Twix", 10); 79 OrderItem i3 = new OrderItem("IceCream", 3); 80 81 try 82 { 83 endpoint.processOrder(new OrderItem[] { i1, i2, i3 }, null); 84 fail("OrderException expected"); 85 } 86 catch (OrderException e) 87 { 88 } 90 } 91 92 93 public void testTooManyItems() throws Exception 94 { 95 InitialContext iniCtx = getClientContext(); 96 Service service = (Service )iniCtx.lookup("java:comp/env/service/OrderProcess"); 97 OrderProcess endpoint = (OrderProcess)service.getPort(OrderProcess.class); 98 99 Person p = new Person("Tom", 3); 100 OrderItem i1 = new OrderItem("Ferrari", 1); 101 OrderItem i2 = new OrderItem("Twix", 10); 102 OrderItem i3 = new OrderItem("IceCream", 3); 103 OrderItem i4 = new OrderItem("GameBoy", 1); 104 105 try 106 { 107 endpoint.processOrder(new OrderItem[] { i1, i2, i3, i4 }, p); 108 fail("OrderException expected"); 109 } 110 catch (OrderException e) 111 { 112 } 114 } 115 } 116 | Popular Tags |