1 6 7 package org.enhydra.shark.asap.test; 8 9 import org.enhydra.shark.asap.*; 10 import org.enhydra.shark.asap.types.*; 11 import org.enhydra.shark.asap.types.holders.*; 12 13 import java.net.InetAddress ; 14 import javax.xml.rpc.holders.ObjectHolder ; 15 import javax.xml.rpc.holders.StringHolder ; 16 import org.apache.axis.message.MessageElement; 17 import org.apache.axis.types.URI; 18 19 24 public class SharkWebServiceTestCase extends junit.framework.TestCase { 25 static private URI ik; 26 27 public SharkWebServiceTestCase(java.lang.String name) { 28 super(name); 29 } 30 31 32 public void test6asapObserverBindingGetProperties() throws Exception { 33 AsapObserverBindingStub binding; 34 try { 35 binding = (AsapObserverBindingStub) new SharkWebServiceLocator() 36 .getasapObserverBinding(); 37 } catch (javax.xml.rpc.ServiceException jre) { 38 if (jre.getLinkedCause() != null) 39 jre.getLinkedCause().printStackTrace(); 40 throw new junit.framework.AssertionFailedError( 41 "JAX-RPC ServiceException caught: " + jre); 42 } 43 assertNotNull("binding is null", binding); 44 45 binding.setTimeout(60000); 47 48 Request rqh = new Request(); 49 String rqb = ""; ResponseHolder rsh = new ResponseHolder(); 51 GetPropertiesRsHolder rsb = new GetPropertiesRsHolder(); 52 rqh.setReceiverKey(new URI("http://vidi")); 53 54 binding.getProperties(rqh, rqb, rsh, rsb); 56 } 58 59 public void test7asapObserverBindingCompleted() throws Exception { 60 AsapObserverBindingStub binding; 61 try { 62 binding = (AsapObserverBindingStub) new SharkWebServiceLocator() 63 .getasapObserverBinding(); 64 } catch (javax.xml.rpc.ServiceException jre) { 65 if (jre.getLinkedCause() != null) 66 jre.getLinkedCause().printStackTrace(); 67 throw new junit.framework.AssertionFailedError( 68 "JAX-RPC ServiceException caught: " + jre); 69 } 70 assertNotNull("binding is null", binding); 71 72 binding.setTimeout(60000); 74 75 Request rqh = new Request(); 76 CompletedRq rqb = new CompletedRq(); 77 ResponseHolder rsh = new ResponseHolder(); 78 StringHolder rsb = new StringHolder (); 79 rqh.setReceiverKey(new URI("http://vidi")); 80 81 binding.completed(rqh, rqb, rsh, rsb); 83 } 85 86 public void test8asapObserverBindingStateChanged() throws Exception { 87 AsapObserverBindingStub binding; 88 try { 89 binding = (AsapObserverBindingStub) new SharkWebServiceLocator() 90 .getasapObserverBinding(); 91 } catch (javax.xml.rpc.ServiceException jre) { 92 if (jre.getLinkedCause() != null) 93 jre.getLinkedCause().printStackTrace(); 94 throw new junit.framework.AssertionFailedError( 95 "JAX-RPC ServiceException caught: " + jre); 96 } 97 assertNotNull("binding is null", binding); 98 99 binding.setTimeout(60000); 101 102 Request rqh = new Request(); 103 StateChangedRq rqb = new StateChangedRq(); 104 ResponseHolder rsh = new ResponseHolder(); 105 StringHolder rsb = new StringHolder (); 106 107 rqh.setReceiverKey(new URI("http://vidi")); 108 binding.stateChanged(rqh, rqb, rsh, rsb); 110 } 112 113 public void test9asapFactoryBindingGetProperties() throws Exception { 114 AsapFactoryBindingStub binding; 115 116 try { 117 binding = (AsapFactoryBindingStub) new SharkWebServiceLocator() 118 .getasapFactoryBinding(); 119 } catch (javax.xml.rpc.ServiceException jre) { 120 if (jre.getLinkedCause() != null) 121 jre.getLinkedCause().printStackTrace(); 122 throw new junit.framework.AssertionFailedError( 123 "JAX-RPC ServiceException caught: " + jre); 124 } 125 assertNotNull("binding is null", binding); 126 127 binding.setTimeout(60000); 129 Request rqHead = new Request(); 130 String rqBody = ""; ResponseHolder rsHead = new ResponseHolder(); 132 GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder(); 133 rqHead.setReceiverKey(new URI("http://vidi")); 134 135 binding.getProperties(rqHead, rqBody, rsHead, rsBody); 137 FactoryPropertiesGroup fpg=rsBody.value.getFactoryPropertiesGroup(); 139 System.err.println("Key="+fpg.getKey()); 140 System.err.println("Name="+fpg.getName()); 141 System.err.println("Subj="+fpg.getSubject()); 142 System.err.println("desc="+fpg.getDescription()); 143 System.err.println("cds="+fpg.getContextDataSchema().get_any()[0].toString()); 144 System.err.println("rds="+fpg.getResultDataSchema().get_any()[0].toString()); 145 } 146 147 public void test10asapFactoryBindingCreateInstance() throws Exception { 148 AsapFactoryBindingStub binding; 149 try { 150 binding = (AsapFactoryBindingStub) new SharkWebServiceLocator() 151 .getasapFactoryBinding(); 152 } catch (javax.xml.rpc.ServiceException jre) { 153 if (jre.getLinkedCause() != null) 154 jre.getLinkedCause().printStackTrace(); 155 throw new junit.framework.AssertionFailedError( 156 "JAX-RPC ServiceException caught: " + jre); 157 } 158 assertNotNull("binding is null", binding); 159 160 binding.setTimeout(60000); 162 163 Request rqHead = new Request(); 164 CreateInstanceRq rqBody = new CreateInstanceRq(); 165 ResponseHolder rsHead = new ResponseHolder(); 166 CreateInstanceRsHolder rsBody = new CreateInstanceRsHolder(); 167 168 rqHead.setReceiverKey(new URI(new SharkWebServiceLocator() 169 .getasapFactoryBindingAddress())); 170 rqHead.getReceiverKey().setQueryString("procDef=Game&packageId=test_js"); 173 rqBody.setObserverKey(new URI(new SharkWebServiceLocator() 174 .getasapObserverBindingAddress())); 175 rqBody.getObserverKey().setHost(InetAddress.getLocalHost().getHostName()); 176 rqBody.setStartImmediately(true); 177 binding.createInstance(rqHead, rqBody, rsHead, rsBody); 179 System.err.println("##" + rsBody.value.getInstanceKey()); 180 ik = rsBody.value.getInstanceKey(); 182 } 183 184 public void test11asapFactoryBindingListInstances() throws Exception { 185 AsapFactoryBindingStub binding; 186 try { 187 binding = (AsapFactoryBindingStub) new SharkWebServiceLocator() 188 .getasapFactoryBinding(); 189 } catch (javax.xml.rpc.ServiceException jre) { 190 if (jre.getLinkedCause() != null) 191 jre.getLinkedCause().printStackTrace(); 192 throw new junit.framework.AssertionFailedError( 193 "JAX-RPC ServiceException caught: " + jre); 194 } 195 assertNotNull("binding is null", binding); 196 197 binding.setTimeout(60000); 199 200 Request rqh = new Request(); 201 rqh.setReceiverKey(new URI(new SharkWebServiceLocator() 202 .getasapFactoryBindingAddress())); 203 206 ListInstancesRq rqb = new ListInstancesRq(); 207 ResponseHolder rsh = new ResponseHolder(); 208 ListInstancesRsHolder rsb = new ListInstancesRsHolder(); 209 binding.listInstances(rqh, rqb, rsh, rsb); 211 Instance[] a = rsb.value.getInstance(); 212 if (null != a) { 213 for (int n = 0; n < a.length; ++n) { 214 System.err.println("[" + a[n].getInstanceKey() + ", " 216 + a[n].getName() + ", " + a[n].getSubject() + "]"); 217 } 218 } else { 219 System.err.println("getInstance value is null"); 220 } 221 } 223 224 public void test2asapInstanceBindingSetProperties() throws Exception { 225 AsapInstanceBindingStub binding; 226 try { 227 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 228 .getasapInstanceBinding(); 229 } catch (javax.xml.rpc.ServiceException jre) { 230 if (jre.getLinkedCause() != null) 231 jre.getLinkedCause().printStackTrace(); 232 throw new junit.framework.AssertionFailedError( 233 "JAX-RPC ServiceException caught: " + jre); 234 } 235 assertNotNull("binding is null", binding); 236 237 binding.setTimeout(60000); 239 240 Request rqh = new Request(); 241 SetPropertiesRq rqb = new SetPropertiesRq(); 242 ResponseHolder rsh = new ResponseHolder(); 243 SetPropertiesRsHolder rsb = new SetPropertiesRsHolder(); 244 rqh.setReceiverKey(new URI("http://vidi")); 245 246 binding.setProperties(rqh, rqb, 248 rsh, rsb); 249 } 251 252 public void test3asapInstanceBindingSubscribe() throws Exception { 253 AsapInstanceBindingStub binding; 254 try { 255 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 256 .getasapInstanceBinding(); 257 } catch (javax.xml.rpc.ServiceException jre) { 258 if (jre.getLinkedCause() != null) 259 jre.getLinkedCause().printStackTrace(); 260 throw new junit.framework.AssertionFailedError( 261 "JAX-RPC ServiceException caught: " + jre); 262 } 263 assertNotNull("binding is null", binding); 264 265 binding.setTimeout(60000); 267 268 Request rqh = new Request(); 269 SubscribeRq rqb = new SubscribeRq(); 270 ResponseHolder rsh = new ResponseHolder(); 271 StringHolder rsb = new StringHolder (); 272 rqh.setReceiverKey(ik); 273 rqb.setObserverKey(new URI(new SharkWebServiceLocator() 274 .getasapObserverBindingAddress())); 275 binding.subscribe(rqh, rqb, rsh, rsb); 277 } 279 280 public void test1asapInstanceBindingGetProperties() throws Exception { 281 AsapInstanceBindingStub binding; 282 try { 283 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 284 .getasapInstanceBinding(); 285 } catch (javax.xml.rpc.ServiceException jre) { 286 if (jre.getLinkedCause() != null) 287 jre.getLinkedCause().printStackTrace(); 288 throw new junit.framework.AssertionFailedError( 289 "JAX-RPC ServiceException caught: " + jre); 290 } 291 assertNotNull("binding is null", binding); 292 293 binding.setTimeout(60000); 295 296 Request rqh = new Request(); 297 String rqb = ""; 298 ResponseHolder rsh = new ResponseHolder(); 299 GetPropertiesRsHolder rsb = new GetPropertiesRsHolder(); 300 rqh.setReceiverKey(ik); 301 302 System.err.println("##tt"); 303 binding.getProperties(rqh, rqb, rsh, rsb); 305 InstancePropertiesGroup ipg = rsb.value.getInstancePropertiesGroup(); 306 System.err.println("#ipg:"+ipg.getKey()); 307 System.err.println("#ipg:"+ipg.getFactoryKey()); 308 URI[] _obs_ = ipg.getObservers().getObserverKey(); 309 for (int n = 0; n < _obs_.length; ++n) { 310 System.err.println("#ipg"+n+":"+_obs_[n]); 311 } 312 Event[] _ev_ = ipg.getHistory().getEvent(); 313 for (int n = 0; n <_ev_.length; ++n) { 314 System.err.println("#ipg"+n+"event:"+_ev_[n].getEventType()); 315 System.err.println("#ipg"+n+"event:"+_ev_[n].getTime()); 316 } 317 MessageElement[] ctx = ipg.getContextData().get_any(); 318 for (int n = 0; n <ctx.length; ++n) { 319 System.err.println("#ipg"+n+"ctx:"+ctx[n].toString()); 320 } 321 } 322 323 public void test4asapInstanceBindingUnsubscribe() throws Exception { 324 AsapInstanceBindingStub binding; 325 try { 326 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 327 .getasapInstanceBinding(); 328 } catch (javax.xml.rpc.ServiceException jre) { 329 if (jre.getLinkedCause() != null) 330 jre.getLinkedCause().printStackTrace(); 331 throw new junit.framework.AssertionFailedError( 332 "JAX-RPC ServiceException caught: " + jre); 333 } 334 assertNotNull("binding is null", binding); 335 336 binding.setTimeout(60000); 338 339 Request rqh = new Request(); 340 UnsubscribeRq rqb = new UnsubscribeRq(); 341 ResponseHolder rsh = new ResponseHolder(); 342 StringHolder rsb = new StringHolder (); 343 rqh.setReceiverKey(ik); 344 rqb.setObserverKey(new URI(new SharkWebServiceLocator() 345 .getasapObserverBindingAddress())); 346 347 binding.unsubscribe(rqh, rqb, rsh, rsb); 349 } 351 352 public void test5asapInstanceBindingChangeState() throws Exception { 353 System.err.println("##ibcss"); 354 AsapInstanceBindingStub binding; 355 try { 356 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 357 .getasapInstanceBinding(); 358 } catch (javax.xml.rpc.ServiceException jre) { 359 if (jre.getLinkedCause() != null) 360 jre.getLinkedCause().printStackTrace(); 361 throw new junit.framework.AssertionFailedError( 362 "JAX-RPC ServiceException caught: " + jre); 363 } 364 assertNotNull("binding is null", binding); 365 366 binding.setTimeout(60000); 368 369 370 Request rqh = new Request(); 371 ChangeStateRq rqb = new ChangeStateRq(); 372 ResponseHolder rsh = new ResponseHolder(); 373 ChangeStateRsHolder rsb = new ChangeStateRsHolder(); 374 rqh.setReceiverKey(ik); 375 rqb.setState(StateType.value2); 376 377 binding.changeState(rqh, rqb, rsh, rsb); 379 System.err.println("##ibcse"); 381 382 383 } 384 385 public void test5_1asapInstanceBindingChangeState() throws Exception { 386 System.err.println("##ibcss"); 387 AsapInstanceBindingStub binding; 388 try { 389 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator() 390 .getasapInstanceBinding(); 391 } catch (javax.xml.rpc.ServiceException jre) { 392 if (jre.getLinkedCause() != null) 393 jre.getLinkedCause().printStackTrace(); 394 throw new junit.framework.AssertionFailedError( 395 "JAX-RPC ServiceException caught: " + jre); 396 } 397 assertNotNull("binding is null", binding); 398 399 binding.setTimeout(60000); 401 402 403 Request rqh = new Request(); 404 ChangeStateRq rqb = new ChangeStateRq(); 405 ResponseHolder rsh = new ResponseHolder(); 406 ChangeStateRsHolder rsb = new ChangeStateRsHolder(); 407 rqh.setReceiverKey(ik); 408 rqb.setState(StateType.value6); 409 410 binding.changeState(rqh, rqb, rsh, rsb); 412 System.err.println("##ibcse"); 414 415 416 } 417 } 418 | Popular Tags |