gdaniels 2003/01/31 15:04:39 Modified: java/test/wsdl/soap12/additional WhiteMesaSoap12AddTestSvcTestCase.java Log: Start fleshing out tests. Needs more work - checking in so I can finish from home. Revision Changes Path 1.2 +68 -37 xml-axis/java/test/wsdl/soap12/additional/WhiteMesaSoap12AddTestSvcTestCase.java Index: WhiteMesaSoap12AddTestSvcTestCase.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/soap12/additional/WhiteMesaSoap12AddTestSvcTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WhiteMesaSoap12AddTestSvcTestCase.java 20 Jan 2003 01:58:31 -0000 1.1 +++ WhiteMesaSoap12AddTestSvcTestCase.java 31 Jan 2003 23:04:39 -0000 1.2 @@ -7,7 +7,14 @@ package test.wsdl.soap12.additional; +import org.apache.axis.Constants; +import org.apache.axis.AxisFault; + public class WhiteMesaSoap12AddTestSvcTestCase extends junit.framework.TestCase { + public static final String STRING_VAL = "SOAP 1.2 is cool!"; + public static final float FLOAT_VAL = 3.14F; + public static final int INT_VAL = 69; + public WhiteMesaSoap12AddTestSvcTestCase(java.lang.String name) { super(name); } @@ -30,8 +37,8 @@ // Test operation java.lang.String value = null; - value = binding.echoString(new java.lang.String()); - // TBD - validate results + value = binding.echoString(STRING_VAL); + assertEquals(STRING_VAL, value); } public void test2Soap12AddTestDocPortEchoSenderFault() throws Exception { @@ -51,9 +58,18 @@ binding.setTimeout(60000); // Test operation - // TODO: Fix this... - // binding.echoSenderFault(new java.lang.String()); - // TBD - validate results + try { + binding.echoSenderFault(STRING_VAL); + } catch (java.rmi.RemoteException e) { + if (e instanceof AxisFault) { + AxisFault af = (AxisFault)e; + assertEquals(Constants.FAULT_SOAP12_SENDER, + af.getFaultCode()); + return; // success + } + } + + fail("Should have received sender fault!"); } public void test3Soap12AddTestDocPortEchoReceiverFault() throws Exception { @@ -73,9 +89,18 @@ binding.setTimeout(60000); // Test operation - // TODO: Fix this... - // binding.echoReceiverFault(new java.lang.String()); - // TBD - validate results + try { + binding.echoReceiverFault(STRING_VAL); + } catch (java.rmi.RemoteException e) { + if (e instanceof AxisFault) { + AxisFault af = (AxisFault)e; + assertEquals(Constants.FAULT_SOAP12_RECEIVER, + af.getFaultCode()); + return; // success + } + } + + fail("Should have received receiver fault!"); } public void test4Soap12AddTestRpcPortEchoVoid() throws Exception { @@ -95,9 +120,7 @@ binding.setTimeout(60000); // Test operation - // TODO: Fix this... - // binding.echoVoid(); - // TBD - validate results + binding.echoVoid(); } public void test5Soap12AddTestRpcPortEchoSimpleTypesAsStruct() throws Exception { @@ -118,8 +141,10 @@ // Test operation test.wsdl.soap12.additional.xsd.SOAPStruct value = null; - value = binding.echoSimpleTypesAsStruct(new java.lang.String(), 0, 0); - // TBD - validate results + value = binding.echoSimpleTypesAsStruct(STRING_VAL, INT_VAL, FLOAT_VAL); + assertEquals("Float values differ", FLOAT_VAL, value.getVarFloat(), 0.000001F); + assertEquals("Int values differ", INT_VAL, value.getVarInt()); + assertEquals("String values differ", STRING_VAL, value.getVarString()); } public void test6Soap12AddTestRpcPortEchoString() throws Exception { @@ -140,8 +165,8 @@ // Test operation java.lang.String value = null; - value = binding.echoString(new java.lang.String()); - // TBD - validate results + value = binding.echoString(STRING_VAL); + assertEquals(STRING_VAL, value); } public void test7Soap12AddTestRpcPortEchoSimpleTypesAsStructOfSchemaTypes() throws Exception { @@ -162,9 +187,15 @@ // Test operation test.wsdl.soap12.additional.xsd.SOAPStructTypes value = null; - // TODO: Fix this... - // value = binding.echoSimpleTypesAsStructOfSchemaTypes(new java.lang.String(), new java.lang.String(), new java.lang.String(), new java.lang.String()); - // TBD - validate results + value = binding. + echoSimpleTypesAsStructOfSchemaTypes(STRING_VAL, + new Integer(INT_VAL), + new Float(FLOAT_VAL), + new Object()); + assertEquals(Constants.XSD_STRING, value.getType1()); + assertEquals(Constants.XSD_INT, value.getType2()); + assertEquals(Constants.XSD_FLOAT, value.getType3()); + assertEquals(Constants.XSD_ANYTYPE, value.getType4()); } public void test8Soap12AddTestRpcPortEchoInteger() throws Exception { @@ -184,18 +215,18 @@ binding.setTimeout(60000); // Test operation - int value = -3; - value = binding.echoInteger(0); - // TBD - validate results - } - - // getTime is a notification style operation and is unsupported. - // getTime is a notification style operation and is unsupported. + int value; + value = binding.echoInteger(INT_VAL); + assertEquals(INT_VAL, value); + } + + // getTime is a notification style operation and is unsupported. + // getTime is a notification style operation and is unsupported. public void test9Soap12AddTestDocUpperPortEchoString() throws Exception { test.wsdl.soap12.additional.Soap12AddTestDocBindingStub binding; try { binding = (test.wsdl.soap12.additional.Soap12AddTestDocBindingStub) - new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocUpperPort(); + new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocUpperPort(); } catch (javax.xml.rpc.ServiceException jre) { if(jre.getLinkedCause()!=null) @@ -203,14 +234,14 @@ throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertNotNull("binding is null", binding); - + // Time out after a minute binding.setTimeout(60000); - + // Test operation java.lang.String value = null; - value = binding.echoString(new java.lang.String()); - // TBD - validate results + value = binding.echoString(STRING_VAL); + assertEquals(STRING_VAL, value); } public void test10Soap12AddTestDocUpperPortEchoSenderFault() throws Exception { @@ -254,13 +285,13 @@ binding.echoReceiverFault(new java.lang.String()); // TBD - validate results } - - // getTime is a notification style operation and is unsupported. + + // getTime is a notification style operation and is unsupported. public void test12Soap12AddTestDocIntermediaryPortEchoString() throws Exception { test.wsdl.soap12.additional.Soap12AddTestDocBindingStub binding; try { binding = (test.wsdl.soap12.additional.Soap12AddTestDocBindingStub) - new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocIntermediaryPort(); + new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocIntermediaryPort(); } catch (javax.xml.rpc.ServiceException jre) { if(jre.getLinkedCause()!=null) @@ -268,14 +299,14 @@ throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertNotNull("binding is null", binding); - + // Time out after a minute binding.setTimeout(60000); - + // Test operation java.lang.String value = null; - value = binding.echoString(new java.lang.String()); - // TBD - validate results + value = binding.echoString(STRING_VAL); + assertEquals(STRING_VAL, value); } public void test13Soap12AddTestDocIntermediaryPortEchoSenderFault() throws Exception {