KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > wfxml > 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.wfxml.test;
8
9 import java.net.URL JavaDoc;
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13 import javax.xml.namespace.QName JavaDoc;
14
15 import org.apache.axis.encoding.DefaultTypeMappingImpl;
16 import org.apache.axis.types.URI;
17 import org.enhydra.shark.asap.types.FactoryPropertiesGroup;
18 import org.enhydra.shark.asap.types.Request;
19 import org.enhydra.shark.asap.types.holders.GetPropertiesRsHolder;
20 import org.enhydra.shark.asap.types.holders.ResponseHolder;
21 import org.enhydra.shark.wfxml.SharkWebServiceLocator;
22 import org.enhydra.shark.wfxml.WfXmlFactoryBindingStub;
23 import org.enhydra.shark.wfxml.util.AltBeanDeserializerFactory;
24 import org.enhydra.shark.wfxml.util.AltBeanSerializerFactory;
25
26 /**
27  * JUnit test case for shark web service wrapper.
28  *
29  * @author V.Puskas
30  */

31 public class ForeignWebServiceTestCase extends junit.framework.TestCase {
32    static private URI ik;
33    static private Map JavaDoc factories = new HashMap JavaDoc();
34    static {
35       factories.put("Fujitsu Retailer","http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Retailer");
36       factories.put("Fujitsu Manufacturer","http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Manufacturer");
37       factories.put("EasyASAP Retailer","http://68.96.20.206:7777/asap_evm");
38       factories.put("EasyASAP Manufacturer","http://68.96.20.206:7787/asap_evm");
39       factories.put("HandySoft Retailer","http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=103");
40       factories.put("HandySoft Manufacturer","http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=102");
41       factories.put("TIBCO Retailer","http://www.staffware.co.za:8080/ASAPServer/FactoryService.asmx");
42       factories.put(".NET reference factory, California","http://interop.i-flow.com/ASAPServer/FactoryService.asmx");
43       factories.put("Enhydra Shark","http://vajat:8080/axis/services/wfxmlFactoryBinding");
44    }
45    public ForeignWebServiceTestCase(java.lang.String JavaDoc name) {
46       super(name);
47       QName JavaDoc xmlType = new javax.xml.namespace.QName JavaDoc("http://www.w3.org/2001/XMLSchema",
48                                                     "anyType");
49       DefaultTypeMappingImpl.getSingleton()
50          .register(String JavaDoc.class,
51                    xmlType,
52                    new AltBeanSerializerFactory(String JavaDoc.class, xmlType),
53                    new AltBeanDeserializerFactory(String JavaDoc.class, xmlType));
54    }
55
56    /*
57     * public void test6asapObserverBindingGetProperties() throws
58     * Exception { AsapObserverBindingStub binding; try { binding =
59     * (AsapObserverBindingStub) new SharkWebServiceLocator()
60     * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
61     * jre) { if (jre.getLinkedCause() != null)
62     * jre.getLinkedCause().printStackTrace(); throw new
63     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
64     * caught: " + jre); } assertNotNull("binding is null", binding); //
65     * Time out after a minute binding.setTimeout(60000); _Request rqh =
66     * new _Request(); Object rqb = new java.lang.String();
67     * _ResponseHolder rsh = new _ResponseHolder();
68     * _GetPropertiesRsHolder rsb = new _GetPropertiesRsHolder();
69     * rqh.setReceiverKey(new URI("http://vidi")); // Test operation
70     * binding.getProperties(rqh, rqb, rsh, rsb); // TBD - validate
71     * results } public void test7asapObserverBindingCompleted() throws
72     * Exception { AsapObserverBindingStub binding; try { binding =
73     * (AsapObserverBindingStub) new SharkWebServiceLocator()
74     * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
75     * jre) { if (jre.getLinkedCause() != null)
76     * jre.getLinkedCause().printStackTrace(); throw new
77     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
78     * caught: " + jre); } assertNotNull("binding is null", binding); //
79     * Time out after a minute binding.setTimeout(60000); _Request rqh =
80     * new _Request(); _CompletedRq rqb = new _CompletedRq();
81     * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
82     * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(new
83     * URI("http://vidi")); // Test operation binding.completed(rqh, rqb,
84     * rsh, rsb); // TBD - validate results } public void
85     * test8asapObserverBindingStateChanged() throws Exception {
86     * AsapObserverBindingStub binding; try { binding =
87     * (AsapObserverBindingStub) new SharkWebServiceLocator()
88     * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
89     * jre) { if (jre.getLinkedCause() != null)
90     * jre.getLinkedCause().printStackTrace(); throw new
91     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
92     * caught: " + jre); } assertNotNull("binding is null", binding); //
93     * Time out after a minute binding.setTimeout(60000); _Request rqh =
94     * new _Request(); _StateChangedRq rqb = new _StateChangedRq();
95     * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
96     * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(new
97     * URI("http://vidi")); // Test operation binding.stateChanged(rqh,
98     * rqb, rsh, rsb); // TBD - validate results }
99     */

100    public void test9asapFactoryBindingGetProperties() throws Exception JavaDoc {
101       WfXmlFactoryBindingStub binding;
102       String JavaDoc uriString = (String JavaDoc) factories.get("Enhydra Shark");
103
104       try {
105          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator()
106          //.getasapFactoryBinding(new URL());
107
.getwfxmlFactoryBinding(new URL JavaDoc(uriString));
108          //
109
} catch (javax.xml.rpc.ServiceException JavaDoc jre) {
110          if (jre.getLinkedCause() != null) jre.getLinkedCause()
111             .printStackTrace();
112          throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: "
113                                                         + jre);
114       }
115       assertNotNull("binding is null", binding);
116
117       // Time out after a minute
118
binding.setTimeout(60000);
119       Request rqHead = new Request();
120       String JavaDoc rqBody = ""; // new java.lang.String()
121
ResponseHolder rsHead = new ResponseHolder();
122       GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
123       rqHead.setReceiverKey(new URI(uriString));
124
125       // Test operation
126
try {
127          binding.getProperties(rqHead, rqBody, rsHead, rsBody);
128       } catch (Throwable JavaDoc t) {
129          System.err.println("Throwable "
130                             + t.getClass().getName() + "(" + t.getMessage()
131                             + ")");
132       }
133       Object JavaDoc[] oo = binding.getResponseHeaders();
134       for (int n = 0; n < oo.length; ++n) {
135          System.err.println(""
136                             + n + "#"
137                             + binding.getResponseHeaders()[n].toString());
138       }
139       // TBD - validate results
140
System.err.println("res" + rsBody.value);
141       FactoryPropertiesGroup fpg = rsBody.value.getFactoryPropertiesGroup();
142       System.err.println("Key=" + fpg.getKey());
143       System.err.println("Name=" + fpg.getName());
144       System.err.println("Subj=" + fpg.getSubject());
145       System.err.println("desc=" + fpg.getDescription());
146       try {
147          System.err.println("cds="
148                             + fpg.getContextDataSchema().get_any()[0].toString());
149          System.err.println("rds="
150                             + fpg.getResultDataSchema().get_any()[0].toString());
151       } catch (Throwable JavaDoc t) {}
152    }
153    /*
154     * public void test10asapFactoryBindingCreateInstance() throws
155     * Exception { AsapFactoryBindingStub binding; try { binding =
156     * (AsapFactoryBindingStub) new SharkWebServiceLocator()
157     * .getasapFactoryBinding(); } catch (javax.xml.rpc.ServiceException
158     * jre) { if (jre.getLinkedCause() != null)
159     * jre.getLinkedCause().printStackTrace(); throw new
160     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
161     * caught: " + jre); } assertNotNull("binding is null", binding); //
162     * Time out after a minute binding.setTimeout(60000); _Request rqHead =
163     * new _Request(); _CreateInstanceRq rqBody = new
164     * _CreateInstanceRq(); _ResponseHolder rsHead = new
165     * _ResponseHolder(); _CreateInstanceRsHolder rsBody = new
166     * _CreateInstanceRsHolder(); rqHead.setReceiverKey(new URI(new
167     * SharkWebServiceLocator() .getasapFactoryBindingAddress()));
168     * //rqHead.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
169     * //rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
170     * rqHead.getReceiverKey().setQueryString("procDef=Game&packageId=test_js");
171     * rqBody.setObserverKey(new URI(new SharkWebServiceLocator()
172     * .getasapObserverBindingAddress()));
173     * rqBody.getObserverKey().setHost(InetAddress.getLocalHost().getHostName());
174     * rqBody.setStartImmediately(true); // Test operation
175     * binding.createInstance(rqHead, rqBody, rsHead, rsBody);
176     * System.err.println("##" + rsBody.value.getInstanceKey()); // TBD -
177     * validate results ik = rsBody.value.getInstanceKey(); } public void
178     * test11asapFactoryBindingListInstances() throws Exception {
179     * AsapFactoryBindingStub binding; try { binding =
180     * (AsapFactoryBindingStub) new SharkWebServiceLocator()
181     * .getasapFactoryBinding(); } catch (javax.xml.rpc.ServiceException
182     * jre) { if (jre.getLinkedCause() != null)
183     * jre.getLinkedCause().printStackTrace(); throw new
184     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
185     * caught: " + jre); } assertNotNull("binding is null", binding); //
186     * Time out after a minute binding.setTimeout(60000); _Request rqh =
187     * new _Request(); rqh.setReceiverKey(new URI(new
188     * SharkWebServiceLocator() .getasapFactoryBindingAddress()));
189     * //rqh.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
190     * //rqh.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
191     * _ListInstancesRq rqb = new _ListInstancesRq(); _ResponseHolder rsh =
192     * new _ResponseHolder(); _ListInstancesRsHolder rsb = new
193     * _ListInstancesRsHolder(); // Test operation
194     * binding.listInstances(rqh, rqb, rsh, rsb); _Instance[] a =
195     * rsb.value.getInstance(); if (null != a) { for (int n = 0; n <
196     * a.length; ++n) { //System.err.println(a[n]);
197     * System.err.println("[" + a[n].getInstanceKey() + ", " +
198     * a[n].getName() + ", " + a[n].getSubject() + "]"); } } else {
199     * System.err.println("getInstance value is null"); } // TBD -
200     * validate results } public void
201     * test2asapInstanceBindingSetProperties() throws Exception {
202     * AsapInstanceBindingStub binding; try { binding =
203     * (AsapInstanceBindingStub) new SharkWebServiceLocator()
204     * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
205     * jre) { if (jre.getLinkedCause() != null)
206     * jre.getLinkedCause().printStackTrace(); throw new
207     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
208     * caught: " + jre); } assertNotNull("binding is null", binding); //
209     * Time out after a minute binding.setTimeout(60000); _Request rqh =
210     * new _Request(); _SetPropertiesRq rqb = new _SetPropertiesRq();
211     * _ResponseHolder rsh = new _ResponseHolder();
212     * _SetPropertiesRsHolder rsb = new _SetPropertiesRsHolder();
213     * rqh.setReceiverKey(new URI("http://vidi")); // Test operation
214     * binding.setProperties(rqh, rqb, rsh, rsb); // TBD - validate
215     * results } public void test3asapInstanceBindingSubscribe() throws
216     * Exception { AsapInstanceBindingStub binding; try { binding =
217     * (AsapInstanceBindingStub) new SharkWebServiceLocator()
218     * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
219     * jre) { if (jre.getLinkedCause() != null)
220     * jre.getLinkedCause().printStackTrace(); throw new
221     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
222     * caught: " + jre); } assertNotNull("binding is null", binding); //
223     * Time out after a minute binding.setTimeout(60000); _Request rqh =
224     * new _Request(); _SubscribeRq rqb = new _SubscribeRq();
225     * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
226     * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(ik);
227     * rqb.setObserverKey(new URI(new SharkWebServiceLocator()
228     * .getasapObserverBindingAddress())); // Test operation
229     * binding.subscribe(rqh, rqb, rsh, rsb); // TBD - validate results }
230     * public void test1asapInstanceBindingGetProperties() throws
231     * Exception { AsapInstanceBindingStub binding; try { binding =
232     * (AsapInstanceBindingStub) new SharkWebServiceLocator()
233     * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
234     * jre) { if (jre.getLinkedCause() != null)
235     * jre.getLinkedCause().printStackTrace(); throw new
236     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
237     * caught: " + jre); } assertNotNull("binding is null", binding); //
238     * Time out after a minute binding.setTimeout(60000); _Request rqh =
239     * new _Request(); Object rqb = new java.lang.String();
240     * _ResponseHolder rsh = new _ResponseHolder();
241     * _GetPropertiesRsHolder rsb = new _GetPropertiesRsHolder();
242     * rqh.setReceiverKey(ik); System.err.println("##tt"); // Test
243     * operation binding.getProperties(rqh, rqb, rsh, rsb);
244     * InstancePropertiesGroup ipg =
245     * rsb.value.getInstancePropertiesGroup();
246     * System.err.println("#ipg:"+ipg.getKey());
247     * System.err.println("#ipg:"+ipg.getFactoryKey()); URI[] _obs_ =
248     * ipg.getObservers().getObserverKey(); for (int n = 0; n <
249     * _obs_.length; ++n) { System.err.println("#ipg"+n+":"+_obs_[n]); }
250     * _Event[] _ev_ = ipg.getHistory().getEvent(); for (int n = 0; n
251     * <_ev_.length; ++n) {
252     * System.err.println("#ipg"+n+"event:"+_ev_[n].getEventType());
253     * System.err.println("#ipg"+n+"event:"+_ev_[n].getTime()); }
254     * MessageElement[] ctx = ipg.getContextData().get_any(); for (int n =
255     * 0; n <ctx.length; ++n) {
256     * System.err.println("#ipg"+n+"ctx:"+ctx[n].toString()); } } public
257     * void test4asapInstanceBindingUnsubscribe() throws Exception {
258     * AsapInstanceBindingStub binding; try { binding =
259     * (AsapInstanceBindingStub) new SharkWebServiceLocator()
260     * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
261     * jre) { if (jre.getLinkedCause() != null)
262     * jre.getLinkedCause().printStackTrace(); throw new
263     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
264     * caught: " + jre); } assertNotNull("binding is null", binding); //
265     * Time out after a minute binding.setTimeout(60000); _Request rqh =
266     * new _Request(); _UnsubscribeRq rqb = new _UnsubscribeRq();
267     * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
268     * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(ik);
269     * rqb.setObserverKey(new URI(new SharkWebServiceLocator()
270     * .getasapObserverBindingAddress())); // Test operation
271     * binding.unsubscribe(rqh, rqb, rsh, rsb); // TBD - validate results }
272     * public void test5asapInstanceBindingChangeState() throws Exception {
273     * System.err.println("##ibcss"); AsapInstanceBindingStub binding;
274     * try { binding = (AsapInstanceBindingStub) new
275     * SharkWebServiceLocator() .getasapInstanceBinding(); } catch
276     * (javax.xml.rpc.ServiceException jre) { if (jre.getLinkedCause() !=
277     * null) jre.getLinkedCause().printStackTrace(); throw new
278     * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
279     * caught: " + jre); } assertNotNull("binding is null", binding); //
280     * Time out after a minute binding.setTimeout(60000); _Request rqh =
281     * new _Request(); _ChangeStateRq rqb = new _ChangeStateRq();
282     * _ResponseHolder rsh = new _ResponseHolder(); _ChangeStateRsHolder
283     * rsb = new _ChangeStateRsHolder(); rqh.setReceiverKey(ik);
284     * rqb.setState(StateType.value6); // Test operation
285     * binding.changeState(rqh, rqb, rsh, rsb); // TBD - validate results
286     * System.err.println("##ibcse"); }
287     */

288 }
Popular Tags