KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > wfxml > test > SharkWebServiceTestCase


1 /*
2  * SharkWebServiceTestCase.java
3  *
4  * This file was auto-generated from WSDL by the Apache Axis WSDL2Java emitter.
5  */

6
7 package org.enhydra.shark.wfxml.test;
8
9 import java.net.InetAddress JavaDoc;
10
11 import javax.xml.namespace.QName JavaDoc;
12 import javax.xml.rpc.holders.ObjectHolder JavaDoc;
13 import javax.xml.rpc.holders.StringHolder JavaDoc;
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 /**
30  * JUnit test case for shark web service wrapper.
31  *
32  * @author V.Puskas
33  */

34 public class SharkWebServiceTestCase extends junit.framework.TestCase {
35    static private URI ik;
36
37    public SharkWebServiceTestCase(java.lang.String JavaDoc name) {
38       super(name);
39       QName JavaDoc xmlType = new javax.xml.namespace.QName JavaDoc("http://www.w3.org/2001/XMLSchema",
40                                                     "anyType");
41       DefaultTypeMappingImpl.getSingleton()
42          .register(String JavaDoc.class,
43                    xmlType,
44                    new AltBeanSerializerFactory(String JavaDoc.class, xmlType),
45                    new AltBeanDeserializerFactory(String JavaDoc.class, xmlType));
46    }
47
48    public void test6asapObserverBindingGetProperties() throws Exception JavaDoc {
49       AsapObserverBindingStub binding;
50       try {
51          binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding();
52       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
61
binding.setTimeout(60000);
62
63       Request rqh = new Request();
64       String JavaDoc rqb = ""; //new java.lang.String();
65
ResponseHolder rsh = new ResponseHolder();
66       GetPropertiesRsHolder rsb = new GetPropertiesRsHolder();
67       rqh.setReceiverKey(new URI("http://vidi"));
68
69       // Test operation
70
binding.getProperties(rqh, rqb, rsh, rsb);
71       // TBD - validate results
72
}
73
74    public void test7asapObserverBindingCompleted() throws Exception JavaDoc {
75       AsapObserverBindingStub binding;
76       try {
77          binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding();
78       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
87
binding.setTimeout(60000);
88
89       Request rqh = new Request();
90       CompletedRq rqb = new CompletedRq();
91       ResponseHolder rsh = new ResponseHolder();
92       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
93       rqh.setReceiverKey(new URI("http://vidi"));
94
95       // Test operation
96
binding.completed(rqh, rqb, rsh, rsb);
97       // TBD - validate results
98
}
99
100    public void test8asapObserverBindingStateChanged() throws Exception JavaDoc {
101       AsapObserverBindingStub binding;
102       try {
103          binding = (AsapObserverBindingStub) new SharkWebServiceLocator().getasapObserverBinding();
104       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
113
binding.setTimeout(60000);
114
115       Request rqh = new Request();
116       StateChangedRq rqb = new StateChangedRq();
117       ResponseHolder rsh = new ResponseHolder();
118       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
119
120       rqh.setReceiverKey(new URI("http://vidi"));
121       // Test operation
122
binding.stateChanged(rqh, rqb, rsh, rsb);
123       // TBD - validate results
124
}
125
126    public void test9asapFactoryBindingGetProperties() throws Exception JavaDoc {
127       WfXmlFactoryBindingStub binding;
128
129       try {
130          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding();
131       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
140
binding.setTimeout(60000);
141       Request rqHead = new Request();
142       String JavaDoc rqBody = ""; // new java.lang.String()
143
ResponseHolder rsHead = new ResponseHolder();
144       GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
145       rqHead.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress()));
146       //rqHead.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
147
//rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
148
rqHead.getReceiverKey()
149          .setQueryString("procDef=Game&packageId=test_bs");
150
151       // Test operation
152
binding.getProperties(rqHead, rqBody, rsHead, rsBody);
153       // TBD - validate results
154
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 JavaDoc {
166       WfXmlFactoryBindingStub binding;
167       try {
168          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding();
169       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
178
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().setQueryString("procMgr=test_js+1+basic");
187
//rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
188
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       // Test operation
196
binding.createInstance(rqHead, rqBody, rsHead, rsBody);
197       System.err.println("##" + rsBody.value.getInstanceKey());
198       // TBD - validate results
199
ik = rsBody.value.getInstanceKey();
200    }
201
202    public void test10asapFactoryBindingGetDefinition() throws Exception JavaDoc {
203       WfXmlFactoryBindingStub binding;
204
205       try {
206          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding();
207       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
216
binding.setTimeout(60000);
217       Request rqHead = new Request();
218       GetDefinitionRq rqBody = new GetDefinitionRq(); // new
219
// java.lang.String()
220
ResponseHolder rsHead = new ResponseHolder();
221       GetDefinitionRsHolder rsBody = new GetDefinitionRsHolder();
222       rqHead.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress()));
223       //rqHead.getReceiverKey().setQueryString("procDef=loop1&packageId=loops");
224

225       // Test operation
226
binding.getDefinition(rqHead, rqBody, rsHead, rsBody);
227       rsBody.value.get_any();
228       // TBD - validate results
229
}
230
231    public void test11asapFactoryBindingListInstances() throws Exception JavaDoc {
232       WfXmlFactoryBindingStub binding;
233       try {
234          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding();
235       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
244
binding.setTimeout(60000);
245
246       Request rqh = new Request();
247       rqh.setReceiverKey(new URI(new SharkWebServiceLocator().getwfxmlFactoryBindingAddress()));
248       //rqh.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
249
//rqh.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
250

251       ListInstancesRq rqb = new ListInstancesRq();
252       ResponseHolder rsh = new ResponseHolder();
253       ListInstancesRsHolder rsb = new ListInstancesRsHolder();
254       // Test operation
255
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(a[n]);
260
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       // TBD - validate results
269
}
270
271    public void test2asapInstanceBindingSetProperties() throws Exception JavaDoc {
272       AsapInstanceBindingStub binding;
273       try {
274          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
275       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
284
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       // Test operation
293
binding.setProperties(rqh, rqb, rsh, rsb);
294       // TBD - validate results
295
}
296
297    public void test3asapInstanceBindingSubscribe() throws Exception JavaDoc {
298       AsapInstanceBindingStub binding;
299       try {
300          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
301       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
310
binding.setTimeout(60000);
311
312       Request rqh = new Request();
313       SubscribeRq rqb = new SubscribeRq();
314       ResponseHolder rsh = new ResponseHolder();
315       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
316       rqh.setReceiverKey(ik);
317       rqb.setObserverKey(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()));
318       // Test operation
319
binding.subscribe(rqh, rqb, rsh, rsb);
320       // TBD - validate results
321
}
322
323    public void test1asapInstanceBindingGetProperties() throws Exception JavaDoc {
324       AsapInstanceBindingStub binding;
325       try {
326          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
327       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
336
binding.setTimeout(60000);
337
338       Request rqh = new Request();
339       String JavaDoc rqb = "";
340       ResponseHolder rsh = new ResponseHolder();
341       GetPropertiesRsHolder rsb = new GetPropertiesRsHolder();
342       rqh.setReceiverKey(ik);
343
344       System.err.println("##tt");
345       // Test operation
346
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 JavaDoc {
366       AsapInstanceBindingStub binding;
367       try {
368          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
369       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
378
binding.setTimeout(60000);
379
380       Request rqh = new Request();
381       UnsubscribeRq rqb = new UnsubscribeRq();
382       ResponseHolder rsh = new ResponseHolder();
383       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
384       rqh.setReceiverKey(ik);
385       rqb.setObserverKey(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()));
386
387       // Test operation
388
binding.unsubscribe(rqh, rqb, rsh, rsb);
389       // TBD - validate results
390
}
391
392    public void test5asapInstanceBindingChangeState() throws Exception JavaDoc {
393       System.err.println("##ibcss");
394       AsapInstanceBindingStub binding;
395       try {
396          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
397       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
406
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       // Test operation
416
binding.changeState(rqh, rqb, rsh, rsb);
417       // TBD - validate results
418
System.err.println("##ibcse");
419
420    }
421
422    public void test5_1asapInstanceBindingChangeState() throws Exception JavaDoc {
423       System.err.println("##ibcss");
424       AsapInstanceBindingStub binding;
425       try {
426          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding();
427       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
436
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       // Test operation
446
binding.changeState(rqh, rqb, rsh, rsb);
447       // TBD - validate results
448
System.err.println("##ibcse");
449
450    }
451 }
Popular Tags