1 6 7 package org.enhydra.shark.wfxml.test; 8 9 import java.net.InetAddress ; 10 11 import javax.xml.namespace.QName ; 12 import javax.xml.rpc.holders.ObjectHolder ; 13 import javax.xml.rpc.holders.StringHolder ; 14 15 import org.apache.axis.encoding.DefaultTypeMappingImpl; 16 import org.apache.axis.message.MessageElement; 17 import org.apache.axis.types.URI; 18 import org.enhydra.shark.asap.AsapInstanceBindingStub; 19 import org.enhydra.shark.asap.AsapObserverBindingStub; 20 import org.enhydra.shark.asap.types.*; 21 import org.enhydra.shark.asap.types.holders.*; 22 import org.enhydra.shark.wfxml.SharkWebServiceLocator; 23 import org.enhydra.shark.wfxml.WfXmlFactoryBindingStub; 24 import org.enhydra.shark.wfxml.types.GetDefinitionRq; 25 import org.enhydra.shark.wfxml.types.holders.GetDefinitionRsHolder; 26 import org.enhydra.shark.wfxml.util.AltBeanDeserializerFactory; 27 import org.enhydra.shark.wfxml.util.AltBeanSerializerFactory; 28 29 34 public class SharkWebServiceTestCase extends junit.framework.TestCase { 35 static private URI ik; 36 37 public SharkWebServiceTestCase(java.lang.String name) { 38 super(name); 39 QName xmlType = new javax.xml.namespace.QName ("http://www.w3.org/2001/XMLSchema", 40 "anyType"); 41 DefaultTypeMappingImpl.getSingleton() 42 .register(String .class, 43 xmlType, 44 new AltBeanSerializerFactory(String .class, xmlType), 45 new AltBeanDeserializerFactory(String .class, xmlType)); 46 } 47 48 public void test6asapObserverBindingGetProperties() throws Exception { 49 AsapObserverBindingStub binding; 50 try { 51 binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding(); 52 } catch (javax.xml.rpc.ServiceException jre) { 53 if (jre.getLinkedCause() != null) jre.getLinkedCause() 54 .printStackTrace(); 55 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 56 + jre); 57 } 58 assertNotNull("binding is null", binding); 59 60 binding.setTimeout(60000); 62 63 Request rqh = new Request(); 64 String rqb = ""; ResponseHolder rsh = new ResponseHolder(); 66 GetPropertiesRsHolder rsb = new GetPropertiesRsHolder(); 67 rqh.setReceiverKey(new URI("http://vidi")); 68 69 binding.getProperties(rqh, rqb, rsh, rsb); 71 } 73 74 public void test7asapObserverBindingCompleted() throws Exception { 75 AsapObserverBindingStub binding; 76 try { 77 binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding(); 78 } catch (javax.xml.rpc.ServiceException jre) { 79 if (jre.getLinkedCause() != null) jre.getLinkedCause() 80 .printStackTrace(); 81 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 82 + jre); 83 } 84 assertNotNull("binding is null", binding); 85 86 binding.setTimeout(60000); 88 89 Request rqh = new Request(); 90 CompletedRq rqb = new CompletedRq(); 91 ResponseHolder rsh = new ResponseHolder(); 92 StringHolder rsb = new StringHolder (); 93 rqh.setReceiverKey(new URI("http://vidi")); 94 95 binding.completed(rqh, rqb, rsh, rsb); 97 } 99 100 public void test8asapObserverBindingStateChanged() throws Exception { 101 AsapObserverBindingStub binding; 102 try { 103 binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding(); 104 } catch (javax.xml.rpc.ServiceException jre) { 105 if (jre.getLinkedCause() != null) jre.getLinkedCause() 106 .printStackTrace(); 107 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 108 + jre); 109 } 110 assertNotNull("binding is null", binding); 111 112 binding.setTimeout(60000); 114 115 Request rqh = new Request(); 116 StateChangedRq rqb = new StateChangedRq(); 117 ResponseHolder rsh = new ResponseHolder(); 118 StringHolder rsb = new StringHolder (); 119 120 rqh.setReceiverKey(new URI("http://vidi")); 121 binding.stateChanged(rqh, rqb, rsh, rsb); 123 } 125 126 public void test9asapFactoryBindingGetProperties() throws Exception { 127 WfXmlFactoryBindingStub binding; 128 129 try { 130 binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(); 131 } catch (javax.xml.rpc.ServiceException jre) { 132 if (jre.getLinkedCause() != null) jre.getLinkedCause() 133 .printStackTrace(); 134 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 135 + jre); 136 } 137 assertNotNull("binding is null", binding); 138 139 binding.setTimeout(60000); 141 Request rqHead = new Request(); 142 String rqBody = ""; ResponseHolder rsHead = new ResponseHolder(); 144 GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder(); 145 rqHead.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress())); 146 rqHead.getReceiverKey() 149 .setQueryString("procDef=Game&packageId=test_bs"); 150 151 binding.getProperties(rqHead, rqBody, rsHead, rsBody); 153 FactoryPropertiesGroup fpg = rsBody.value.getFactoryPropertiesGroup(); 155 System.err.println("Key=" + fpg.getKey()); 156 System.err.println("Name=" + fpg.getName()); 157 System.err.println("Subj=" + fpg.getSubject()); 158 System.err.println("desc=" + fpg.getDescription()); 159 System.err.println("cds=" 160 + fpg.getContextDataSchema().get_any()[0].toString()); 161 System.err.println("rds=" 162 + fpg.getResultDataSchema().get_any()[0].toString()); 163 } 164 165 public void test10asapFactoryBindingCreateInstance() throws Exception { 166 WfXmlFactoryBindingStub binding; 167 try { 168 binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(); 169 } catch (javax.xml.rpc.ServiceException jre) { 170 if (jre.getLinkedCause() != null) jre.getLinkedCause() 171 .printStackTrace(); 172 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 173 + jre); 174 } 175 assertNotNull("binding is null", binding); 176 177 binding.setTimeout(60000); 179 180 Request rqHead = new Request(); 181 CreateInstanceRq rqBody = new CreateInstanceRq(); 182 ResponseHolder rsHead = new ResponseHolder(); 183 CreateInstanceRsHolder rsBody = new CreateInstanceRsHolder(); 184 185 rqHead.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress())); 186 rqHead.getReceiverKey() 189 .setQueryString("procDef=Game&packageId=test_bs"); 190 rqBody.setObserverKey(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress())); 191 rqBody.getObserverKey().setHost(InetAddress.getLocalHost() 192 .getHostName()); 193 rqBody.setName("some fine name"); 194 rqBody.setStartImmediately(true); 195 binding.createInstance(rqHead, rqBody, rsHead, rsBody); 197 System.err.println("##" + rsBody.value.getInstanceKey()); 198 ik = rsBody.value.getInstanceKey(); 200 } 201 202 public void test10asapFactoryBindingGetDefinition() throws Exception { 203 WfXmlFactoryBindingStub binding; 204 205 try { 206 binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(); 207 } catch (javax.xml.rpc.ServiceException jre) { 208 if (jre.getLinkedCause() != null) jre.getLinkedCause() 209 .printStackTrace(); 210 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 211 + jre); 212 } 213 assertNotNull("binding is null", binding); 214 215 binding.setTimeout(60000); 217 Request rqHead = new Request(); 218 GetDefinitionRq rqBody = new GetDefinitionRq(); ResponseHolder rsHead = new ResponseHolder(); 221 GetDefinitionRsHolder rsBody = new GetDefinitionRsHolder(); 222 rqHead.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress())); 223 225 binding.getDefinition(rqHead, rqBody, rsHead, rsBody); 227 rsBody.value.get_any(); 228 } 230 231 public void test11asapFactoryBindingListInstances() throws Exception { 232 WfXmlFactoryBindingStub binding; 233 try { 234 binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(); 235 } catch (javax.xml.rpc.ServiceException jre) { 236 if (jre.getLinkedCause() != null) jre.getLinkedCause() 237 .printStackTrace(); 238 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 239 + jre); 240 } 241 assertNotNull("binding is null", binding); 242 243 binding.setTimeout(60000); 245 246 Request rqh = new Request(); 247 rqh.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress())); 248 251 ListInstancesRq rqb = new ListInstancesRq(); 252 ResponseHolder rsh = new ResponseHolder(); 253 ListInstancesRsHolder rsb = new ListInstancesRsHolder(); 254 binding.listInstances(rqh, rqb, rsh, rsb); 256 Instance[] a = rsb.value.getInstance(); 257 if (null != a) { 258 for (int n = 0; n < a.length; ++n) { 259 System.err.println("[" 261 + a[n].getInstanceKey() + ", " 262 + a[n].getName() + ", " + a[n].getSubject() 263 + "]"); 264 } 265 } else { 266 System.err.println("getInstance value is null"); 267 } 268 } 270 271 public void test2asapInstanceBindingSetProperties() throws Exception { 272 AsapInstanceBindingStub binding; 273 try { 274 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 275 } catch (javax.xml.rpc.ServiceException jre) { 276 if (jre.getLinkedCause() != null) jre.getLinkedCause() 277 .printStackTrace(); 278 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 279 + jre); 280 } 281 assertNotNull("binding is null", binding); 282 283 binding.setTimeout(60000); 285 286 Request rqh = new Request(); 287 SetPropertiesRq rqb = new SetPropertiesRq(); 288 ResponseHolder rsh = new ResponseHolder(); 289 SetPropertiesRsHolder rsb = new SetPropertiesRsHolder(); 290 rqh.setReceiverKey(new URI("http://vidi")); 291 292 binding.setProperties(rqh, rqb, rsh, rsb); 294 } 296 297 public void test3asapInstanceBindingSubscribe() throws Exception { 298 AsapInstanceBindingStub binding; 299 try { 300 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 301 } catch (javax.xml.rpc.ServiceException jre) { 302 if (jre.getLinkedCause() != null) jre.getLinkedCause() 303 .printStackTrace(); 304 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 305 + jre); 306 } 307 assertNotNull("binding is null", binding); 308 309 binding.setTimeout(60000); 311 312 Request rqh = new Request(); 313 SubscribeRq rqb = new SubscribeRq(); 314 ResponseHolder rsh = new ResponseHolder(); 315 StringHolder rsb = new StringHolder (); 316 rqh.setReceiverKey(ik); 317 rqb.setObserverKey(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress())); 318 binding.subscribe(rqh, rqb, rsh, rsb); 320 } 322 323 public void test1asapInstanceBindingGetProperties() throws Exception { 324 AsapInstanceBindingStub binding; 325 try { 326 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 327 } catch (javax.xml.rpc.ServiceException jre) { 328 if (jre.getLinkedCause() != null) jre.getLinkedCause() 329 .printStackTrace(); 330 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 331 + jre); 332 } 333 assertNotNull("binding is null", binding); 334 335 binding.setTimeout(60000); 337 338 Request rqh = new Request(); 339 String rqb = ""; 340 ResponseHolder rsh = new ResponseHolder(); 341 GetPropertiesRsHolder rsb = new GetPropertiesRsHolder(); 342 rqh.setReceiverKey(ik); 343 344 System.err.println("##tt"); 345 binding.getProperties(rqh, rqb, rsh, rsb); 347 InstancePropertiesGroup ipg = rsb.value.getInstancePropertiesGroup(); 348 System.err.println("#ipg:" + ipg.getKey()); 349 System.err.println("#ipg:" + ipg.getFactoryKey()); 350 URI[] _obs_ = ipg.getObservers().getObserverKey(); 351 for (int n = 0; n < _obs_.length; ++n) { 352 System.err.println("#ipg" + n + ":" + _obs_[n]); 353 } 354 Event[] _ev_ = ipg.getHistory().getEvent(); 355 for (int n = 0; n < _ev_.length; ++n) { 356 System.err.println("#ipg" + n + "event:" + _ev_[n].getEventType()); 357 System.err.println("#ipg" + n + "event:" + _ev_[n].getTime()); 358 } 359 MessageElement[] ctx = ipg.getContextData().get_any(); 360 for (int n = 0; n < ctx.length; ++n) { 361 System.err.println("#ipg" + n + "ctx:" + ctx[n].toString()); 362 } 363 } 364 365 public void test4asapInstanceBindingUnsubscribe() throws Exception { 366 AsapInstanceBindingStub binding; 367 try { 368 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 369 } catch (javax.xml.rpc.ServiceException jre) { 370 if (jre.getLinkedCause() != null) jre.getLinkedCause() 371 .printStackTrace(); 372 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 373 + jre); 374 } 375 assertNotNull("binding is null", binding); 376 377 binding.setTimeout(60000); 379 380 Request rqh = new Request(); 381 UnsubscribeRq rqb = new UnsubscribeRq(); 382 ResponseHolder rsh = new ResponseHolder(); 383 StringHolder rsb = new StringHolder (); 384 rqh.setReceiverKey(ik); 385 rqb.setObserverKey(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress())); 386 387 binding.unsubscribe(rqh, rqb, rsh, rsb); 389 } 391 392 public void test5asapInstanceBindingChangeState() throws Exception { 393 System.err.println("##ibcss"); 394 AsapInstanceBindingStub binding; 395 try { 396 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 397 } catch (javax.xml.rpc.ServiceException jre) { 398 if (jre.getLinkedCause() != null) jre.getLinkedCause() 399 .printStackTrace(); 400 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 401 + jre); 402 } 403 assertNotNull("binding is null", binding); 404 405 binding.setTimeout(60000); 407 408 Request rqh = new Request(); 409 ChangeStateRq rqb = new ChangeStateRq(); 410 ResponseHolder rsh = new ResponseHolder(); 411 ChangeStateRsHolder rsb = new ChangeStateRsHolder(); 412 rqh.setReceiverKey(ik); 413 rqb.setState(StateType.value2); 414 415 binding.changeState(rqh, rqb, rsh, rsb); 417 System.err.println("##ibcse"); 419 420 } 421 422 public void test5_1asapInstanceBindingChangeState() throws Exception { 423 System.err.println("##ibcss"); 424 AsapInstanceBindingStub binding; 425 try { 426 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(); 427 } catch (javax.xml.rpc.ServiceException jre) { 428 if (jre.getLinkedCause() != null) jre.getLinkedCause() 429 .printStackTrace(); 430 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 431 + jre); 432 } 433 assertNotNull("binding is null", binding); 434 435 binding.setTimeout(60000); 437 438 Request rqh = new Request(); 439 ChangeStateRq rqb = new ChangeStateRq(); 440 ResponseHolder rsh = new ResponseHolder(); 441 ChangeStateRsHolder rsb = new ChangeStateRsHolder(); 442 rqh.setReceiverKey(ik); 443 rqb.setState(StateType.value6); 444 445 binding.changeState(rqh, rqb, rsh, rsb); 447 System.err.println("##ibcse"); 449 450 } 451 } | Popular Tags |