KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > asap > test > ForeignWebServiceTestCase


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 java.net.URL JavaDoc;
10
11 import org.apache.axis.types.URI;
12 import org.enhydra.shark.asap.AsapFactoryBindingStub;
13 import org.enhydra.shark.asap.SharkWebServiceLocator;
14 import org.enhydra.shark.asap.types.FactoryPropertiesGroup;
15 import org.enhydra.shark.asap.types.Request;
16 import org.enhydra.shark.asap.types.holders.GetPropertiesRsHolder;
17 import org.enhydra.shark.asap.types.holders.ResponseHolder;
18
19 /**
20  * JUnit test case for shark web service wrapper.
21  *
22  * @author V.Puskas
23  */

24 public class ForeignWebServiceTestCase extends junit.framework.TestCase {
25    static private URI ik;
26
27    public ForeignWebServiceTestCase(java.lang.String JavaDoc 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       // Time out after a minute
46       binding.setTimeout(60000);
47
48       _Request rqh = new _Request();
49       Object 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,
56             rsh, rsb);
57       // TBD - validate results
58    }
59
60    public void test7asapObserverBindingCompleted() throws Exception {
61       AsapObserverBindingStub binding;
62       try {
63          binding = (AsapObserverBindingStub) new SharkWebServiceLocator()
64                .getasapObserverBinding();
65       } catch (javax.xml.rpc.ServiceException jre) {
66          if (jre.getLinkedCause() != null)
67             jre.getLinkedCause().printStackTrace();
68          throw new junit.framework.AssertionFailedError(
69                "JAX-RPC ServiceException caught: " + jre);
70       }
71       assertNotNull("binding is null", binding);
72
73       // Time out after a minute
74       binding.setTimeout(60000);
75
76       _Request rqh = new _Request();
77       _CompletedRq rqb = new _CompletedRq();
78       _ResponseHolder rsh = new _ResponseHolder();
79       ObjectHolder rsb = new javax.xml.rpc.holders.ObjectHolder();
80       rqh.setReceiverKey(new URI("http://vidi"));
81
82       // Test operation
83       binding.completed(rqh, rqb,
84             rsh, rsb);
85       // TBD - validate results
86    }
87
88    public void test8asapObserverBindingStateChanged() throws Exception {
89       AsapObserverBindingStub binding;
90       try {
91          binding = (AsapObserverBindingStub) new SharkWebServiceLocator()
92                .getasapObserverBinding();
93       } catch (javax.xml.rpc.ServiceException jre) {
94          if (jre.getLinkedCause() != null)
95             jre.getLinkedCause().printStackTrace();
96          throw new junit.framework.AssertionFailedError(
97                "JAX-RPC ServiceException caught: " + jre);
98       }
99       assertNotNull("binding is null", binding);
100
101       // Time out after a minute
102       binding.setTimeout(60000);
103
104       _Request rqh = new _Request();
105       _StateChangedRq rqb = new _StateChangedRq();
106       _ResponseHolder rsh = new _ResponseHolder();
107       ObjectHolder rsb = new javax.xml.rpc.holders.ObjectHolder();
108
109       rqh.setReceiverKey(new URI("http://vidi"));
110       // Test operation
111       binding.stateChanged(rqh, rqb,
112             rsh, rsb);
113       // TBD - validate results
114    }
115 */

116    public void test9asapFactoryBindingGetProperties() throws Exception JavaDoc {
117       AsapFactoryBindingStub binding;
118       String JavaDoc uriString;
119       //uriString = "http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Manufacturer";
120
uriString = "http://www.staffware.co.za:8080/ASAPServer/FactoryService.asmx";
121       //uriString = "http://68.96.20.206:7787/asap_evm";;
122
//uriString = "http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Retailer";
123

124       try {
125          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
126          //.getasapFactoryBinding(new URL());
127
.getasapFactoryBinding(new URL JavaDoc(uriString));
128          //
129
} catch (javax.xml.rpc.ServiceException JavaDoc jre) {
130          if (jre.getLinkedCause() != null)
131             jre.getLinkedCause().printStackTrace();
132          throw new junit.framework.AssertionFailedError(
133                "JAX-RPC ServiceException caught: " + jre);
134       }
135       assertNotNull("binding is null", binding);
136
137       // Time out after a minute
138
binding.setTimeout(60000);
139       Request rqHead = new Request();
140       String JavaDoc rqBody = ""; // new java.lang.String()
141
ResponseHolder rsHead = new ResponseHolder();
142       GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
143       rqHead.setReceiverKey(new URI(uriString));
144
145       // Test operation
146
try {
147          binding.getProperties(rqHead, rqBody, rsHead, rsBody);
148       } catch (Throwable JavaDoc t) {
149          System.err.println("Throwable "+t.getClass().getName()+"("+t.getMessage()+")");
150       }
151       Object JavaDoc []oo = binding.getResponseHeaders();
152       for (int n = 0; n < oo.length; ++n) {
153          System.err.println(""+n+"#"+binding.getResponseHeaders()[n].toString());
154       }
155       // TBD - validate results
156
System.err.println("res"+rsBody.value);
157       FactoryPropertiesGroup fpg=rsBody.value.getFactoryPropertiesGroup();
158       System.err.println("Key="+fpg.getKey());
159       System.err.println("Name="+fpg.getName());
160       System.err.println("Subj="+fpg.getSubject());
161       System.err.println("desc="+fpg.getDescription());
162       System.err.println("cds="+fpg.getContextDataSchema().get_any()[0].toString());
163       System.err.println("rds="+fpg.getResultDataSchema().get_any()[0].toString());
164    }
165 /*
166    public void test10asapFactoryBindingCreateInstance() throws Exception {
167       AsapFactoryBindingStub binding;
168       try {
169          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
170                .getasapFactoryBinding();
171       } catch (javax.xml.rpc.ServiceException jre) {
172          if (jre.getLinkedCause() != null)
173             jre.getLinkedCause().printStackTrace();
174          throw new junit.framework.AssertionFailedError(
175                "JAX-RPC ServiceException caught: " + jre);
176       }
177       assertNotNull("binding is null", binding);
178
179       // Time out after a minute
180       binding.setTimeout(60000);
181
182       _Request rqHead = new _Request();
183       _CreateInstanceRq rqBody = new _CreateInstanceRq();
184       _ResponseHolder rsHead = new _ResponseHolder();
185       _CreateInstanceRsHolder rsBody = new _CreateInstanceRsHolder();
186
187       rqHead.setReceiverKey(new URI(new SharkWebServiceLocator()
188             .getasapFactoryBindingAddress()));
189       //rqHead.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
190       //rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
191       rqHead.getReceiverKey().setQueryString("procDef=Game&packageId=test_js");
192       rqBody.setObserverKey(new URI(new SharkWebServiceLocator()
193             .getasapObserverBindingAddress()));
194       rqBody.getObserverKey().setHost(InetAddress.getLocalHost().getHostName());
195       rqBody.setStartImmediately(true);
196       // Test operation
197       binding.createInstance(rqHead, rqBody, rsHead, rsBody);
198       System.err.println("##" + rsBody.value.getInstanceKey());
199       // TBD - validate results
200       ik = rsBody.value.getInstanceKey();
201    }
202
203    public void test11asapFactoryBindingListInstances() throws Exception {
204       AsapFactoryBindingStub binding;
205       try {
206          binding = (AsapFactoryBindingStub) new SharkWebServiceLocator()
207                .getasapFactoryBinding();
208       } catch (javax.xml.rpc.ServiceException jre) {
209          if (jre.getLinkedCause() != null)
210             jre.getLinkedCause().printStackTrace();
211          throw new junit.framework.AssertionFailedError(
212                "JAX-RPC ServiceException caught: " + jre);
213       }
214       assertNotNull("binding is null", binding);
215
216       // Time out after a minute
217       binding.setTimeout(60000);
218
219       _Request rqh = new _Request();
220       rqh.setReceiverKey(new URI(new SharkWebServiceLocator()
221             .getasapFactoryBindingAddress()));
222       //rqh.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
223       //rqh.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
224
225       _ListInstancesRq rqb = new _ListInstancesRq();
226       _ResponseHolder rsh = new _ResponseHolder();
227       _ListInstancesRsHolder rsb = new _ListInstancesRsHolder();
228       // Test operation
229       binding.listInstances(rqh, rqb, rsh, rsb);
230       _Instance[] a = rsb.value.getInstance();
231       if (null != a) {
232          for (int n = 0; n < a.length; ++n) {
233             //System.err.println(a[n]);
234             System.err.println("[" + a[n].getInstanceKey() + ", "
235                   + a[n].getName() + ", " + a[n].getSubject() + "]");
236          }
237       } else {
238          System.err.println("getInstance value is null");
239       }
240       // TBD - validate results
241    }
242
243    public void test2asapInstanceBindingSetProperties() throws Exception {
244       AsapInstanceBindingStub binding;
245       try {
246          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
247                .getasapInstanceBinding();
248       } catch (javax.xml.rpc.ServiceException jre) {
249          if (jre.getLinkedCause() != null)
250             jre.getLinkedCause().printStackTrace();
251          throw new junit.framework.AssertionFailedError(
252                "JAX-RPC ServiceException caught: " + jre);
253       }
254       assertNotNull("binding is null", binding);
255
256       // Time out after a minute
257       binding.setTimeout(60000);
258
259       _Request rqh = new _Request();
260       _SetPropertiesRq rqb = new _SetPropertiesRq();
261       _ResponseHolder rsh = new _ResponseHolder();
262       _SetPropertiesRsHolder rsb = new _SetPropertiesRsHolder();
263       rqh.setReceiverKey(new URI("http://vidi"));
264
265       // Test operation
266       binding.setProperties(rqh, rqb,
267             rsh, rsb);
268       // TBD - validate results
269    }
270
271    public void test3asapInstanceBindingSubscribe() throws Exception {
272       AsapInstanceBindingStub binding;
273       try {
274          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
275                .getasapInstanceBinding();
276       } catch (javax.xml.rpc.ServiceException jre) {
277          if (jre.getLinkedCause() != null)
278             jre.getLinkedCause().printStackTrace();
279          throw new junit.framework.AssertionFailedError(
280                "JAX-RPC ServiceException caught: " + jre);
281       }
282       assertNotNull("binding is null", binding);
283
284       // Time out after a minute
285       binding.setTimeout(60000);
286
287       _Request rqh = new _Request();
288       _SubscribeRq rqb = new _SubscribeRq();
289       _ResponseHolder rsh = new _ResponseHolder();
290       ObjectHolder rsb = new javax.xml.rpc.holders.ObjectHolder();
291       rqh.setReceiverKey(ik);
292       rqb.setObserverKey(new URI(new SharkWebServiceLocator()
293             .getasapObserverBindingAddress()));
294       // Test operation
295       binding.subscribe(rqh, rqb, rsh, rsb);
296       // TBD - validate results
297    }
298
299    public void test1asapInstanceBindingGetProperties() throws Exception {
300       AsapInstanceBindingStub binding;
301       try {
302          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
303                .getasapInstanceBinding();
304       } catch (javax.xml.rpc.ServiceException jre) {
305          if (jre.getLinkedCause() != null)
306             jre.getLinkedCause().printStackTrace();
307          throw new junit.framework.AssertionFailedError(
308                "JAX-RPC ServiceException caught: " + jre);
309       }
310       assertNotNull("binding is null", binding);
311
312       // Time out after a minute
313       binding.setTimeout(60000);
314
315       _Request rqh = new _Request();
316       Object rqb = new java.lang.String();
317       _ResponseHolder rsh = new _ResponseHolder();
318       _GetPropertiesRsHolder rsb = new _GetPropertiesRsHolder();
319       rqh.setReceiverKey(ik);
320
321       System.err.println("##tt");
322       // Test operation
323       binding.getProperties(rqh, rqb, rsh, rsb);
324       InstancePropertiesGroup ipg = rsb.value.getInstancePropertiesGroup();
325       System.err.println("#ipg:"+ipg.getKey());
326       System.err.println("#ipg:"+ipg.getFactoryKey());
327        URI[] _obs_ = ipg.getObservers().getObserverKey();
328       for (int n = 0; n < _obs_.length; ++n) {
329          System.err.println("#ipg"+n+":"+_obs_[n]);
330       }
331       _Event[] _ev_ = ipg.getHistory().getEvent();
332       for (int n = 0; n <_ev_.length; ++n) {
333          System.err.println("#ipg"+n+"event:"+_ev_[n].getEventType());
334          System.err.println("#ipg"+n+"event:"+_ev_[n].getTime());
335       }
336       MessageElement[] ctx = ipg.getContextData().get_any();
337       for (int n = 0; n <ctx.length; ++n) {
338          System.err.println("#ipg"+n+"ctx:"+ctx[n].toString());
339       }
340    }
341
342    public void test4asapInstanceBindingUnsubscribe() throws Exception {
343       AsapInstanceBindingStub binding;
344       try {
345          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
346                .getasapInstanceBinding();
347       } catch (javax.xml.rpc.ServiceException jre) {
348          if (jre.getLinkedCause() != null)
349             jre.getLinkedCause().printStackTrace();
350          throw new junit.framework.AssertionFailedError(
351                "JAX-RPC ServiceException caught: " + jre);
352       }
353       assertNotNull("binding is null", binding);
354
355       // Time out after a minute
356       binding.setTimeout(60000);
357
358       _Request rqh = new _Request();
359       _UnsubscribeRq rqb = new _UnsubscribeRq();
360       _ResponseHolder rsh = new _ResponseHolder();
361       ObjectHolder rsb = new javax.xml.rpc.holders.ObjectHolder();
362       rqh.setReceiverKey(ik);
363       rqb.setObserverKey(new URI(new SharkWebServiceLocator()
364             .getasapObserverBindingAddress()));
365
366       // Test operation
367       binding.unsubscribe(rqh, rqb, rsh, rsb);
368       // TBD - validate results
369    }
370
371    public void test5asapInstanceBindingChangeState() throws Exception {
372       System.err.println("##ibcss");
373       AsapInstanceBindingStub binding;
374       try {
375          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator()
376                .getasapInstanceBinding();
377       } catch (javax.xml.rpc.ServiceException jre) {
378          if (jre.getLinkedCause() != null)
379             jre.getLinkedCause().printStackTrace();
380          throw new junit.framework.AssertionFailedError(
381                "JAX-RPC ServiceException caught: " + jre);
382       }
383       assertNotNull("binding is null", binding);
384
385       // Time out after a minute
386       binding.setTimeout(60000);
387
388
389       _Request rqh = new _Request();
390       _ChangeStateRq rqb = new _ChangeStateRq();
391       _ResponseHolder rsh = new _ResponseHolder();
392       _ChangeStateRsHolder rsb = new _ChangeStateRsHolder();
393       rqh.setReceiverKey(ik);
394       rqb.setState(StateType.value6);
395
396       // Test operation
397       binding.changeState(rqh, rqb, rsh, rsb);
398       // TBD - validate results
399       System.err.println("##ibcse");
400
401
402    }
403    */

404 }
405
Popular Tags