KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > query > QueryTestServiceTestCase


1 /**
2  * QueryTest_ServiceTestCase.java
3  *
4  * Test the QueryBean object.
5  *
6  */

7
8 package test.wsdl.query;
9
10 public class QueryTestServiceTestCase extends junit.framework.TestCase {
11     public QueryTestServiceTestCase(java.lang.String JavaDoc name) {
12         super(name);
13     }
14
15     public void testQueryTestWSDL() throws Exception JavaDoc {
16         javax.xml.rpc.ServiceFactory JavaDoc serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
17         java.net.URL JavaDoc url = new java.net.URL JavaDoc(new test.wsdl.query.QueryTestServiceLocator().getQueryTestAddress() + "?WSDL");
18         javax.xml.rpc.Service JavaDoc service = serviceFactory.createService(url, new test.wsdl.query.QueryTestServiceLocator().getServiceName());
19         assertTrue(service != null);
20     }
21
22
23     public void test2QueryTestEchoQuery() throws Exception JavaDoc {
24         test.wsdl.query.QueryTestBindingStub binding;
25         try {
26             binding = (test.wsdl.query.QueryTestBindingStub)
27                           new test.wsdl.query.QueryTestServiceLocator().getQueryTest();
28         }
29         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
30             if(jre.getLinkedCause()!=null)
31                 jre.getLinkedCause().printStackTrace();
32             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
33         }
34         assertNotNull("binding is null", binding);
35
36         // Time out after a minute
37
binding.setTimeout(60000);
38
39         // Test operation
40
test.wsdl.query.QueryBean inQuery = new QueryBean();
41         String JavaDoc[] columns = new String JavaDoc[] {"first", "last", "number"};
42         Object JavaDoc[][] data = new Object JavaDoc[][] { {new String JavaDoc("Joe"), new String JavaDoc("Blow"), new Integer JavaDoc(3)},
43                                            {new String JavaDoc("John"), new String JavaDoc("Doe"), new Integer JavaDoc(2)} };
44         inQuery.setColumnList(columns);
45         inQuery.setData(data);
46
47         QueryBean outQuery = binding.echoQuery(inQuery);
48         assertNotNull("return value is null", outQuery);
49         String JavaDoc[] outCols = outQuery.getColumnList();
50         assertNotNull("column list is null", outCols);
51         assertEquals("column value #1 doesn't match", columns[0], outCols[0]);
52         assertEquals("column value #2 doesn't match", columns[1], outCols[1]);
53         assertEquals("column value #3 doesn't match", columns[2], outCols[2]);
54         Object JavaDoc[][] outData = outQuery.getData();
55         assertNotNull("data arrayt is null", outData);
56         assertEquals("data value 0,0 doesn't match", data[0][0], outData[0][0]);
57         assertEquals("data value 0,1 doesn't match", data[0][1], outData[0][1]);
58         assertEquals("data value 0,2 doesn't match", data[0][2], outData[0][2]);
59         assertEquals("data value 1,0 doesn't match", data[1][0], outData[1][0]);
60         assertEquals("data value 1,1 doesn't match", data[1][1], outData[1][1]);
61         assertEquals("data value 1,2 doesn't match", data[1][2], outData[1][2]);
62     }
63
64 /*
65     public void test3QueryTestEchoArray() throws Exception {
66         test.wsdl.query.QueryTestBindingStub binding;
67         try {
68             binding = (test.wsdl.query.QueryTestBindingStub)
69                           new test.wsdl.query.QueryTestServiceLocator().getQueryTest();
70         }
71         catch (javax.xml.rpc.ServiceException jre) {
72             if(jre.getLinkedCause()!=null)
73                 jre.getLinkedCause().printStackTrace();
74             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
75         }
76         assertNotNull("binding is null", binding);
77
78         // Time out after a minute
79         binding.setTimeout(60000);
80
81         // Test operation
82         java.lang.Object[] value = null;
83         value = binding.echoArray(new java.lang.Object[0]);
84         // TBD - validate results
85     }
86 */

87
88 }
89
Popular Tags