1 2 3 package org.enhydra.shark.asap.test; 4 5 10 import org.enhydra.shark.asap.types.*; 11 12 import java.net.InetAddress ; 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 import javax.xml.rpc.ServiceException ; 16 import org.apache.axis.message.MessageElement; 17 import org.apache.axis.types.URI; 18 import org.enhydra.shark.asap.*; 19 import org.enhydra.shark.asap.AsapFactoryBindingStub; 20 import org.enhydra.shark.asap.SharkWebServiceLocator; 21 import org.enhydra.shark.asap.types.holders.CreateInstanceRsHolder; 22 import org.enhydra.shark.asap.types.holders.GetPropertiesRsHolder; 23 import org.enhydra.shark.asap.types.holders.ResponseHolder; 24 25 public class CookbookTestCase extends junit.framework.TestCase { 26 private static SharkWebServiceLocator swsl = new SharkWebServiceLocator(); 27 28 private static URI ik; 29 30 private static String targetService; 31 32 public static final String TARGET_SERVICE = "asap.test.ts"; 33 34 public static final String DEFAULT_SERVICE = "http://vajat.prozone.co.yu:8080/axis/services/wfxmlFactoryBinding"; 35 36 public CookbookTestCase(java.lang.String name) { 37 super(name); 38 targetService = System.getProperty(TARGET_SERVICE, DEFAULT_SERVICE); 39 System.err.println(TARGET_SERVICE + ":" + targetService); 40 } 41 42 public void testLevel1CreateProcess() throws Exception { 43 AsapFactoryBindingStub binding = getFactroyBinding(); 44 45 Request rqHead = new Request(); 46 CreateInstanceRq rqBody = new CreateInstanceRq(); 47 ResponseHolder rsHead = new ResponseHolder(); 48 CreateInstanceRsHolder rsBody = new CreateInstanceRsHolder(); 49 50 rqHead.setReceiverKey(new URI(swsl.getasapFactoryBindingAddress())); 51 rqHead.getReceiverKey().setQueryString("procDef=181&packageId=181"); 55 rqBody.setObserverKey(new URI(swsl.getasapObserverBindingAddress())); 57 rqBody.getObserverKey().setHost(InetAddress.getLocalHost() 58 .getHostName()); 59 rqBody.setStartImmediately(true); 60 MessageElement[] b = new MessageElement[2]; 61 b[0] = new MessageElement("", "product_code"); 62 b[0].setValue("52"); 63 b[1] = new MessageElement("", "product_quantity"); 64 b[1].setValue("69"); 65 rqBody.setContextData(new CreateInstanceRqContextData(b)); 66 binding.createInstance(rqHead, rqBody, rsHead, rsBody); 68 ik = rsBody.value.getInstanceKey(); 69 System.out.println("InstanceKey is " + ik); 70 } 71 72 public void testLevel1GetPropsOfProcess() throws Exception { 73 Thread.sleep(10000); 74 AsapInstanceBindingStub binding = getInstanceBinding(ik.toString()); 75 76 Request rqHead = new Request(null, ik, YesNoIfError.Yes, ""); 77 CreateInstanceRq rqBody = new CreateInstanceRq(); 78 ResponseHolder rsHead = new ResponseHolder(); 79 GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder(); 80 binding.getProperties(rqHead, "", rsHead, rsBody); 81 InstancePropertiesGroup props = rsBody.value.getInstancePropertiesGroup(); 82 System.err.println(props.getName()); 83 for (int i = 0; i < props.getResultData().get_any().length; i++) { 84 System.err.println(props.getResultData().get_any()[i].getName() 85 + " = " 86 + props.getResultData().get_any()[i].getValue()); 87 } 88 } 89 90 125 private AsapFactoryBindingStub getFactroyBinding() throws MalformedURLException { 126 AsapFactoryBindingStub ret; 127 try { 128 ret = (AsapFactoryBindingStub) swsl.getasapFactoryBinding(new URL (targetService)); 129 } catch (ServiceException jre) { 130 if (jre.getLinkedCause() != null) jre.getLinkedCause() 131 .printStackTrace(); 132 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 133 + jre); 134 } 135 assertNotNull("binding is null", ret); 136 137 ret.setTimeout(60000); 139 return ret; 140 } 141 142 private AsapInstanceBindingStub getInstanceBinding(String s) throws MalformedURLException { 143 AsapInstanceBindingStub ret; 144 try { 145 ret = (AsapInstanceBindingStub) swsl.getasapInstanceBinding(new URL (s)); 146 } catch (ServiceException jre) { 147 if (jre.getLinkedCause() != null) jre.getLinkedCause() 148 .printStackTrace(); 149 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 150 + jre); 151 } 152 assertNotNull("binding is null", ret); 153 154 ret.setTimeout(60000); 156 return ret; 157 } 158 } 159 160 | Popular Tags |