| 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 name) { |
| 12 |
super(name); |
| 13 |
} |
| 14 |
|
| 15 |
public void testQueryTestWSDL() throws Exception { |
| 16 |
javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); |
| 17 |
java.net.URL url = new java.net.URL(new test.wsdl.query.QueryTestServiceLocator().getQueryTestAddress() + "?WSDL"); |
| 18 |
javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.query.QueryTestServiceLocator().getServiceName()); |
| 19 |
assertTrue(service != null); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
public void test2QueryTestEchoQuery() throws Exception { |
| 24 |
test.wsdl.query.QueryTestSoapBindingStub binding; |
| 25 |
try { |
| 26 |
binding = (test.wsdl.query.QueryTestSoapBindingStub) |
| 27 |
new test.wsdl.query.QueryTestServiceLocator().getQueryTest(); |
| 28 |
} |
| 29 |
catch (javax.xml.rpc.ServiceException 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 |
// Set up input data |
| 40 |
test.wsdl.query.QueryBean inQuery = new QueryBean(); |
| 41 |
String[] columns = new String[] {"first", "last", "number"}; |
| 42 |
Object[][] data = new Object[][] { {new String("Joe"), new String("Blow"), new Integer(3)}, |
| 43 |
{new String("John"), new String("Doe"), new Integer(2)} }; |
| 44 |
inQuery.setColumnList(columns); |
| 45 |
inQuery.setData(data); |
| 46 |
|
| 47 |
// Do the operation |
| 48 |
QueryBean outQuery = binding.echoQuery(inQuery); |
| 49 |
|
| 50 |
// Check the results |
| 51 |
assertNotNull("return value from echoQuery is null", outQuery); |
| 52 |
String[] outCols = outQuery.getColumnList(); |
| 53 |
assertNotNull("column list in the returned Query is null, should have string array in it", outCols); |
| 54 |
assertEquals("column value #1 doesn't match", columns[0], outCols[0]); |
| 55 |
assertEquals("column value #2 doesn't match", columns[1], outCols[1]); |
| 56 |
assertEquals("column value #3 doesn't match", columns[2], outCols[2]); |
| 57 |
Object[][] outData = outQuery.getData(); |
| 58 |
assertNotNull("data array in the returned Query is null, should have Query data in it", outData); |
| 59 |
assertEquals("data value 0,0 doesn't match", data[0][0], outData[0][0]); |
| 60 |
assertEquals("data value 0,1 doesn't match", data[0][1], outData[0][1]); |
| 61 |
assertEquals("data value 0,2 doesn't match", data[0][2], outData[0][2]); |
| 62 |
assertEquals("data value 1,0 doesn't match", data[1][0], outData[1][0]); |
| 63 |
assertEquals("data value 1,1 doesn't match", data[1][1], outData[1][1]); |
| 64 |
assertEquals("data value 1,2 doesn't match", data[1][2], outData[1][2]); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
} |