| 1 |
/** |
| 2 |
* ComplexRpcEncServiceTestCase.java |
| 3 |
* |
| 4 |
* This file was auto-generated from WSDL |
| 5 |
* by the Apache Axis WSDL2Java emitter. |
| 6 |
*/ |
| 7 |
|
| 8 |
package test.wsdl.interop4.groupH.complexRPCenc; |
| 9 |
|
| 10 |
import java.net.URL; |
| 11 |
|
| 12 |
public class ComplexRpcEncServiceTestCase extends junit.framework.TestCase { |
| 13 |
|
| 14 |
public static URL url = null; |
| 15 |
|
| 16 |
public static void main(String[] args) throws Exception { |
| 17 |
if (args.length == 1) { |
| 18 |
url = new URL(args[0]); |
| 19 |
} else { |
| 20 |
url = new URL(new ComplexRpcEncServiceLocator().getComplexRpcEncPortAddress()); |
| 21 |
} |
| 22 |
junit.textui.TestRunner.run(new junit.framework.TestSuite(ComplexRpcEncServiceTestCase.class)); |
| 23 |
} // main |
| 24 |
|
| 25 |
|
| 26 |
public ComplexRpcEncServiceTestCase(java.lang.String name) throws Exception { |
| 27 |
super(name); |
| 28 |
if (url == null) { |
| 29 |
url = new URL(new ComplexRpcEncServiceLocator().getComplexRpcEncPortAddress()); |
| 30 |
} |
| 31 |
} |
| 32 |
public void test1ComplexRpcEncPortEchoSOAPStructFault() throws Exception { |
| 33 |
test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncPortType binding; |
| 34 |
try { |
| 35 |
binding = new test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncServiceLocator().getComplexRpcEncPort(url); |
| 36 |
} |
| 37 |
catch (javax.xml.rpc.ServiceException jre) { |
| 38 |
if(jre.getLinkedCause()!=null) |
| 39 |
jre.getLinkedCause().printStackTrace(); |
| 40 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 41 |
} |
| 42 |
assertTrue("binding is null", binding != null); |
| 43 |
|
| 44 |
SOAPStruct soapStruct = new SOAPStruct(); |
| 45 |
soapStruct.setVarFloat(1.1F); |
| 46 |
soapStruct.setVarInt(3); |
| 47 |
soapStruct.setVarString("Fault test"); |
| 48 |
|
| 49 |
// Test operation |
| 50 |
try { |
| 51 |
SOAPStructFault param = new SOAPStructFault(soapStruct); |
| 52 |
binding.echoSOAPStructFault(param); |
| 53 |
} |
| 54 |
catch (test.wsdl.interop4.groupH.complexRPCenc.SOAPStructFault e1) { |
| 55 |
assertEquals("SOAPStruct values not equal", |
| 56 |
soapStruct, e1.getSoapStruct()); |
| 57 |
return; |
| 58 |
} |
| 59 |
fail("Should have caught exception!"); |
| 60 |
} |
| 61 |
|
| 62 |
public void test2ComplexRpcEncPortEchoBaseStructFault() throws Exception { |
| 63 |
test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncPortType binding; |
| 64 |
try { |
| 65 |
binding = new test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncServiceLocator().getComplexRpcEncPort(url); |
| 66 |
} |
| 67 |
catch (javax.xml.rpc.ServiceException jre) { |
| 68 |
if(jre.getLinkedCause()!=null) |
| 69 |
jre.getLinkedCause().printStackTrace(); |
| 70 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 71 |
} |
| 72 |
assertTrue("binding is null", binding != null); |
| 73 |
|
| 74 |
short s = 30; |
| 75 |
BaseStruct param = new BaseStruct(1.1F, s); |
| 76 |
// Test operation |
| 77 |
try { |
| 78 |
binding.echoBaseStructFault(param); |
| 79 |
} |
| 80 |
catch (test.wsdl.interop4.groupH.complexRPCenc.BaseStruct e1) { |
| 81 |
assertEquals("BaseStruct values not equal", param, e1); |
| 82 |
return; |
| 83 |
} |
| 84 |
fail("Should have caught exception!"); |
| 85 |
} |
| 86 |
|
| 87 |
public void test3ComplexRpcEncPortEchoExtendedStructFault() throws Exception { |
| 88 |
test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncPortType binding; |
| 89 |
try { |
| 90 |
binding = new test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncServiceLocator().getComplexRpcEncPort(url); |
| 91 |
} |
| 92 |
catch (javax.xml.rpc.ServiceException jre) { |
| 93 |
if(jre.getLinkedCause()!=null) |
| 94 |
jre.getLinkedCause().printStackTrace(); |
| 95 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 96 |
} |
| 97 |
assertTrue("binding is null", binding != null); |
| 98 |
|
| 99 |
ExtendedStruct extended = new ExtendedStruct(); |
| 100 |
extended.setIntMessage(1); |
| 101 |
extended.setAnotherIntMessage(2); |
| 102 |
extended.setFloatMessage(3.3F); |
| 103 |
extended.setShortMessage((short)5); |
| 104 |
extended.setStringMessage("This is an ExtendedStruct"); |
| 105 |
|
| 106 |
// Test operation |
| 107 |
try { |
| 108 |
binding.echoExtendedStructFault(extended); |
| 109 |
} |
| 110 |
catch (test.wsdl.interop4.groupH.complexRPCenc.ExtendedStruct e1) { |
| 111 |
assertEquals("ExtendedStruct values not equal", extended, e1); |
| 112 |
return; |
| 113 |
} |
| 114 |
|
| 115 |
fail("Should have caught exception!"); |
| 116 |
} |
| 117 |
|
| 118 |
public void test4ComplexRpcEncPortEchoMultipleFaults1() throws Exception { |
| 119 |
test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncPortType binding; |
| 120 |
try { |
| 121 |
binding = new test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncServiceLocator().getComplexRpcEncPort(url); |
| 122 |
} |
| 123 |
catch (javax.xml.rpc.ServiceException jre) { |
| 124 |
if(jre.getLinkedCause()!=null) |
| 125 |
jre.getLinkedCause().printStackTrace(); |
| 126 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 127 |
} |
| 128 |
assertTrue("binding is null", binding != null); |
| 129 |
|
| 130 |
BaseStruct base = new BaseStruct(); |
| 131 |
base.setFloatMessage(2.2F); |
| 132 |
base.setShortMessage((short)4); |
| 133 |
|
| 134 |
SOAPStruct struct = new SOAPStruct(); |
| 135 |
struct.setVarFloat(1.1F); |
| 136 |
struct.setVarInt(5); |
| 137 |
struct.setVarString("Twas a dark and stormy night..."); |
| 138 |
|
| 139 |
for (int i = 1; i < 3; i++) { |
| 140 |
// Test operation |
| 141 |
try { |
| 142 |
binding.echoMultipleFaults1(i, struct, base); |
| 143 |
} |
| 144 |
catch (test.wsdl.interop4.groupH.complexRPCenc.BaseStruct e1) { |
| 145 |
assertEquals("Wrong fault thrown: " + e1.getClass(), 2, i); |
| 146 |
assertEquals("Bad data echoed", base, e1); |
| 147 |
continue; |
| 148 |
} |
| 149 |
catch (test.wsdl.interop4.groupH.complexRPCenc.SOAPStructFault e2) { |
| 150 |
assertEquals("Wrong fault thrown: " + e2.getClass(), 1, i); |
| 151 |
assertEquals("Bad data echoed", struct, e2.getSoapStruct()); |
| 152 |
continue; |
| 153 |
} |
| 154 |
fail("Should have caught exception!"); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
public void test5ComplexRpcEncPortEchoMultipleFaults2() throws Exception { |
| 159 |
test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncPortType binding; |
| 160 |
try { |
| 161 |
binding = new test.wsdl.interop4.groupH.complexRPCenc.ComplexRpcEncServiceLocator().getComplexRpcEncPort(url); |
| 162 |
} |
| 163 |
catch (javax.xml.rpc.ServiceException jre) { |
| 164 |
if(jre.getLinkedCause()!=null) |
| 165 |
jre.getLinkedCause().printStackTrace(); |
| 166 |
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); |
| 167 |
} |
| 168 |
assertTrue("binding is null", binding != null); |
| 169 |
|
| 170 |
BaseStruct base = new BaseStruct(); |
| 171 |
base.setFloatMessage(2.2F); |
| 172 |
base.setShortMessage((short)4); |
| 173 |
|
| 174 |
ExtendedStruct extended = new ExtendedStruct(); |
| 175 |
extended.setIntMessage(1); |
| 176 |
extended.setAnotherIntMessage(2); |
| 177 |
extended.setFloatMessage(3.3F); |
| 178 |
extended.setShortMessage((short)5); |
| 179 |
extended.setStringMessage("This is an ExtendedStruct"); |
| 180 |
|
| 181 |
MoreExtendedStruct moreExtended = new MoreExtendedStruct(); |
| 182 |
moreExtended.setBooleanMessage(true); |
| 183 |
moreExtended.setIntMessage(2); |
| 184 |
moreExtended.setAnotherIntMessage(3); |
| 185 |
moreExtended.setFloatMessage(6.6F); |
| 186 |
moreExtended.setShortMessage((short)9); |
| 187 |
moreExtended.setStringMessage("This is a MoreExtendedStruct"); |
| 188 |
|
| 189 |
// Test operation multiple times |
| 190 |
for (int i = 1; i < 4; i++) { |
| 191 |
try { |
| 192 |
binding.echoMultipleFaults2(i, base, extended, moreExtended); |
| 193 |
} |
| 194 |
catch (MoreExtendedStruct e3) { |
| 195 |
assertEquals("Wrong fault thrown: " + e3.getClass(), 3, i); |
| 196 |
assertEquals("Bad data echoed", moreExtended, e3); |
| 197 |
continue; |
| 198 |
} |
| 199 |
catch (ExtendedStruct e2) { |
| 200 |
assertEquals("Wrong fault thrown: " + e2.getClass(), 2, i); |
| 201 |
assertEquals("Bad data echoed", extended, e2); |
| 202 |
continue; |
| 203 |
} |
| 204 |
catch (BaseStruct e1) { |
| 205 |
assertEquals("Wrong fault thrown: " + e1.getClass(), 1, i); |
| 206 |
assertEquals("Bad data echoed", base, e1); |
| 207 |
continue; |
| 208 |
} |
| 209 |
|
| 210 |
fail("Should have caught exception!"); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
} |