001: /*
002: * SharkWebServiceTestCase.java
003: *
004: * This file was auto-generated from WSDL by the Apache Axis WSDL2Java emitter.
005: */
006:
007: package org.enhydra.shark.wfxml.test;
008:
009: import java.net.URL;
010: import java.util.HashMap;
011: import java.util.Map;
012:
013: import org.apache.axis.types.URI;
014: import org.enhydra.shark.asap.types.GetPropertiesRs;
015: import org.enhydra.shark.asap.types.Request;
016: import org.enhydra.shark.asap.types.holders.GetPropertiesRsHolder;
017: import org.enhydra.shark.asap.types.holders.ResponseHolder;
018: import org.enhydra.shark.wfxml.SharkWebServiceLocator;
019: import org.enhydra.shark.wfxml.WfXmlFactoryBindingStub;
020:
021: /**
022: * JUnit test case for shark web service wrapper.
023: *
024: * @author V.Puskas
025: */
026: public class ForeignWebServiceTestCase extends junit.framework.TestCase {
027: // static private URI ik;
028: static private Map factories = new HashMap();
029: static {
030: factories
031: .put("Fujitsu Retailer",
032: "http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Retailer");
033: factories
034: .put("Fujitsu Manufacturer",
035: "http://interop.i-flow.com/iflowjsp/jsp/ProcDef.jsp?planName=Manufacturer");
036: factories.put("EasyASAP Retailer",
037: "http://68.96.20.206:7777/asap_evm");
038: factories.put("EasyASAP Manufacturer",
039: "http://68.96.20.206:7787/asap_evm");
040: factories
041: .put("HandySoft Retailer",
042: "http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=103");
043: factories
044: .put("HandySoft Manufacturer",
045: "http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=102");
046: factories
047: .put("TIBCO Retailer",
048: "http://www.staffware.co.za:8080/ASAPServer/FactoryService.asmx");
049: factories
050: .put(".NET reference factory, California",
051: "http://interop.i-flow.com/ASAPServer/FactoryService.asmx");
052: factories.put("Enhydra Shark",
053: "http://vajat:8080/axis/services/wfxmlFactoryBinding");
054: }
055:
056: public ForeignWebServiceTestCase(java.lang.String name) {
057: super (name);
058: // QName xmlType = new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema",
059: // "anyType");
060: // DefaultTypeMappingImpl.getSingleton()
061: // .register(String.class,
062: // xmlType,
063: // new AltBeanSerializerFactory(String.class, xmlType),
064: // new AltBeanDeserializerFactory(String.class, xmlType));
065: }
066:
067: /*
068: * public void test6asapObserverBindingGetProperties() throws
069: * Exception { AsapObserverBindingStub binding; try { binding =
070: * (AsapObserverBindingStub) new SharkWebServiceLocator()
071: * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
072: * jre) { if (jre.getLinkedCause() != null)
073: * jre.getLinkedCause().printStackTrace(); throw new
074: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
075: * caught: " + jre); } assertNotNull("binding is null", binding); //
076: * Time out after a minute binding.setTimeout(60000); _Request rqh =
077: * new _Request(); Object rqb = new java.lang.String();
078: * _ResponseHolder rsh = new _ResponseHolder();
079: * _GetPropertiesRsHolder rsb = new _GetPropertiesRsHolder();
080: * rqh.setReceiverKey(new URI("http://vidi")); // Test operation
081: * binding.getProperties(rqh, rqb, rsh, rsb); // TBD - validate
082: * results } public void test7asapObserverBindingCompleted() throws
083: * Exception { AsapObserverBindingStub binding; try { binding =
084: * (AsapObserverBindingStub) new SharkWebServiceLocator()
085: * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
086: * jre) { if (jre.getLinkedCause() != null)
087: * jre.getLinkedCause().printStackTrace(); throw new
088: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
089: * caught: " + jre); } assertNotNull("binding is null", binding); //
090: * Time out after a minute binding.setTimeout(60000); _Request rqh =
091: * new _Request(); _CompletedRq rqb = new _CompletedRq();
092: * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
093: * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(new
094: * URI("http://vidi")); // Test operation binding.completed(rqh, rqb,
095: * rsh, rsb); // TBD - validate results } public void
096: * test8asapObserverBindingStateChanged() throws Exception {
097: * AsapObserverBindingStub binding; try { binding =
098: * (AsapObserverBindingStub) new SharkWebServiceLocator()
099: * .getasapObserverBinding(); } catch (javax.xml.rpc.ServiceException
100: * jre) { if (jre.getLinkedCause() != null)
101: * jre.getLinkedCause().printStackTrace(); throw new
102: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
103: * caught: " + jre); } assertNotNull("binding is null", binding); //
104: * Time out after a minute binding.setTimeout(60000); _Request rqh =
105: * new _Request(); _StateChangedRq rqb = new _StateChangedRq();
106: * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
107: * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(new
108: * URI("http://vidi")); // Test operation binding.stateChanged(rqh,
109: * rqb, rsh, rsb); // TBD - validate results }
110: */
111: public void test9asapFactoryBindingGetProperties() throws Exception {
112: WfXmlFactoryBindingStub binding;
113: String uriString = (String) factories.get("Enhydra Shark");
114:
115: try {
116: binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator()
117: //.getasapFactoryBinding(new URL());
118: .getwfxmlFactoryBinding(new URL(uriString));
119: //
120: } catch (javax.xml.rpc.ServiceException jre) {
121: if (jre.getLinkedCause() != null)
122: jre.getLinkedCause().printStackTrace();
123: throw new junit.framework.AssertionFailedError(
124: "JAX-RPC ServiceException caught: " + jre);
125: }
126: assertNotNull("binding is null", binding);
127:
128: // Time out after a minute
129: binding.setTimeout(60000);
130: Request rqHead = new Request();
131: String rqBody = ""; // new java.lang.String()
132: ResponseHolder rsHead = new ResponseHolder();
133: GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
134: rqHead.setReceiverKey(new URI(uriString));
135:
136: // Test operation
137: try {
138: binding.getProperties(rqHead, rqBody, rsHead, rsBody);
139: } catch (Throwable t) {
140: System.err.println("Throwable " + t.getClass().getName()
141: + "(" + t.getMessage() + ")");
142: }
143: Object[] oo = binding.getResponseHeaders();
144: for (int n = 0; n < oo.length; ++n) {
145: System.err.println("" + n + "#"
146: + binding.getResponseHeaders()[n].toString());
147: }
148: // TBD - validate results
149: System.err.println("res" + rsBody.value);
150: GetPropertiesRs fpg = rsBody.value;
151: System.err.println("Key=" + fpg.getKey());
152: System.err.println("Name=" + fpg.getName());
153: System.err.println("Subj=" + fpg.getSubject());
154: System.err.println("desc=" + fpg.getDescription());
155: try {
156: System.err.println("cds="
157: + fpg.getContextDataSchema().get_any()[0]
158: .toString());
159: System.err
160: .println("rds="
161: + fpg.getResultDataSchema().get_any()[0]
162: .toString());
163: } catch (Throwable t) {
164: }
165: }
166: /*
167: * public void test10asapFactoryBindingCreateInstance() throws
168: * Exception { AsapFactoryBindingStub binding; try { binding =
169: * (AsapFactoryBindingStub) new SharkWebServiceLocator()
170: * .getasapFactoryBinding(); } catch (javax.xml.rpc.ServiceException
171: * jre) { if (jre.getLinkedCause() != null)
172: * jre.getLinkedCause().printStackTrace(); throw new
173: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
174: * caught: " + jre); } assertNotNull("binding is null", binding); //
175: * Time out after a minute binding.setTimeout(60000); _Request rqHead =
176: * new _Request(); _CreateInstanceRq rqBody = new
177: * _CreateInstanceRq(); _ResponseHolder rsHead = new
178: * _ResponseHolder(); _CreateInstanceRsHolder rsBody = new
179: * _CreateInstanceRsHolder(); rqHead.setReceiverKey(new URI(new
180: * SharkWebServiceLocator() .getasapFactoryBindingAddress()));
181: * //rqHead.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
182: * //rqHead.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
183: * rqHead.getReceiverKey().setQueryString("procDef=Game&packageId=test_js");
184: * rqBody.setObserverKey(new URI(new SharkWebServiceLocator()
185: * .getasapObserverBindingAddress()));
186: * rqBody.getObserverKey().setHost(InetAddress.getLocalHost().getHostName());
187: * rqBody.setStartImmediately(true); // Test operation
188: * binding.createInstance(rqHead, rqBody, rsHead, rsBody);
189: * System.err.println("##" + rsBody.value.getInstanceKey()); // TBD -
190: * validate results ik = rsBody.value.getInstanceKey(); } public void
191: * test11asapFactoryBindingListInstances() throws Exception {
192: * AsapFactoryBindingStub binding; try { binding =
193: * (AsapFactoryBindingStub) new SharkWebServiceLocator()
194: * .getasapFactoryBinding(); } catch (javax.xml.rpc.ServiceException
195: * jre) { if (jre.getLinkedCause() != null)
196: * jre.getLinkedCause().printStackTrace(); throw new
197: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
198: * caught: " + jre); } assertNotNull("binding is null", binding); //
199: * Time out after a minute binding.setTimeout(60000); _Request rqh =
200: * new _Request(); rqh.setReceiverKey(new URI(new
201: * SharkWebServiceLocator() .getasapFactoryBindingAddress()));
202: * //rqh.getReceiverKey().setQueryString("procMgr=test_js+1+basic");
203: * //rqh.getReceiverKey().setQueryString("procDef=manufacturing&packageId=test_js");
204: * _ListInstancesRq rqb = new _ListInstancesRq(); _ResponseHolder rsh =
205: * new _ResponseHolder(); _ListInstancesRsHolder rsb = new
206: * _ListInstancesRsHolder(); // Test operation
207: * binding.listInstances(rqh, rqb, rsh, rsb); _Instance[] a =
208: * rsb.value.getInstance(); if (null != a) { for (int n = 0; n <
209: * a.length; ++n) { //System.err.println(a[n]);
210: * System.err.println("[" + a[n].getInstanceKey() + ", " +
211: * a[n].getName() + ", " + a[n].getSubject() + "]"); } } else {
212: * System.err.println("getInstance value is null"); } // TBD -
213: * validate results } public void
214: * test2asapInstanceBindingSetProperties() throws Exception {
215: * AsapInstanceBindingStub binding; try { binding =
216: * (AsapInstanceBindingStub) new SharkWebServiceLocator()
217: * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
218: * jre) { if (jre.getLinkedCause() != null)
219: * jre.getLinkedCause().printStackTrace(); throw new
220: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
221: * caught: " + jre); } assertNotNull("binding is null", binding); //
222: * Time out after a minute binding.setTimeout(60000); _Request rqh =
223: * new _Request(); _SetPropertiesRq rqb = new _SetPropertiesRq();
224: * _ResponseHolder rsh = new _ResponseHolder();
225: * _SetPropertiesRsHolder rsb = new _SetPropertiesRsHolder();
226: * rqh.setReceiverKey(new URI("http://vidi")); // Test operation
227: * binding.setProperties(rqh, rqb, rsh, rsb); // TBD - validate
228: * results } public void test3asapInstanceBindingSubscribe() throws
229: * Exception { AsapInstanceBindingStub binding; try { binding =
230: * (AsapInstanceBindingStub) new SharkWebServiceLocator()
231: * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
232: * jre) { if (jre.getLinkedCause() != null)
233: * jre.getLinkedCause().printStackTrace(); throw new
234: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
235: * caught: " + jre); } assertNotNull("binding is null", binding); //
236: * Time out after a minute binding.setTimeout(60000); _Request rqh =
237: * new _Request(); _SubscribeRq rqb = new _SubscribeRq();
238: * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
239: * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(ik);
240: * rqb.setObserverKey(new URI(new SharkWebServiceLocator()
241: * .getasapObserverBindingAddress())); // Test operation
242: * binding.subscribe(rqh, rqb, rsh, rsb); // TBD - validate results }
243: * public void test1asapInstanceBindingGetProperties() throws
244: * Exception { AsapInstanceBindingStub binding; try { binding =
245: * (AsapInstanceBindingStub) new SharkWebServiceLocator()
246: * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
247: * jre) { if (jre.getLinkedCause() != null)
248: * jre.getLinkedCause().printStackTrace(); throw new
249: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
250: * caught: " + jre); } assertNotNull("binding is null", binding); //
251: * Time out after a minute binding.setTimeout(60000); _Request rqh =
252: * new _Request(); Object rqb = new java.lang.String();
253: * _ResponseHolder rsh = new _ResponseHolder();
254: * _GetPropertiesRsHolder rsb = new _GetPropertiesRsHolder();
255: * rqh.setReceiverKey(ik); System.err.println("##tt"); // Test
256: * operation binding.getProperties(rqh, rqb, rsh, rsb);
257: * InstancePropertiesGroup ipg =
258: * rsb.value.getInstancePropertiesGroup();
259: * System.err.println("#ipg:"+ipg.getKey());
260: * System.err.println("#ipg:"+ipg.getFactoryKey()); URI[] _obs_ =
261: * ipg.getObservers().getObserverKey(); for (int n = 0; n <
262: * _obs_.length; ++n) { System.err.println("#ipg"+n+":"+_obs_[n]); }
263: * _Event[] _ev_ = ipg.getHistory().getEvent(); for (int n = 0; n
264: * <_ev_.length; ++n) {
265: * System.err.println("#ipg"+n+"event:"+_ev_[n].getEventType());
266: * System.err.println("#ipg"+n+"event:"+_ev_[n].getTime()); }
267: * MessageElement[] ctx = ipg.getContextData().get_any(); for (int n =
268: * 0; n <ctx.length; ++n) {
269: * System.err.println("#ipg"+n+"ctx:"+ctx[n].toString()); } } public
270: * void test4asapInstanceBindingUnsubscribe() throws Exception {
271: * AsapInstanceBindingStub binding; try { binding =
272: * (AsapInstanceBindingStub) new SharkWebServiceLocator()
273: * .getasapInstanceBinding(); } catch (javax.xml.rpc.ServiceException
274: * jre) { if (jre.getLinkedCause() != null)
275: * jre.getLinkedCause().printStackTrace(); throw new
276: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
277: * caught: " + jre); } assertNotNull("binding is null", binding); //
278: * Time out after a minute binding.setTimeout(60000); _Request rqh =
279: * new _Request(); _UnsubscribeRq rqb = new _UnsubscribeRq();
280: * _ResponseHolder rsh = new _ResponseHolder(); ObjectHolder rsb =
281: * new javax.xml.rpc.holders.ObjectHolder(); rqh.setReceiverKey(ik);
282: * rqb.setObserverKey(new URI(new SharkWebServiceLocator()
283: * .getasapObserverBindingAddress())); // Test operation
284: * binding.unsubscribe(rqh, rqb, rsh, rsb); // TBD - validate results }
285: * public void test5asapInstanceBindingChangeState() throws Exception {
286: * System.err.println("##ibcss"); AsapInstanceBindingStub binding;
287: * try { binding = (AsapInstanceBindingStub) new
288: * SharkWebServiceLocator() .getasapInstanceBinding(); } catch
289: * (javax.xml.rpc.ServiceException jre) { if (jre.getLinkedCause() !=
290: * null) jre.getLinkedCause().printStackTrace(); throw new
291: * junit.framework.AssertionFailedError( "JAX-RPC ServiceException
292: * caught: " + jre); } assertNotNull("binding is null", binding); //
293: * Time out after a minute binding.setTimeout(60000); _Request rqh =
294: * new _Request(); _ChangeStateRq rqb = new _ChangeStateRq();
295: * _ResponseHolder rsh = new _ResponseHolder(); _ChangeStateRsHolder
296: * rsb = new _ChangeStateRsHolder(); rqh.setReceiverKey(ik);
297: * rqb.setState(StateType.value6); // Test operation
298: * binding.changeState(rqh, rqb, rsh, rsb); // TBD - validate results
299: * System.err.println("##ibcse"); }
300: */
301: }
|