KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > asap > 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.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 JavaDoc;
14 import javax.xml.rpc.holders.ObjectHolder JavaDoc;
15 import javax.xml.rpc.holders.StringHolder JavaDoc;
16 import org.apache.axis.message.MessageElement;
17 import org.apache.axis.types.URI;
18
19 /**
20  * JUnit test case for shark web service wrapper.
21  *
22  * @author V.Puskas
23  */

24 public class SharkWebServiceTestCase extends junit.framework.TestCase {
25    static private URI ik;
26
27    public SharkWebServiceTestCase(java.lang.String JavaDoc name) {
28       super(name);
29    }
30
31
32    public void test6asapObserverBindingGetProperties() throws Exception JavaDoc {
33       AsapObserverBindingStub binding;
34       try {
35          binding = (AsapObserverBindingStub) new SharkWebServiceLocator()
36                .getasapObserverBinding();
37       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
46
binding.setTimeout(60000);
47
48       Request rqh = new Request();
49       String JavaDoc rqb = ""; //new java.lang.String();
50
ResponseHolder rsh = new ResponseHolder();
51       GetPropertiesRsHolder rsb = new GetPropertiesRsHolder();
52       rqh.setReceiverKey(new URI("http://vidi"));
53
54       // Test operation
55
binding.getProperties(rqh, rqb, rsh, rsb);
56       // TBD - validate results
57
}
58
59    public void test7asapObserverBindingCompleted() throws Exception JavaDoc {
60       AsapObserverBindingStub binding;
61       try {
62          binding = (AsapObserverBindingStub) new SharkWebServiceLocator()
63                .getasapObserverBinding();
64       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
73
binding.setTimeout(60000);
74
75       Request rqh = new Request();
76       CompletedRq rqb = new CompletedRq();
77       ResponseHolder rsh = new ResponseHolder();
78       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
79       rqh.setReceiverKey(new URI("http://vidi"));
80
81       // Test operation
82
binding.completed(rqh, rqb, rsh, rsb);
83       // TBD - validate results
84
}
85
86    public void test8asapObserverBindingStateChanged() throws Exception JavaDoc {
87       AsapObserverBindingStub binding;
88       try {
89          binding = (AsapObserverBindingStub) new SharkWebServiceLocator()
90                .getasapObserverBinding();
91       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
100
binding.setTimeout(60000);
101
102       Request rqh = new Request();
103       StateChangedRq rqb = new StateChangedRq();
104       ResponseHolder rsh = new ResponseHolder();
105       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
106
107       rqh.setReceiverKey(new URI("http://vidi"));
108       // Test operation
109
binding.stateChanged(rqh, rqb, rsh, rsb);
110       // TBD - validate results
111
}
112
113    public void test9asapFactoryBindingGetProperties() throws Exception JavaDoc {
114       AsapFactoryBindingStub binding;
115
116       try {
117          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
118                .getasapFactoryBinding();
119       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
128
binding.setTimeout(60000);
129       Request rqHead = new Request();
130       String JavaDoc rqBody = ""; // new java.lang.String()
131
ResponseHolder rsHead = new ResponseHolder();
132       GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
133       rqHead.setReceiverKey(new URI("http://vidi"));
134
135       // Test operation
136
binding.getProperties(rqHead, rqBody, rsHead, rsBody);
137       // TBD - validate results
138
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 JavaDoc {
148       AsapFactoryBindingStub binding;
149       try {
150          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
151                .getasapFactoryBinding();
152       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
161
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("procMgr=test_js+1+basic");
171
//rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
172
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       // Test operation
178
binding.createInstance(rqHead, rqBody, rsHead, rsBody);
179       System.err.println("##" + rsBody.value.getInstanceKey());
180       // TBD - validate results
181
ik = rsBody.value.getInstanceKey();
182    }
183
184    public void test11asapFactoryBindingListInstances() throws Exception JavaDoc {
185       AsapFactoryBindingStub binding;
186       try {
187          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
188                .getasapFactoryBinding();
189       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
198
binding.setTimeout(60000);
199
200       Request rqh = new Request();
201       rqh.setReceiverKey(new URI(new SharkWebServiceLocator()
202             .getasapFactoryBindingAddress()));
203       //rqh.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
204
//rqh.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
205

206       ListInstancesRq rqb = new ListInstancesRq();
207       ResponseHolder rsh = new ResponseHolder();
208       ListInstancesRsHolder rsb = new ListInstancesRsHolder();
209       // Test operation
210
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]);
215
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       // TBD - validate results
222
}
223
224    public void test2asapInstanceBindingSetProperties() throws Exception JavaDoc {
225       AsapInstanceBindingStub binding;
226       try {
227          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
228                .getasapInstanceBinding();
229       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
238
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       // Test operation
247
binding.setProperties(rqh, rqb,
248             rsh, rsb);
249       // TBD - validate results
250
}
251
252    public void test3asapInstanceBindingSubscribe() throws Exception JavaDoc {
253       AsapInstanceBindingStub binding;
254       try {
255          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
256                .getasapInstanceBinding();
257       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
266
binding.setTimeout(60000);
267
268       Request rqh = new Request();
269       SubscribeRq rqb = new SubscribeRq();
270       ResponseHolder rsh = new ResponseHolder();
271       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
272       rqh.setReceiverKey(ik);
273       rqb.setObserverKey(new URI(new SharkWebServiceLocator()
274             .getasapObserverBindingAddress()));
275       // Test operation
276
binding.subscribe(rqh, rqb, rsh, rsb);
277       // TBD - validate results
278
}
279
280    public void test1asapInstanceBindingGetProperties() throws Exception JavaDoc {
281       AsapInstanceBindingStub binding;
282       try {
283          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
284                .getasapInstanceBinding();
285       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
294
binding.setTimeout(60000);
295
296       Request rqh = new Request();
297       String JavaDoc rqb = "";
298       ResponseHolder rsh = new ResponseHolder();
299       GetPropertiesRsHolder rsb = new GetPropertiesRsHolder();
300       rqh.setReceiverKey(ik);
301
302       System.err.println("##tt");
303       // Test operation
304
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 JavaDoc {
324       AsapInstanceBindingStub binding;
325       try {
326          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
327                .getasapInstanceBinding();
328       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
337
binding.setTimeout(60000);
338
339       Request rqh = new Request();
340       UnsubscribeRq rqb = new UnsubscribeRq();
341       ResponseHolder rsh = new ResponseHolder();
342       StringHolder JavaDoc rsb = new StringHolder JavaDoc();
343       rqh.setReceiverKey(ik);
344       rqb.setObserverKey(new URI(new SharkWebServiceLocator()
345             .getasapObserverBindingAddress()));
346
347       // Test operation
348
binding.unsubscribe(rqh, rqb, rsh, rsb);
349       // TBD - validate results
350
}
351
352    public void test5asapInstanceBindingChangeState() throws Exception JavaDoc {
353       System.err.println("##ibcss");
354       AsapInstanceBindingStub binding;
355       try {
356          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
357                .getasapInstanceBinding();
358       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
367
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       // Test operation
378
binding.changeState(rqh, rqb, rsh, rsb);
379       // TBD - validate results
380
System.err.println("##ibcse");
381
382
383    }
384
385    public void test5_1asapInstanceBindingChangeState() throws Exception JavaDoc {
386       System.err.println("##ibcss");
387       AsapInstanceBindingStub binding;
388       try {
389          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
390                .getasapInstanceBinding();
391       } catch (javax.xml.rpc.ServiceException JavaDoc 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       // Time out after a minute
400
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       // Test operation
411
binding.changeState(rqh, rqb, rsh, rsb);
412       // TBD - validate results
413
System.err.println("##ibcse");
414
415
416    }
417 }
418
Popular Tags