1
7
8 package indyjug.jboss.webservice;
9
10public class StockTraderServiceTestCase extends junit.framework.TestCase {
11 public StockTraderServiceTestCase(java.lang.String name) {
12 super(name);
13 }
14 public void test1StockTraderGetStocks() throws Exception {
15 indyjug.jboss.webservice.StockTraderSoapBindingStub binding;
16 try {
17 binding = (indyjug.jboss.webservice.StockTraderSoapBindingStub)
18 new indyjug.jboss.webservice.StockTraderServiceLocator().getStockTrader();
19 }
20 catch (javax.xml.rpc.ServiceException jre) {
21 if(jre.getLinkedCause()!=null)
22 jre.getLinkedCause().printStackTrace();
23 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
24 }
25 assertNotNull("binding is null", binding);
26
27 binding.setTimeout(60000);
29
30 java.lang.Object[] value = null;
32 value = binding.getStocks();
33
34 assertNotNull("return value", value);
35 assertEquals("return value length", 4, value.length);
36 }
37
38 public void test2StockTraderGetStocksByExchange() throws Exception {
39 indyjug.jboss.webservice.StockTraderSoapBindingStub binding;
40 try {
41 binding = (indyjug.jboss.webservice.StockTraderSoapBindingStub)
42 new indyjug.jboss.webservice.StockTraderServiceLocator().getStockTrader();
43 }
44 catch (javax.xml.rpc.ServiceException jre) {
45 if(jre.getLinkedCause()!=null)
46 jre.getLinkedCause().printStackTrace();
47 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
48 }
49 assertNotNull("binding is null", binding);
50
51 binding.setTimeout(60000);
53
54 java.lang.Object[] value = null;
56 value = binding.getStocksByExchange("NYSE");
57
58 assertNotNull("return value", value);
59 assertEquals("return value length", 2, value.length);
60 }
61
62 public void test3StockTraderTrade() throws Exception {
63 indyjug.jboss.webservice.StockTraderSoapBindingStub binding;
64 try {
65 binding = (indyjug.jboss.webservice.StockTraderSoapBindingStub)
66 new indyjug.jboss.webservice.StockTraderServiceLocator().getStockTrader();
67 }
68 catch (javax.xml.rpc.ServiceException jre) {
69 if(jre.getLinkedCause()!=null)
70 jre.getLinkedCause().printStackTrace();
71 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
72 }
73 assertNotNull("binding is null", binding);
74
75 binding.setTimeout(60000);
77
78 indyjug.jboss.webservice.OrderValue value = null;
80 value = binding.trade("NYSE", "IBM", "BUY", 82.85, 100.0);
81
82 assertNotNull("return value", value);
83
84 OrderValue order = (OrderValue)value;
85 assertEquals("order exchange", "NYSE", order.getStock().getExchange());
86 assertEquals("order symbol", "IBM", order.getStock().getSymbol());
87 assertEquals("order action", "BUY", order.getAction());
88 assertEquals("order price", 82.85, order.getPrice().doubleValue(), 0.0);
89 assertEquals("order price", 100.0, order.getShares().doubleValue(), 0.0);
90 }
91
92}
93