KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.wfxml.test;
2
3 import java.net.MalformedURLException JavaDoc;
4 import java.net.URL JavaDoc;
5 import java.util.*;
6
7 import javax.xml.namespace.QName JavaDoc;
8
9 import org.apache.axis.client.Call;
10 import org.apache.axis.encoding.DefaultTypeMappingImpl;
11 import org.apache.axis.encoding.ser.SimpleSerializerFactory;
12 import org.apache.axis.message.MessageElement;
13 import org.apache.axis.types.URI;
14 import org.enhydra.shark.asap.AsapBindingUtilitiesImpl;
15 import org.enhydra.shark.asap.AsapInstanceBindingStub;
16 import org.enhydra.shark.asap.types.*;
17 import org.enhydra.shark.asap.types.holders.*;
18 import org.enhydra.shark.wfxml.SharkWebServiceLocator;
19 import org.enhydra.shark.wfxml.WfXmlFactoryBindingStub;
20 import org.enhydra.shark.wfxml.util.AltBeanDeserializerFactory;
21
22 /**
23  * JUnit test case for shark web service wrapper.
24  *
25  * @author V.Puskas
26  */

27 public class WfXmlKissClient extends junit.framework.TestCase {
28    static private URI ik;
29
30    static private Map factories = new HashMap();
31
32    static private Map schemaLocactions = new HashMap();
33
34    private static final String JavaDoc SERVICE = "Enhydra Shark Retailer";
35
36    private static final String JavaDoc OBS = "";
37
38    static {
39       factories.put("Fujitsu Retailer",
40                     "http://interop.i-flow.com/ibpm/jsp/ProcDef.jsp?planName=Retailer");
41       schemaLocactions.put("Fujitsu Retailer","");
42       
43       factories.put("Fujitsu Manufacturer",
44                     "http://interop.i-flow.com/ibpm/jsp/ProcDef.jsp?planName=Manufacturer");
45       schemaLocactions.put("Fujitsu Manufacturer","http://interop.i-flow.com/ibpm/jsp/contextData.jsp?pdid=152");
46       
47       factories.put("TIBCO Retailer",
48                     "http://193.131.190.26:8080/ASAP/services/Factory?retail");
49       schemaLocactions.put("TIBCO Retailer","");
50       
51       factories.put("TIBCO Manufacturer",
52                     "http://bpm-interop.tibco.com:8080/ASAP/services/Factory?manufac");
53       schemaLocactions.put("TIBCO Manufacturer","http://bpm-interop.tibco.com:8080/ASAP/schemas/context/manufac.xsd");
54       
55       factories.put("EasyASAP Retailer", "http://68.96.20.206:7777/asap_evm");
56       schemaLocactions.put("EasyASAP Retailer","");
57       
58       factories.put("EasyASAP Manufacturer",
59                     "http://68.96.20.206:7787/asap_evm");
60       schemaLocactions.put("EasyASAP Manufacturer","");
61       
62       factories.put("Enhydra Shark Retailer",
63                     "http://vajat.prozone.co.yu:8080/axis/services/wfxmlFactoryBinding?procDef=retailer&packageId=shark_retailer");
64       schemaLocactions.put("Enhydra Shark Retailer","");
65       
66       factories.put("Enhydra Shark Manufacturer",
67                     "http://vajat.prozone.co.yu:8080/axis/services/wfxmlFactoryBinding?procDef=manufacturer&packageId=shark_manufacturer");
68       schemaLocactions.put("Enhydra Shark Manufacturer","");
69       // factories.put("HandySoft Retailer",
70
// "http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=103");
71
// factories.put("HandySoft Manufacturer",
72
// "http://63.137.54.122/bizflow/services/wfxmlservice/ProcDef?pid=102");
73
// factories.put(".NET reference factory, California",
74
// "http://interop.i-flow.com/ASAPServer/FactoryService.asmx");
75
}
76
77    public WfXmlKissClient(java.lang.String JavaDoc name) {
78       super(name);
79       QName JavaDoc xmlType = new javax.xml.namespace.QName JavaDoc("http://www.w3.org/2001/XMLSchema",
80                                                     "anyType");
81       DefaultTypeMappingImpl.getSingleton()
82          .register(String JavaDoc.class,
83                    xmlType,
84                    new SimpleSerializerFactory(String JavaDoc.class,
85                                                new javax.xml.namespace.QName JavaDoc("http://www.w3.org/2001/XMLSchema",
86                                                                              "string")),
87                    new AltBeanDeserializerFactory(String JavaDoc.class,
88                                                   new javax.xml.namespace.QName JavaDoc("http://www.w3.org/2001/XMLSchema",
89                                                                                 "string")));
90    }
91
92    public void qtest0wfxmlFactoryBindingGetProperties() throws Exception JavaDoc {
93       System.err.println(Call.SOAPACTION_USE_PROPERTY);
94       String JavaDoc uriString = (String JavaDoc) factories.get(SERVICE);
95       WfXmlFactoryBindingStub binding = getFactoryBinding(uriString);
96
97       //binding._setProperty(Call.SOAPACTION_USE_PROPERTY,Boolean.FALSE);
98
Request rqHead = new Request(null,
99                                    new URI(uriString),
100                                    YesNoIfError.No,
101                                    null);
102       String JavaDoc rqBody = ""; // new java.lang.String()
103
ResponseHolder rsHead = new ResponseHolder();
104       GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder();
105
106       // Test operation
107
try {
108          binding.getProperties(rqHead, rqBody, rsHead, rsBody);
109       } catch (Throwable JavaDoc t) {
110          System.err.println("Throwable "
111                             + t.getClass().getName() + "(" + t.getMessage()
112                             + ")");
113       }
114       Object JavaDoc[] oo = binding.getResponseHeaders();
115       for (int n = 0; n < oo.length; ++n) {
116          System.err.println(""
117                             + n + "#"
118                             + binding.getResponseHeaders()[n].toString());
119       }
120       // TBD - validate results
121
System.err.println("res" + rsBody.value);
122       FactoryPropertiesGroup fpg = rsBody.value.getFactoryPropertiesGroup();
123       System.err.println("Key=" + fpg.getKey());
124       System.err.println("Name=" + fpg.getName());
125       System.err.println("Subj=" + fpg.getSubject());
126       System.err.println("desc=" + fpg.getDescription());
127       try {
128          System.err.println("cds="
129                             + fpg.getContextDataSchema().get_any()[0].toString());
130          System.err.println("rds="
131                             + fpg.getResultDataSchema().get_any()[0].toString());
132       } catch (Throwable JavaDoc t) {}
133    }
134
135    public void test1wfxmlFactoryBindingCreateInstance() throws Exception JavaDoc {
136       String JavaDoc uriString = (String JavaDoc) factories.get(SERVICE);
137       WfXmlFactoryBindingStub binding = getFactoryBinding(uriString);
138
139       Map m = new HashMap();
140       m.put("product_code", new Long JavaDoc(111));
141       m.put("product_quantity", new Long JavaDoc(221));
142       m.put("order_number", new Long JavaDoc(4));
143       m.put("order_date", new Date(System.currentTimeMillis()));
144       m.put("retailer_name", "vlada 323");
145       Request rqHead = new Request(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()),
146                                    new URI(uriString),
147                                    YesNoIfError.Yes,
148                                    null);
149       CreateInstanceRq rqBody = new CreateInstanceRq(true,
150                                                      new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()),
151                                                      "rqName",
152                                                      "srqName",
153                                                      "Enhydra Shark engine ",
154                                                      AsapBindingUtilitiesImpl.getContextData(m,
155                                                                                              (String JavaDoc) schemaLocactions.get(SERVICE)));
156       ResponseHolder rsHead = new ResponseHolder();
157       CreateInstanceRsHolder rsBody = new CreateInstanceRsHolder();
158       rqHead.getSenderKey().setHost("vajat.prozone.co.yu");
159       //rqHead.getSenderKey().setQueryString("procId=vso&actid=a");
160
rqBody.getObserverKey().setHost("vajat.prozone.co.yu");
161       //rqBody.getObserverKey().setQueryString("procId=vso&actid=a");
162
binding.createInstance(rqHead, rqBody, rsHead, rsBody);
163       System.err.println("##" + rsBody.value.getInstanceKey());
164       ik = rsBody.value.getInstanceKey();
165    }
166
167    public void qqtestAsapInstanceBindingGetProperties() throws Exception JavaDoc {
168       Thread.sleep(70000);
169       AsapInstanceBindingStub binding;
170       try {
171          binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(new URL JavaDoc(ik.toString()));
172       } catch (javax.xml.rpc.ServiceException JavaDoc jre) {
173          if (jre.getLinkedCause() != null) jre.getLinkedCause()
174             .printStackTrace();
175          throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: "
176                                                         + jre);
177       }
178       assertNotNull("binding is null", binding);
179
180       // Time out after a minute
181
binding.setTimeout(60000);
182
183       Request rqh = new Request();
184       String JavaDoc rqb = "";
185       ResponseHolder rsh = new ResponseHolder();
186       GetPropertiesRsHolder rsb = new GetPropertiesRsHolder();
187       rqh.setReceiverKey(ik);
188
189       System.err.println("##tt");
190       // Test operation
191
binding.getProperties(rqh, rqb, rsh, rsb);
192       InstancePropertiesGroup ipg = rsb.value.getInstancePropertiesGroup();
193       System.err.println("#ipg:" + ipg.getKey());
194       System.err.println("#ipg:" + ipg.getFactoryKey());
195       URI[] _obs_ = ipg.getObservers().getObserverKey();
196       for (int n = 0; n < _obs_.length; ++n) {
197          System.err.println("#ipg" + n + ":" + _obs_[n]);
198       }
199       Event[] _ev_ = ipg.getHistory().getEvent();
200       for (int n = 0; n < _ev_.length; ++n) {
201          System.err.println("#ipg" + n + "event:" + _ev_[n].getEventType());
202          System.err.println("#ipg" + n + "event:" + _ev_[n].getTime());
203       }
204       MessageElement[] ctx = ipg.getContextData().get_any();
205       for (int n = 0; n < ctx.length; ++n) {
206          System.err.println("#ipg" + n + "ctx:" + ctx[n].toString());
207       }
208    }
209
210    private WfXmlFactoryBindingStub getFactoryBinding(String JavaDoc uriString) throws MalformedURLException JavaDoc {
211       WfXmlFactoryBindingStub binding;
212
213       try {
214          binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(new URL JavaDoc(uriString));
215       } catch (javax.xml.rpc.ServiceException JavaDoc jre) {
216          if (jre.getLinkedCause() != null) jre.getLinkedCause()
217             .printStackTrace();
218          throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: "
219                                                         + jre);
220       }
221       assertNotNull("binding is null", binding);
222
223       // Time out after a minute
224
binding.setTimeout(60000);
225       return binding;
226    }
227 }
Popular Tags