1 9 10 package test.wsdl.interop4.groupH.simpleRPCenc; 11 12 import java.net.URL ; 13 14 public class SimpleRpcEncServiceTestCase extends junit.framework.TestCase { 15 16 public static URL url = null; 17 18 public static void main(String [] args) throws Exception { 19 if (args.length == 1) { 20 url = new URL (args[0]); 21 } else { 22 url = new URL (new SimpleRpcEncServiceLocator().getSimpleRpcEncPortAddress()); 23 } 24 junit.textui.TestRunner.run(new junit.framework.TestSuite(SimpleRpcEncServiceTestCase.class)); 25 } 27 28 public SimpleRpcEncServiceTestCase(java.lang.String name) throws Exception { 29 super(name); 30 if (url == null) { 31 url = new URL (new SimpleRpcEncServiceLocator().getSimpleRpcEncPortAddress()); 32 } 33 } 34 35 36 public void test1SimpleRpcEncPortEchoEmptyFault() throws Exception { 37 SimpleRpcEncPortType binding; 38 try { 39 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 40 } 41 catch (javax.xml.rpc.ServiceException jre) { 42 if(jre.getLinkedCause()!=null) 43 jre.getLinkedCause().printStackTrace(); 44 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 45 } 46 assertTrue("binding is null", binding != null); 47 48 try { 51 binding.echoEmptyFault(); 52 } 53 catch(EmptyFault ef) { 54 return; 55 } 56 fail("Did NOT catch any exception"); 57 } 58 59 60 61 public void test2SimpleRpcEncPortEchoStringFault() throws Exception { 62 SimpleRpcEncPortType binding; 63 try { 64 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 65 } 66 catch (javax.xml.rpc.ServiceException jre) { 67 if(jre.getLinkedCause()!=null) 68 jre.getLinkedCause().printStackTrace(); 69 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 70 } 71 assertTrue("binding is null", binding != null); 72 73 try { 75 binding.echoStringFault("HELLO"); 76 } 77 catch(StringFault sf) { 78 assertEquals("HELLO", sf.getPart2()); 79 return; 80 } 81 fail("Did NOT catch any exception"); 82 } 83 84 public void test3SimpleRpcEncPortEchoIntArrayFault() throws Exception { 85 SimpleRpcEncPortType binding; 86 try { 87 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 88 } 89 catch (javax.xml.rpc.ServiceException jre) { 90 if(jre.getLinkedCause()!=null) 91 jre.getLinkedCause().printStackTrace(); 92 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 93 } 94 assertTrue("binding is null", binding != null); 95 96 int[] param = new int[] {1, 2, 3}; 99 try { 100 binding.echoIntArrayFault(param); 101 } 102 catch(IntArrayFault f) { 103 int[] ret = f.getPart5(); 104 assertEquals("Array element 1", param[0], ret[0]); 105 assertEquals("Array element 2", param[1], ret[1]); 106 assertEquals("Array element 3", param[2], ret[2]); 107 return; 108 } 109 fail("Did NOT catch any exception"); 110 } 111 112 public void test4SimpleRpcEncPortEchoMultipleFaults1() throws Exception { 113 SimpleRpcEncPortType binding; 114 try { 115 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 116 } 117 catch (javax.xml.rpc.ServiceException jre) { 118 if(jre.getLinkedCause()!=null) 119 jre.getLinkedCause().printStackTrace(); 120 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 121 } 122 assertTrue("binding is null", binding != null); 123 124 float[] floatParam = new float[] {1.0F, 2.2F, 3.5F}; 127 String stringParam = "HELLO"; 128 for (int i=1; i < 4; i++) { 129 try { 130 binding.echoMultipleFaults1(i, stringParam, floatParam); 131 } 132 catch (EmptyFault e1) { 133 assertEquals("Wrong fault thrown: " + e1.getClass(), 1, i); 134 continue; 135 } 136 catch (StringFault e2) { 137 assertEquals("Wrong fault thrown: " + e2.getClass(), 2, i); 138 assertEquals("HELLO", e2.getPart2()); 139 continue; 140 } 141 catch (FloatArrayFault e3) { 142 assertEquals("Wrong fault thrown: " + e3.getClass(), 3, i); 143 float[] ret = e3.getPart7(); 144 assertEquals(floatParam[0], ret[0], 0.01F); 145 assertEquals(floatParam[1], ret[1], 0.01F); 146 assertEquals(floatParam[2], ret[2], 0.01F); 147 continue; 148 } 149 fail("Did NOT catch any exception"); 150 } 151 } 152 153 public void test5SimpleRpcEncPortEchoMultipleFaults2() throws Exception { 154 SimpleRpcEncPortType binding; 155 try { 156 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 157 } 158 catch (javax.xml.rpc.ServiceException jre) { 159 if(jre.getLinkedCause()!=null) 160 jre.getLinkedCause().printStackTrace(); 161 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 162 } 163 assertTrue("binding is null", binding != null); 164 165 String stringParam = "HELLO"; 168 String [] stringArrayParam = new String [] {"one", "two", "three"}; 169 float floatParam = 9.7F; 170 for (int i=1; i < 4; i++) { 171 try { 172 binding.echoMultipleFaults2(i, stringParam, floatParam, stringArrayParam); 173 } 174 catch (FloatFault e1) { 175 assertEquals("Wrong fault thrown: " + e1.getClass(), 1, i); 176 assertEquals(floatParam, e1.getPart4(), 0.01F); 177 continue; 178 } 179 catch (StringFault e2) { 180 assertEquals("Wrong fault thrown: " + e2.getClass(), 2, i); 181 assertEquals(stringParam, e2.getPart2()); 182 continue; 183 } 184 catch (StringArrayFault e3) { 185 assertEquals("Wrong fault thrown: " + e3.getClass(), 3, i); 186 String [] ret = e3.getPart6(); 187 assertEquals("Array element 1", stringArrayParam[0], ret[0]); 188 assertEquals("Array element 2", stringArrayParam[1], ret[1]); 189 assertEquals("Array element 3", stringArrayParam[2], ret[2]); 190 continue; 191 } 192 fail("Did NOT catch any exception"); 193 } 194 } 195 196 public void test6SimpleRpcEncPortEchoMultipleFaults3() throws Exception { 197 SimpleRpcEncPortType binding; 198 try { 199 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 200 } 201 catch (javax.xml.rpc.ServiceException jre) { 202 if(jre.getLinkedCause()!=null) 203 jre.getLinkedCause().printStackTrace(); 204 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 205 } 206 assertTrue("binding is null", binding != null); 207 208 String param1 = "Param1"; 211 String param2 = "Param2"; 212 for (int i=1; i < 3; i++) { 213 try { 214 binding.echoMultipleFaults3(i, param1, param2); 215 } 216 catch (StringFault e1) { 217 assertEquals("Wrong fault thrown: " + e1.getClass(), 1, i); 218 assertEquals(param1, e1.getPart2()); 219 continue; 220 } 221 catch (String2Fault e2) { 222 assertEquals("Wrong fault thrown: " + e2.getClass(), 2, i); 223 assertEquals(param2, e2.getPart2()); 224 continue; 225 } 226 fail("Did NOT catch any exception"); 227 } 228 } 229 230 public void test7SimpleRpcEncPortEchoMultipleFaults4() throws Exception { 231 SimpleRpcEncPortType binding; 232 try { 233 binding = new SimpleRpcEncServiceLocator().getSimpleRpcEncPort(url); 234 } 235 catch (javax.xml.rpc.ServiceException jre) { 236 if(jre.getLinkedCause()!=null) 237 jre.getLinkedCause().printStackTrace(); 238 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 239 } 240 assertTrue("binding is null", binding != null); 241 242 int intParam = 66; 245 Enum enumParam = new Enum (1); 246 for (int i=1; i < 3; i++) { 247 try { 248 binding.echoMultipleFaults4(i, intParam, enumParam); 249 } 250 catch (IntFault e1) { 251 assertEquals("Wrong fault thrown: " + e1.getClass(), 1, i); 252 assertEquals(intParam, e1.getPart3()); 253 continue; 254 } 255 catch (EnumFault e2) { 256 assertEquals("Wrong fault thrown: " + e2.getClass(), 2, i); 257 assertEquals(enumParam.getValue(), e2.getPart9().getValue()); 258 continue; 259 } 260 fail("Did NOT catch any exception"); 261 } 262 } 263 264 } 265 | Popular Tags |