You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2014/04/14 20:31:12 UTC
[70/90] [abbrv] AIRAVATA-1124
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/GraphTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/GraphTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/GraphTestCase.java
new file mode 100644
index 0000000..e35dacf
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/GraphTestCase.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.ComponentRegistryException;
+import org.apache.airavata.workflow.model.graph.Graph;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.xbaya.test.util.WorkflowCreator;
+
+public class GraphTestCase extends TestCase {
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws ComponentRegistryException
+ */
+ public void testRemoveNode() throws ComponentException, GraphException, ComponentRegistryException {
+ WorkflowCreator creator = new WorkflowCreator();
+ Workflow workflow = creator.createSimpleMathWorkflow();
+ Graph graph = workflow.getGraph();
+
+ Node node = graph.getNode("Adder_add");
+ assertNotNull(node);
+ int originalSize = graph.getPorts().size();
+ int portNum = node.getAllPorts().size();
+ graph.removeNode(node);
+
+ assertEquals(originalSize - portNum, graph.getPorts().size());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MetadataTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MetadataTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MetadataTestCase.java
new file mode 100644
index 0000000..2ab432f
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MetadataTestCase.java
@@ -0,0 +1,221 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.awt.Point;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.Component;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.ComponentRegistryException;
+import org.apache.airavata.workflow.model.component.local.LocalComponentRegistry;
+import org.apache.airavata.workflow.model.component.system.InputComponent;
+import org.apache.airavata.workflow.model.component.system.OutputComponent;
+import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.system.OutputNode;
+import org.apache.airavata.workflow.model.graph.ws.WSGraph;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
+public class MetadataTestCase extends TestCase {
+
+ private static final String WSDL_DIRECTORY = "/u/sshirasu/codes/appservices/gfac2/wsdls";
+
+ private static final String WRF_STATIC_PREPROCESSOR_WSDL = "WrfStaticPreprocessor.wsdl";
+
+ private static final String TERRAIN_PREPROCESSOR_WSDL = "TerrainPreprocessor.wsdl";
+
+ private static final String ADAS_INTERPOLATOR_WSDL = "ADASInterpolator.wsdl";
+
+ private static final String LATERAL_BOUNDARY_INTERPOLATOR_WSDL = "LateralBoundaryInterpolator.wsdl";
+
+ private static final String ARPS2WRF_INTERPOLATOR_WSDL = "ARPS2WRFInterpolator.wsdl";
+
+ private static final String WRF_FORECASTING_MODEL_WSDL = "WRFForecastingModel.wsdl";
+
+ private static final Logger logger = LoggerFactory.getLogger(MetadataTestCase.class);
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws IOException
+ * @throws ComponentRegistryException
+ */
+ public void testWorkflow() throws ComponentException, GraphException, IOException, ComponentRegistryException {
+ Workflow workflow = createWorkflow();
+
+ File workflowFile = new File("tmp/ADASInitializedWRFForecast.xwf");
+ XMLUtil.saveXML(workflow.toXML(), workflowFile);
+ }
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws IOException
+ * @throws ComponentRegistryException
+ */
+ public void testPreInvoke() throws ComponentException, GraphException, IOException, ComponentRegistryException {
+ Workflow workflow = createWorkflow();
+ workflow.createScript();
+
+ File workflowWSDLFile = new File("tmp/ADASInitializedWRFForecast-wsdl.xml");
+ XMLUtil.saveXML(workflow.getWorkflowWSDL().xml(), workflowWSDLFile);
+ File bpelFile = new File("tmp/ADASInitializedWRFForecast-bpel.xml");
+ XMLUtil.saveXML(workflow.getGpelProcess().xml(), bpelFile);
+
+ // Get the metadata for input.
+ XmlElement inputAppinfo = workflow.getInputMetadata();
+
+ // Get the input information
+ List<WSComponentPort> inputs = workflow.getInputs();
+
+ for (WSComponentPort input : inputs) {
+ // Show the information of each input.
+
+ // Name
+ String name = input.getName();
+ logger.info("name: " + name);
+
+ // Type
+ QName type = input.getType();
+ logger.info("type: " + type);
+
+ // Metadata as XML
+ XmlElement appinfo = input.getAppinfo();
+ logger.info("appinfo: " + XMLUtil.xmlElementToString(appinfo));
+
+ if (appinfo != null) {
+ // Parse the simple case.
+ for (XmlElement element : appinfo.requiredElementContent()) {
+ String tag = element.getName();
+ String value = element.requiredText();
+ logger.info(tag + " = " + value);
+ }
+ }
+
+ // Set a value to each input.
+ input.setValue("200");
+ }
+ }
+
+ private Workflow createWorkflow() throws ComponentException, GraphException, ComponentRegistryException {
+
+ Workflow workflow = new Workflow();
+
+ // Name, description
+ workflow.setName("ADASInitializedWRFForecast");
+ workflow.setDescription("");
+
+ WSGraph graph = workflow.getGraph();
+
+ LocalComponentRegistry componentRegistry = new LocalComponentRegistry(WSDL_DIRECTORY);
+
+ // WRF_STATIC_PREPROCESSOR_WSDL
+ Component wrfPreComp = componentRegistry.getComponent(WRF_STATIC_PREPROCESSOR_WSDL);
+ Node wrfPreNode = workflow.addNode(wrfPreComp);
+ wrfPreNode.setPosition(new Point(313, 0));
+
+ // TERRAIN_PREPROCESSOR_WSDL
+ Component terrainPreComp = componentRegistry.getComponent(TERRAIN_PREPROCESSOR_WSDL);
+ Node terrainPreNode = workflow.addNode(terrainPreComp);
+ terrainPreNode.setPosition(new Point(59, 289));
+
+ // ADAS_INTERPOLATOR_WSDL
+ Component adasIntComp = componentRegistry.getComponent(ADAS_INTERPOLATOR_WSDL);
+ Node adasIntNode = workflow.addNode(adasIntComp);
+ adasIntNode.setPosition(new Point(373, 235));
+
+ // LATERAL_BOUNDARY_INTERPOLATOR_WSDL
+ Component lateralIntComp = componentRegistry.getComponent(LATERAL_BOUNDARY_INTERPOLATOR_WSDL);
+ Node lateralIntNode = workflow.addNode(lateralIntComp);
+ lateralIntNode.setPosition(new Point(371, 369));
+
+ // ARPS2WRF_INTERPOLATOR_WSDL
+ Component arp2wrfComp = componentRegistry.getComponent(ARPS2WRF_INTERPOLATOR_WSDL);
+ Node arp2wrfNode = workflow.addNode(arp2wrfComp);
+ arp2wrfNode.setPosition(new Point(607, 104));
+
+ // WRF_FORECASTING_MODEL_WSDL
+ Component wrfComp = componentRegistry.getComponent(WRF_FORECASTING_MODEL_WSDL);
+ Node wrfNode = workflow.addNode(wrfComp);
+ wrfNode.setPosition(new Point(781, 14));
+
+ // Parameters
+ Component inputComponent = new InputComponent();
+ Component outputComponent = new OutputComponent();
+
+ // Input parameter node
+ InputNode confInput = (InputNode) workflow.addNode(inputComponent);
+ confInput.setPosition(new Point(0, 100));
+
+ // Input parameter node
+ InputNode adasInput = (InputNode) workflow.addNode(inputComponent);
+ adasInput.setPosition(new Point(286, 145));
+
+ // Input parameter node
+ InputNode namInput = (InputNode) workflow.addNode(inputComponent);
+ namInput.setPosition(new Point(179, 438));
+
+ // Output parameter
+ OutputNode outParamNode = (OutputNode) workflow.addNode(outputComponent);
+ outParamNode.setPosition(new Point(863, 169));
+
+ // Connect ports
+ graph.addEdge(confInput.getOutputPort(0), wrfPreNode.getInputPort(0));
+ graph.addEdge(confInput.getOutputPort(0), arp2wrfNode.getInputPort(0));
+ graph.addEdge(confInput.getOutputPort(0), adasIntNode.getInputPort(1));
+ graph.addEdge(confInput.getOutputPort(0), lateralIntNode.getInputPort(1));
+ graph.addEdge(confInput.getOutputPort(0), terrainPreNode.getInputPort(0));
+ graph.addEdge(terrainPreNode.getOutputPort(0), adasIntNode.getInputPort(2));
+ graph.addEdge(terrainPreNode.getOutputPort(0), lateralIntNode.getInputPort(0));
+ graph.addEdge(adasInput.getOutputPort(0), adasIntNode.getInputPort(0));
+ graph.addEdge(namInput.getOutputPort(0), lateralIntNode.getInputPort(2));
+ graph.addEdge(wrfPreNode.getOutputPort(0), arp2wrfNode.getInputPort(1));
+ graph.addEdge(adasIntNode.getOutputPort(0), arp2wrfNode.getInputPort(2));
+ graph.addEdge(lateralIntNode.getOutputPort(0), arp2wrfNode.getInputPort(3));
+ graph.addEdge(arp2wrfNode.getOutputPort(0), wrfNode.getInputPort(0));
+ graph.addEdge(wrfNode.getOutputPort(0), outParamNode.getInputPort(0));
+
+ // Add metadata
+ String inputMetadata = "<appinfo "
+ + "xmlns:lsm=\"http://www.extreme.indiana.edu/namespaces/2006/lead-service-metadata\">"
+ + "<lsm:constraints>" + "<lsm:constraint type=\"temporalSync\">"
+ + "<lsm:elementref name=\"ADASDataFiles\" />" + "<lsm:elementref name=\"NAMDataFiles\" />"
+ + "</lsm:constraint>" + "</lsm:constraints>" + "</appinfo>";
+ graph.setInputMetadata(XMLUtil.stringToXmlElement(inputMetadata));
+
+ return workflow;
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MonitorTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MonitorTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MonitorTestCase.java
new file mode 100644
index 0000000..1962104
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/MonitorTestCase.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import org.apache.airavata.workflow.tracking.Notifier;
+import org.apache.airavata.workflow.tracking.NotifierFactory;
+import org.apache.airavata.workflow.tracking.common.InvocationEntity;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.airavata.workflow.tracking.impl.state.DataObjImpl;
+import org.apache.airavata.wsmg.client.WseMsgBrokerClient;
+import org.apache.axis2.addressing.EndpointReference;
+
+public class MonitorTestCase extends XBayaTestCase {
+
+ private final static URI WORKFLOW_INSTANCE_ID = URI
+ .create("tag:gpel.leadproject.org,2006:6B9/GFacTestWorkflow1/instance1");
+
+ /**
+ */
+ public void test() {
+ EndpointReference brokerEPR = WseMsgBrokerClient.createEndpointReference(this.configuration.getBrokerURL()
+ .toString(), this.configuration.getTopic());
+
+ Notifier notifier = NotifierFactory.createNotifier();
+
+ WorkflowTrackingContext context = notifier.createTrackingContext(new Properties(), brokerEPR.toString(),
+ URI.create("workflowID"), URI.create("serviceID"), "workflowNodeID", new Integer(1));
+ notifier.publishURL(context, "title", "http://www.google.com", "descriptionAndAnnotation");
+
+ notifier.workflowInitialized(context, WORKFLOW_INSTANCE_ID);
+
+ DataObjImpl dataObj = new DataObjImpl(URI.create("test"), new ArrayList<URI>());
+ notifier.dataConsumed(context, dataObj, "description");
+ }
+
+ /**
+ *
+ */
+ public void testScalability() {
+ for (int i = 0; i < 100; i++) {
+ test();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/ResourceNotifierTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/ResourceNotifierTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/ResourceNotifierTestCase.java
new file mode 100644
index 0000000..00dbcb5
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/ResourceNotifierTestCase.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.apache.airavata.workflow.tracking.Notifier;
+import org.apache.airavata.workflow.tracking.NotifierFactory;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.airavata.wsmg.client.WseMsgBrokerClient;
+
+import org.apache.axis2.addressing.EndpointReference;
+
+public class ResourceNotifierTestCase extends XBayaTestCase {
+
+ /**
+ *
+ */
+ public void test() {
+ EndpointReference brokerEPR = WseMsgBrokerClient.createEndpointReference(this.configuration.getBrokerURL()
+ .toString(), this.configuration.getTopic());
+ Notifier notifier = NotifierFactory.createNotifier();
+
+ URI initiatorWorkflowID = URI.create("Workflow");
+ URI initiatorServiceID = URI.create("Adder_add");
+ String initiatorWorkflowNodeID1 = "Adder_add";
+ Integer workflowTimeStep = new Integer(0);
+ WorkflowTrackingContext context = notifier.createTrackingContext(new Properties(), brokerEPR.toString(),
+ initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID1, workflowTimeStep);
+ notifier.resourceMapping(context, "resource1.example.com", 1, null);
+ notifier.resourceMapping(context, "resource2.example.com", 2);
+ notifier.resourceMapping(context, "resource3.example.com", 3);
+
+ String initiatorWorkflowNodeID2 = "Adder_add_2";
+ context = notifier.createTrackingContext(new Properties(), brokerEPR.toString(), initiatorWorkflowID,
+ initiatorServiceID, initiatorWorkflowNodeID2, workflowTimeStep);
+ notifier.resourceMapping(context, "resource.example.com", 0);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/StringUtilTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/StringUtilTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/StringUtilTestCase.java
new file mode 100644
index 0000000..0ece074
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/StringUtilTestCase.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.common.utils.StringUtil;
+
+public class StringUtilTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public void testIncrementName() {
+ String name1 = "test";
+ String name2 = StringUtil.incrementName(name1);
+ assertEquals(name2, "test_2");
+ String name3 = StringUtil.incrementName(name2);
+ assertEquals(name3, "test_3");
+
+ String name9 = "test_9";
+ String name10 = StringUtil.incrementName(name9);
+ assertEquals(name10, "test_10");
+ String name11 = StringUtil.incrementName(name10);
+ assertEquals(name11, "test_11");
+
+ String nameA = "test_a";
+ String nameA2 = StringUtil.incrementName(nameA);
+ assertEquals(nameA2, "test_a_2");
+
+ String name = "test_";
+ String name_2 = StringUtil.incrementName(name);
+ assertEquals(name_2, "test__2");
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLTestCase.java
new file mode 100644
index 0000000..4476474
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLTestCase.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.ComponentRegistryException;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.xbaya.jython.script.JythonScript;
+import org.apache.airavata.xbaya.test.util.WorkflowCreator;
+import org.apache.airavata.common.utils.IOUtil;
+
+public class WSDLTestCase extends XBayaTestCase {
+
+ // private static final Logger logger = LoggerFactory.getLogger();
+
+ private WorkflowCreator graphCreater;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ File tmpDir = new File("tmp");
+ tmpDir.mkdir();
+
+ this.graphCreater = new WorkflowCreator();
+ }
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws IOException
+ * @throws ComponentRegistryException
+ */
+ public void testSimpleMath() throws ComponentException, GraphException, IOException, ComponentRegistryException {
+
+ Workflow workflow = this.graphCreater.createSimpleMathWorkflow();
+
+ File workflowFile = new File("tmp/simple-math.xwf");
+ XMLUtil.saveXML(workflow.toXML(), workflowFile);
+
+ // Creates a Jython script
+ File jythonFile = new File("tmp/simple-math.py");
+ JythonScript script = new JythonScript(workflow, this.configuration);
+ script.create();
+ IOUtil.writeToFile(script.getJythonString(), jythonFile);
+ }
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws IOException
+ * @throws ComponentRegistryException
+ */
+ public void testComplexMath() throws ComponentException, GraphException, IOException, ComponentRegistryException {
+ Workflow workflow = this.graphCreater.createComplexMathWorkflow();
+ File graphFile = new File("tmp/complex-math.xwf");
+ XMLUtil.saveXML(workflow.toXML(), graphFile);
+
+ // Creates a Jython script
+ File jythonFile = new File("tmp/complex-math.py");
+ JythonScript script = new JythonScript(workflow, this.configuration);
+ script.create();
+ IOUtil.writeToFile(script.getJythonString(), jythonFile);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLUtilTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLUtilTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLUtilTestCase.java
new file mode 100644
index 0000000..9386734
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSDLUtilTestCase.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.net.URI;
+
+import org.apache.airavata.common.utils.WSDLUtil;
+
+public class WSDLUtilTestCase extends XBayaTestCase {
+
+ /**
+ *
+ */
+ public void testAppendWSDLQuary() {
+ URI uri0 = URI.create("http://localhost:8080");
+ URI wsdlURI0 = WSDLUtil.appendWSDLQuary(uri0);
+ assertEquals("http://localhost:8080/?wsdl", wsdlURI0.toString());
+
+ URI uri1 = URI.create("http://localhost:8080/");
+ URI wsdlURI1 = WSDLUtil.appendWSDLQuary(uri1);
+ assertEquals("http://localhost:8080/?wsdl", wsdlURI1.toString());
+
+ URI uri2 = URI.create("http://localhost:8080/service");
+ URI wsdlURI2 = WSDLUtil.appendWSDLQuary(uri2);
+ assertEquals("http://localhost:8080/service?wsdl", wsdlURI2.toString());
+
+ URI uri3 = URI.create("http://localhost:8080/?wsdl");
+ URI wsdlURI3 = WSDLUtil.appendWSDLQuary(uri3);
+ assertEquals("http://localhost:8080/?wsdl", wsdlURI3.toString());
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSIFTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSIFTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSIFTestCase.java
new file mode 100644
index 0000000..4b43502
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WSIFTestCase.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import junit.framework.TestSuite;
+
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.ui.widgets.component.ComponentTreeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WSIFTestCase extends XBayaTestCase {
+
+ private static final Logger logger = LoggerFactory.getLogger(WSIFTestCase.class);
+
+ private ComponentTreeNode resouceCatalogComponentTree;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(new TestSuite(WSIFTestCase.class));
+ }
+
+ /**
+ * @see org.apache.airavata.xbaya.test.XBayaTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.resouceCatalogComponentTree = null;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WaitDialogTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WaitDialogTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WaitDialogTestCase.java
new file mode 100644
index 0000000..89839db
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WaitDialogTestCase.java
@@ -0,0 +1,282 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.dialogs.WaitDialog;
+import org.apache.airavata.xbaya.ui.utils.Cancelable;
+
+public class WaitDialogTestCase extends XBayaTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Prevent to connect to GPEL engine every time.
+ this.configuration.setGPELEngineURL(null);
+
+ this.configuration.setHeight(200);
+ this.configuration.setWidth(200);
+ }
+
+ /**
+ * @throws InterruptedException
+ *
+ */
+ public void testShowHide() throws InterruptedException {
+ XBayaEngine engine = new XBayaEngine(this.configuration);
+ Cancelable cancelable = new Cancelable() {
+ public void cancel() {
+ // Nothing
+ }
+ };
+ final WaitDialog dialog = new WaitDialog(cancelable, "title", "message", engine.getGUI());
+ Thread showThread = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+ showThread.start();
+
+ Thread.sleep(1000);
+
+ dialog.hide();
+
+ showThread.join();
+ }
+
+ /**
+ * @throws InterruptedException
+ *
+ */
+ public void testShowShowHide() throws InterruptedException {
+ XBayaEngine engine = new XBayaEngine(this.configuration);
+ Cancelable cancelable = new Cancelable() {
+ public void cancel() {
+ // Nothing
+ }
+ };
+ final WaitDialog dialog = new WaitDialog(cancelable, "title", "message", engine.getGUI());
+ Thread showThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread showThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread hideThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ showThread1.start();
+ showThread2.start();
+
+ Thread.sleep(1000);
+
+ hideThread1.start();
+
+ showThread1.join();
+ showThread2.join();
+ hideThread1.join();
+ }
+
+ /**
+ * @throws InterruptedException
+ *
+ */
+ public void testShowHideShowHide() throws InterruptedException {
+ XBayaEngine engine = new XBayaEngine(this.configuration);
+ Cancelable cancelable = new Cancelable() {
+ public void cancel() {
+ // Nothing
+ }
+ };
+ final WaitDialog dialog = new WaitDialog(cancelable, "title", "message", engine.getGUI());
+ Thread showThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread showThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread hideThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ Thread hideThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ showThread1.start();
+
+ Thread.sleep(1000);
+
+ hideThread1.start();
+
+ Thread.sleep(1000);
+ showThread2.start();
+
+ Thread.sleep(1000);
+ hideThread2.start();
+
+ showThread1.join();
+ showThread2.join();
+ hideThread1.join();
+ hideThread2.join();
+ }
+
+ /**
+ * @throws InterruptedException
+ */
+ public void testShowHideHide() throws InterruptedException {
+ XBayaEngine engine = new XBayaEngine(this.configuration);
+ Cancelable cancelable = new Cancelable() {
+ public void cancel() {
+ // Nothing
+ }
+ };
+ final WaitDialog dialog = new WaitDialog(cancelable, "title", "message", engine.getGUI());
+ Thread showThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread hideThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ Thread hideThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ showThread1.start();
+
+ Thread.sleep(1000);
+
+ hideThread1.start();
+ hideThread2.start();
+
+ showThread1.join();
+ hideThread1.join();
+ hideThread2.join();
+ }
+
+ /**
+ * @throws InterruptedException
+ */
+ public void testShowShowHideHide() throws InterruptedException {
+ XBayaEngine engine = new XBayaEngine(this.configuration);
+ Cancelable cancelable = new Cancelable() {
+ public void cancel() {
+ // Nothing
+ }
+ };
+ final WaitDialog dialog = new WaitDialog(cancelable, "title", "message", engine.getGUI());
+ Thread showThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread showThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+
+ };
+
+ Thread hideThread1 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ Thread hideThread2 = new Thread() {
+ @Override
+ public void run() {
+ dialog.hide();
+ }
+
+ };
+
+ showThread1.start();
+ showThread2.start();
+
+ Thread.sleep(1000);
+
+ hideThread1.start();
+ hideThread2.start();
+
+ showThread1.join();
+ showThread2.join();
+ hideThread1.join();
+ hideThread2.join();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WebComponentRegistryClientTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WebComponentRegistryClientTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WebComponentRegistryClientTestCase.java
new file mode 100644
index 0000000..8db2612
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WebComponentRegistryClientTestCase.java
@@ -0,0 +1,173 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.awt.Point;
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.airavata.common.utils.IOUtil;
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.Component;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.system.InputComponent;
+import org.apache.airavata.workflow.model.component.system.OutputComponent;
+import org.apache.airavata.workflow.model.component.web.WebComponentRegistry;
+import org.apache.airavata.workflow.model.graph.Graph;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.system.OutputNode;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.jython.script.JythonScript;
+import org.xmlpull.infoset.XmlElement;
+
+public class WebComponentRegistryClientTestCase extends XBayaTestCase {
+
+ /**
+ * MATH_ADDER_WSDL
+ */
+ private static final String MATH_ADDER_WSDL = "adder-wsdl.xml";
+
+ /**
+ * MATH_MULTIPLIER_WSDL
+ */
+ private static final String MATH_MULTIPLIER_WSDL = "multiplier-wsdl.xml";
+
+ private Component inputComponent;
+
+ private Component outputComponent;
+
+ private WebComponentRegistry componentRegistry;
+
+ private File temporaryDirectory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ this.temporaryDirectory = new File("tmp");
+ this.temporaryDirectory.mkdir();
+
+ this.componentRegistry = new WebComponentRegistry(XBayaConstants.DEFAULT_WEB_REGISTRY.toURL());
+ this.componentRegistry.getComponentReferenceList(); // To read components
+ this.inputComponent = new InputComponent();
+ this.outputComponent = new OutputComponent();
+ }
+
+ /**
+ * @throws GraphException
+ * @throws ComponentException
+ * @throws IOException
+ */
+ public void testComplexMath() throws GraphException, ComponentException, IOException {
+
+ Workflow workflow = createComplexMathWorkflow();
+ File workflowFile = new File(this.temporaryDirectory, "web-complex-math.xwf");
+ XMLUtil.saveXML(workflow.toXML(), workflowFile);
+
+ // Load the same graph again from the file, saves it, and compare them.
+ XmlElement workflowElement = XMLUtil.loadXML(workflowFile);
+ Workflow workflow2 = new Workflow(workflowElement);
+ File workflowFile2 = new File(this.temporaryDirectory, "web-complex-math-2.xwf");
+ XMLUtil.saveXML(workflow2.toXML(), workflowFile2);
+
+ String workflowFileString = IOUtil.readFileToString(workflowFile);
+ String workflowFile2String = IOUtil.readFileToString(workflowFile2);
+ assertEquals(workflowFileString, workflowFile2String);
+
+ // Create a Jython script
+ File jythonFile = new File(this.temporaryDirectory, "web-complex-math.py");
+ JythonScript script = new JythonScript(workflow, this.configuration);
+ script.create();
+ IOUtil.writeToFile(script.getJythonString(), jythonFile);
+ }
+
+ /**
+ * @return The graph
+ * @throws GraphException
+ */
+ private Workflow createComplexMathWorkflow() throws GraphException {
+
+ Workflow workflow = new Workflow();
+
+ // Name, description
+ workflow.setName("Complex math workflow");
+ workflow.setDescription("Complex math workflow");
+
+ Graph graph = workflow.getGraph();
+
+ // Adder nodes
+ Component adderComp = this.componentRegistry.getComponents(MATH_ADDER_WSDL).get(0);
+
+ Node adderNode1 = workflow.addNode(adderComp);
+ adderNode1.setPosition(new Point(170, 50));
+
+ Node adderNode2 = workflow.addNode(adderComp);
+ adderNode2.setPosition(new Point(170, 210));
+
+ // Multiplier node
+ Component multiComp = this.componentRegistry.getComponents(MATH_MULTIPLIER_WSDL).get(0);
+
+ Node multiNode = workflow.addNode(multiComp);
+ multiNode.setPosition(new Point(320, 130));
+
+ // Parameter node 1
+ InputNode paramNode1 = (InputNode) workflow.addNode(this.inputComponent);
+ paramNode1.setPosition(new Point(20, 30));
+ String paramValue1 = "2";
+ paramNode1.setDefaultValue(paramValue1);
+
+ // Parameter node 2
+ InputNode paramNode2 = (InputNode) workflow.addNode(this.inputComponent);
+ paramNode2.setPosition(new Point(20, 100));
+ String paramValue2 = "3";
+ paramNode2.setDefaultValue(paramValue2);
+
+ // Parameter node 3
+ InputNode paramNode3 = (InputNode) workflow.addNode(this.inputComponent);
+ paramNode3.setPosition(new Point(20, 170));
+ String paramValue3 = "4";
+ paramNode3.setDefaultValue(paramValue3);
+
+ // Parameter node 4
+ InputNode paramNode4 = (InputNode) workflow.addNode(this.inputComponent);
+ paramNode4.setPosition(new Point(20, 240));
+ String paramValue4 = "5";
+ paramNode4.setDefaultValue(paramValue4);
+
+ OutputNode outParamNode = (OutputNode) workflow.addNode(this.outputComponent);
+ outParamNode.setPosition(new Point(370, 240));
+
+ // Connect ports
+ graph.addEdge(paramNode1.getOutputPort(0), adderNode1.getInputPort(0));
+ graph.addEdge(paramNode2.getOutputPort(0), adderNode1.getInputPort(1));
+ graph.addEdge(paramNode3.getOutputPort(0), adderNode2.getInputPort(0));
+ graph.addEdge(paramNode4.getOutputPort(0), adderNode2.getInputPort(1));
+ graph.addEdge(adderNode1.getOutputPort(0), multiNode.getInputPort(0));
+ graph.addEdge(adderNode2.getOutputPort(0), multiNode.getInputPort(1));
+ graph.addEdge(multiNode.getOutputPort(0), outParamNode.getInputPort(0));
+
+ return workflow;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
new file mode 100644
index 0000000..737ebcf
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
@@ -0,0 +1,373 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.awt.Point;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.airavata.common.exception.UtilsException;
+import org.apache.airavata.common.utils.WSDLUtil;
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.Component;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.ComponentRegistryException;
+import org.apache.airavata.workflow.model.component.local.LocalComponentRegistry;
+import org.apache.airavata.workflow.model.component.system.OutputComponent;
+import org.apache.airavata.workflow.model.gpel.DSCUtil;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.Node.NodeExecutionState;
+import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
+import org.apache.airavata.workflow.model.graph.ws.WSGraph;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.workflow.tracking.client.Callback;
+import org.apache.airavata.workflow.tracking.client.NotificationType;
+import org.apache.airavata.workflow.tracking.common.InvocationContext;
+import org.apache.airavata.workflow.tracking.common.InvocationEntity;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.airavata.workflow.tracking.impl.NotifierImpl;
+import org.apache.airavata.workflow.tracking.impl.publish.LoopbackPublisher;
+import org.apache.airavata.workflow.tracking.impl.publish.NotificationPublisher;
+import org.apache.airavata.ws.monitor.Monitor;
+import org.apache.airavata.ws.monitor.MonitorConfiguration;
+import org.apache.airavata.ws.monitor.EventDataRepository;
+import org.apache.airavata.ws.monitor.MonitorException;
+import org.apache.airavata.ws.monitor.event.Event;
+import org.apache.airavata.ws.monitor.event.Event.Type;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.modifier.WorkflowModifier;
+import org.apache.airavata.xbaya.test.service.adder.Adder;
+import org.apache.airavata.xbaya.test.service.multiplier.Multiplier;
+import org.apache.airavata.xbaya.test.util.WorkflowCreator;
+import org.apache.airavata.xbaya.ui.graph.GraphCanvas;
+import org.apache.xmlbeans.XmlObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.view.XmlValidationException;
+import org.xmlpull.v1.builder.XmlElement;
+
+import xsul.soap11_util.Soap11Util;
+import xsul.wsif.WSIFMessage;
+import xsul.wsif.WSIFOperation;
+import xsul.wsif.WSIFPort;
+import xsul.wsif.WSIFService;
+import xsul.wsif.WSIFServiceFactory;
+import xsul.xbeans_util.XBeansUtil;
+import xsul.xwsif_runtime.WSIFClient;
+import xsul.xwsif_runtime.WSIFRuntime;
+import xsul5.wsdl.WsdlDefinitions;
+import xsul5.wsdl.WsdlResolver;
+
+public class WorkflowModificationTestCase extends XBayaTestCase {
+
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowModificationTestCase.class);
+
+ private boolean gui = false;
+
+ private XBayaEngine engine;
+
+ private GraphCanvas graphCanvas;
+
+ /**
+ * @see org.apache.airavata.xbaya.test.XBayaTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ String guiProperty = System.getProperty("xbaya.gui.test");
+ this.gui = Boolean.parseBoolean(guiProperty);
+ }
+
+ /**
+ * @throws IOException
+ * @throws ComponentRegistryException
+ * @throws GraphException
+ * @throws ComponentException
+ * @throws MonitorException
+ */
+ public void test() throws IOException, ComponentException, GraphException, ComponentRegistryException,
+ MonitorException {
+
+ WorkflowCreator creator = new WorkflowCreator();
+ Workflow workflow = creator.createComplexMathWorkflow();
+ workflow.createScript();
+
+ Monitor monitor;
+ if (this.gui) {
+ this.engine = new XBayaEngine(this.configuration);
+ this.graphCanvas = this.engine.getGUI().getGraphCanvas();
+ this.graphCanvas.setWorkflow(workflow);
+ monitor = this.engine.getMonitor();
+ this.engine.getGUI().eventReceived(new Event(Type.MONITOR_STARTED));
+ repaintAndWait(2);
+ } else {
+ MonitorConfiguration monitorConfiguration = new MonitorConfiguration(this.configuration.getBrokerURL(),
+ this.configuration.getTopic(), this.configuration.isPullMode(),
+ this.configuration.getMessageBoxURL());
+ monitor = new Monitor(monitorConfiguration);
+ }
+
+ EventDataRepository eventData = monitor.getEventDataRepository();
+ MonitorCallback callback = new MonitorCallback(eventData);
+ LoopbackPublisher publisher = new LoopbackPublisher(callback, this.configuration.getTopic());
+ MonitorNotifier notifier = new MonitorNotifier(publisher);
+
+ executeToMiddle(workflow, notifier);
+
+ modifyWorkflow(workflow);
+
+ File modifiedWorkflowFile = new File(this.temporalDirectory, "complex-math-modified.xwf");
+ XMLUtil.saveXML(workflow.toXML(), modifiedWorkflowFile);
+
+ // Create a diff workflow
+ WorkflowModifier modifier = new WorkflowModifier(workflow, eventData);
+ Workflow diffWorkflow = modifier.createDifference();
+
+ if (this.gui) {
+ GraphCanvas canvas = this.engine.getGUI().newGraphCanvas(true);
+ canvas.setWorkflow(diffWorkflow);
+ repaintAndWait(5);
+ }
+
+ File diffWorkflowFile = new File(this.temporalDirectory, "complex-math-diff.xwf");
+ XMLUtil.saveXML(diffWorkflow.toXML(), diffWorkflowFile);
+
+ }
+
+ private void executeToMiddle(Workflow workflow, MonitorNotifier notifier) throws XmlValidationException,
+ ComponentException {
+ WSGraph graph = workflow.getGraph();
+
+ String adder1ID = "Adder_add";
+ String adder2ID = "Adder_add_2";
+
+ NodeImpl a = graph.getNode("a");
+ NodeImpl b = graph.getNode("b");
+ NodeImpl c = graph.getNode("c");
+ NodeImpl d = graph.getNode("d");
+ NodeImpl adder = graph.getNode(adder1ID);
+ NodeImpl adder2 = graph.getNode(adder2ID);
+
+ WsdlDefinitions workflowWSDL = workflow.getWorkflowWSDL();
+ DSCUtil.convertToCWSDL(workflowWSDL, URI.create("http://example.com"));
+ HashMap<String, String> inputMap = new HashMap<String, String>();
+ inputMap.put("a", "2");
+ inputMap.put("b", "3");
+ inputMap.put("c", "4");
+ inputMap.put("d", "5");
+
+ try {
+ sendNotification(workflowWSDL, null, WSDLUtil.getFirstOperation(workflowWSDL).getName(), inputMap, null,
+ notifier);
+ } catch (UtilsException e) {
+ e.printStackTrace();
+ }
+
+ WsdlDefinitions adderWSDL = WsdlResolver.getInstance().loadWsdl(
+ new File(XBayaPathConstants.WSDL_DIRECTORY + File.separator + Adder.WSDL_PATH).toURI());
+
+ HashMap<String, String> inputMap1 = new HashMap<String, String>();
+ inputMap1.put("x", "2");
+ inputMap1.put("y", "3");
+ HashMap<String, String> outputMap1 = new HashMap<String, String>();
+ outputMap1.put("z", "5");
+ sendNotification(adderWSDL, adder1ID, "add", inputMap1, outputMap1, notifier);
+ // These are needed because without GUI, the nodes' color won't be
+ // changed.
+ a.setState(NodeExecutionState.FINISHED);
+ b.setState(NodeExecutionState.FINISHED);
+ adder.setState(NodeExecutionState.FINISHED);
+ repaintAndWait(3);
+
+ HashMap<String, String> inputMap2 = new HashMap<String, String>();
+ inputMap2.put("x", "4");
+ inputMap2.put("y", "5");
+ HashMap<String, String> outputMap2 = new HashMap<String, String>();
+ outputMap2.put("z", "9");
+ sendNotification(adderWSDL, adder2ID, "add", inputMap2, outputMap2, notifier);
+
+ c.setState(NodeExecutionState.FINISHED);
+ d.setState(NodeExecutionState.FINISHED);
+ adder2.setState(NodeExecutionState.FINISHED);
+ repaintAndWait(3);
+ }
+
+ private void modifyWorkflow(Workflow workflow) throws ComponentException, ComponentRegistryException,
+ GraphException {
+ WSGraph graph = workflow.getGraph();
+
+ OutputComponent outputComponent = new OutputComponent();
+ LocalComponentRegistry registry = new LocalComponentRegistry(XBayaPathConstants.WSDL_DIRECTORY);
+ Component adderComponent = registry.getComponent(Adder.WSDL_PATH);
+ Component multiplierComponent = registry.getComponent(Multiplier.WSDL_PATH);
+
+ NodeImpl c = graph.getNode("c");
+ NodeImpl d = graph.getNode("d");
+ NodeImpl adder = graph.getNode("Adder_add");
+ NodeImpl adder2 = graph.getNode("Adder_add_2");
+ NodeImpl multiplier = graph.getNode("Multiplier_multiply");
+
+ // Remove Adder_2 and replace with Multiplier_2.
+ graph.removeNode(adder2);
+ repaintAndWait(1);
+
+ Node multiplier2 = workflow.addNode(multiplierComponent);
+ multiplier2.setPosition(new Point(170, 210));
+ repaintAndWait(1);
+
+ graph.addEdge(c.getOutputPort(0), multiplier2.getInputPort(0));
+ repaintAndWait(1);
+
+ graph.addEdge(d.getOutputPort(0), multiplier2.getInputPort(1));
+ repaintAndWait(1);
+
+ graph.addEdge(multiplier2.getOutputPort(0), multiplier.getInputPort(1));
+ repaintAndWait(1);
+
+ // Add one more adder and an output.
+ Node adder3 = workflow.addNode(adderComponent);
+ adder3.setPosition(new Point(320, 300));
+ repaintAndWait(1);
+
+ graph.addEdge(adder.getOutputPort(0), adder3.getInputPort(0));
+ repaintAndWait(1);
+
+ graph.addEdge(multiplier2.getOutputPort(0), adder3.getInputPort(1));
+ repaintAndWait(1);
+
+ Node output2 = workflow.addNode(outputComponent);
+ output2.setPosition(new Point(500, 300));
+ repaintAndWait(1);
+
+ graph.addEdge(adder3.getOutputPort(0), output2.getInputPort(0));
+ repaintAndWait(1);
+ }
+
+ private void sendNotification(WsdlDefinitions definitions, String nodeID, String operationName,
+ Map<String, String> inputMap, Map<String, String> outputMap, MonitorNotifier notifier) {
+
+ WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
+ WSIFService service = factory.getService(WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(definitions));
+ WSIFClient client = WSIFRuntime.getDefault().newClientFor(service, null);
+ WSIFPort port = client.getPort();
+ WSIFOperation operation = port.createOperation(operationName);
+ WSIFMessage inputMessage = operation.createInputMessage();
+
+ for (String key : inputMap.keySet()) {
+ String value = inputMap.get(key);
+ inputMessage.setObjectPart(key, value);
+ }
+
+ URI myWorkflowID = null;
+ URI myServiceID = URI.create(XBayaConstants.APPLICATION_SHORT_NAME);
+ String myNodeID = null;
+ Integer myTimestep = null;
+ InvocationEntity myEntity = notifier.createEntity(myWorkflowID, myServiceID, myNodeID, myTimestep);
+
+ URI serviceWorkflowID = null;
+ URI serviceServiceID = URI.create("ServiceID");
+ String serviceNodeID = nodeID;
+ Integer serviceTimestep = null;
+ InvocationEntity serviceEntity = notifier.createEntity(serviceWorkflowID, serviceServiceID, serviceNodeID,
+ serviceTimestep);
+ WorkflowTrackingContext workflowContext = notifier.createTrackingContext(new Properties(), this.configuration
+ .getBrokerURL().toASCIIString(), myWorkflowID, myServiceID, myNodeID, myTimestep);
+
+ XmlElement inputBody = (XmlElement) ((XmlElement) inputMessage).getParent();
+ XmlObject inputBodyObject = XBeansUtil.xmlElementToXmlObject(inputBody);
+
+ InvocationContext context = notifier.invokingService(workflowContext, serviceEntity, null, inputBodyObject);
+
+ if (outputMap != null) {
+ WSIFMessage outputMessage = operation.createOutputMessage();
+ Soap11Util.getInstance().wrapBodyContent((XmlElement) outputMessage);
+ for (String key : outputMap.keySet()) {
+ String value = outputMap.get(key);
+ outputMessage.setObjectPart(key, value);
+ }
+ XmlElement outputBody = (XmlElement) ((XmlElement) outputMessage).getParent();
+ XmlObject outputBodyObject = XBeansUtil.xmlElementToXmlObject(outputBody);
+
+ notifier.receivedResult(workflowContext, context, null, outputBodyObject);
+ }
+ }
+
+ private void repaintAndWait(int second) {
+ if (this.gui) {
+ this.graphCanvas.repaint();
+ try {
+ Thread.sleep(second * 1000);
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ private class MonitorNotifier extends NotifierImpl {
+
+ /**
+ * Constructs a MonitorNotifier.
+ *
+ * @param publisher
+ */
+ public MonitorNotifier(NotificationPublisher publisher) {
+ super();
+ }
+ }
+
+ private class MonitorCallback implements Callback {
+
+ private EventDataRepository eventData;
+
+ /**
+ * Constructs a MonitorCallback.
+ *
+ * @param eventData
+ */
+ public MonitorCallback(EventDataRepository eventData) {
+ this.eventData = eventData;
+ }
+
+ /**
+ *
+ * @param topic
+ * the topic to which this message was sent. This can also be retrieved from the messageObj XMlObject
+ * directly after typecasting.
+ * @param type
+ * @param message
+ */
+ public void deliverMessage(String topic, NotificationType type, XmlObject message) {
+
+ XmlElement event = XBeansUtil.xmlObjectToXmlElement(message);
+ this.eventData.addEvent(XMLUtil.xmlElement3ToXmlElement5(event));
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowTestCase.java
new file mode 100644
index 0000000..8eb5092
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowTestCase.java
@@ -0,0 +1,120 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.component.ComponentRegistryException;
+import org.apache.airavata.workflow.model.graph.Graph;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.util.GraphUtil;
+import org.apache.airavata.workflow.model.graph.ws.WSNode;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.test.util.WorkflowCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
+public class WorkflowTestCase extends XBayaTestCase {
+
+ private static Logger logger = LoggerFactory.getLogger(WorkflowTestCase.class);
+
+ private WorkflowCreator workflowCreator;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.workflowCreator = new WorkflowCreator();
+ }
+
+ /**
+ * @throws IOException
+ * @throws GraphException
+ * @throws ComponentException
+ */
+ public void testParse() throws IOException, GraphException, ComponentException {
+
+ File file = new File(XBayaPathConstants.WORKFLOW_DIRECTORY, "complex-math.xwf");
+ XmlElement workflowXML = XMLUtil.loadXML(file);
+
+ // Parse the workflow
+ Workflow workflow = new Workflow(workflowXML);
+
+ // Take out the graph of the workflow.
+ Graph graph = workflow.getGraph();
+
+ // Extract inputs of the workflow.
+ Collection<InputNode> inputNodes = GraphUtil.getInputNodes(graph);
+
+ for (InputNode inputNode : inputNodes) {
+
+ // Name of the input.
+ String inputName = inputNode.getName();
+ logger.info("inputName: " + inputName);
+
+ // Get next nodes.
+ Collection<Node> nextNodes = GraphUtil.getNextNodes(inputNode);
+
+ for (Node nextNode : nextNodes) {
+
+ String name = nextNode.getName();
+ logger.info("name: " + name);
+ }
+ }
+ }
+
+ /**
+ * @throws ComponentException
+ * @throws GraphException
+ * @throws IOException
+ * @throws ComponentRegistryException
+ */
+ public void testSaveAndLoad() throws ComponentException, GraphException, IOException, ComponentRegistryException {
+
+ Workflow workflow = this.workflowCreator.createComplexMathWorkflow();
+
+ XmlElement workflowElement = workflow.toXML();
+ File file = new File(this.temporalDirectory, "complex-math.xwf");
+ XMLUtil.saveXML(workflowElement, file);
+
+ XmlElement loadedWorkflowElement = XMLUtil.loadXML(file);
+ Workflow loadedWorkflow = new Workflow(loadedWorkflowElement);
+
+ Graph loadedGraph = loadedWorkflow.getGraph();
+ Collection<WSNode> loadedWSNodes = GraphUtil.getWSNodes(loadedGraph);
+ assertTrue(loadedWSNodes.size() != 0);
+
+ for (WSNode loadedWSNode : loadedWSNodes) {
+ assertNotNull(loadedWSNode.getComponent());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaSecurityTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaSecurityTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaSecurityTestCase.java
new file mode 100644
index 0000000..728151a
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaSecurityTestCase.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.net.URI;
+
+import junit.framework.TestSuite;
+
+import org.apache.airavata.common.utils.WSDLUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import xsul.wsdl.WsdlResolver;
+
+public class XBayaSecurityTestCase extends XBayaTestCase {
+
+ private static final Logger logger = LoggerFactory.getLogger(XBayaSecurityTestCase.class);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(new TestSuite(XBayaSecurityTestCase.class));
+ }
+
+ /**
+ * @see org.apache.airavata.xbaya.test.XBayaTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ // Security related XSUL is configured in super.setUp();
+ super.setUp();
+ }
+
+ /**
+ *
+ */
+ public void testWSDL() {
+ URI gFacURL = this.configuration.getGFacURL();
+ URI gFacWSDLURL = WSDLUtil.appendWSDLQuary(gFacURL);
+ gFacWSDLURL = URI.create("https://tyr12.cs.indiana.edu:22443/data_catalog?wsdl"); // FAIL
+ gFacWSDLURL = URI.create("https://tyr12.cs.indiana.edu:9443/wcs?wsdl"); // FAIL
+ gFacWSDLURL = URI.create("https://tyr13.cs.indiana.edu:7443/gpel/"); // OK
+
+ logger.info("accessing " + gFacWSDLURL);
+ WsdlResolver.getInstance().loadWsdl(gFacWSDLURL);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaTestCase.java
new file mode 100644
index 0000000..8114543
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XBayaTestCase.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.io.File;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.xbaya.XBayaConfiguration;
+import org.slf4j.Logger;
+
+public abstract class XBayaTestCase extends TestCase {
+
+
+ protected XBayaConfiguration configuration;
+
+ protected File temporalDirectory;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ this.configuration = new XBayaConfiguration();
+
+ // tmp directory
+ this.temporalDirectory = new File("tmp/");
+ this.temporalDirectory.mkdir();
+
+ // topic
+ if (this.configuration.getTopic() == null) {
+ this.configuration.setTopic("xbaya-test");
+ }
+
+ // Overwrite some default setting.
+ String gpelURLString = System.getProperty("gpel.url");
+ if (gpelURLString != null) {
+ this.configuration.setGPELEngineURL(URI.create(gpelURLString));
+ }
+ String dscURLString = System.getProperty("dsc.url");
+ if (dscURLString != null) {
+ this.configuration.setDSCURL(URI.create(dscURLString));
+ }
+
+ String myProxyUsername = System.getProperty("myproxy.username");
+ if (myProxyUsername != null) {
+ this.configuration.setMyProxyUsername(myProxyUsername);
+ }
+ String myProxyPassphrase = System.getProperty("myproxy.passphrase");
+ if (myProxyPassphrase != null) {
+ this.configuration.setMyProxyPassphrase(myProxyPassphrase);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XppTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XppTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XppTestCase.java
new file mode 100644
index 0000000..38df89f
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/XppTestCase.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.v1.XmlSerializer;
+
+public class XppTestCase extends TestCase {
+
+ private static final Logger logger = LoggerFactory.getLogger(XppTestCase.class);
+
+ /*
+ * @see TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * @throws XmlPullParserException
+ * @throws IllegalArgumentException
+ * @throws IllegalStateException
+ * @throws IOException
+ */
+ public void testEscape() throws XmlPullParserException, IllegalArgumentException, IllegalStateException,
+ IOException {
+
+ String testString = "<tag><test/><[CDATA[<tag2/>]]></tag>";
+
+ logger.info("before:");
+ logger.info(testString);
+
+ XmlPullParserFactory xppFactory = XmlPullParserFactory.newInstance();
+ XmlSerializer xmlSerializer = xppFactory.newSerializer();
+ StringWriter stringwriter = new StringWriter();
+ xmlSerializer.setOutput(stringwriter);
+ xmlSerializer.text(testString);
+ String afterString = stringwriter.toString();
+
+ logger.info("after:");
+ logger.info(afterString);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonClassLoaderTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonClassLoaderTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonClassLoaderTestCase.java
new file mode 100644
index 0000000..d50c9dc
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonClassLoaderTestCase.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test.jython;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.xbaya.jython.runner.JythonClassLoader;
+import org.python.util.jython;
+
+public class JythonClassLoaderTestCase extends TestCase {
+
+ /**
+ * @throws ClassNotFoundException
+ */
+ public void testLoadClass() throws ClassNotFoundException {
+ JythonClassLoader loader = new JythonClassLoader(this.getClass().getClassLoader());
+
+ Class<?> newJythonClass = loader.loadClass(jython.class.getName(), true);
+ assertNotSame(jython.class, newJythonClass);
+
+ Class<?> newStringClass = loader.loadClass(String.class.getName(), true);
+ assertEquals(String.class, newStringClass);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonLibraryTest.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonLibraryTest.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonLibraryTest.java
new file mode 100644
index 0000000..773edfc
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonLibraryTest.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test.jython;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.invoker.GenericInvoker;
+import org.apache.airavata.xbaya.invoker.Invoker;
+import org.apache.airavata.xbaya.jython.lib.NotificationSender;
+import org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable;
+import org.apache.airavata.xbaya.test.service.adder.AdderService;
+import org.apache.airavata.xbaya.test.service.multiplier.MultiplierService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JythonLibraryTest extends TestCase {
+
+ private static final Logger logger = LoggerFactory.getLogger(JythonLibraryTest.class);
+
+ /**
+ * @throws WorkflowException
+ */
+ @SuppressWarnings("boxing")
+ public void testSimpleMath() throws WorkflowException {
+
+ AdderService service = new AdderService();
+ service.run();
+ String adderWSDLLoc = service.getServiceWsdlLocation();
+
+ WorkflowNotifiable notifier = new NotificationSender(XBayaConstants.DEFAULT_BROKER_URL.toString(), "test-topic");
+
+ Invoker invoker = new GenericInvoker(null, adderWSDLLoc, "adder", null, null, notifier);
+ invoker.setup();
+ invoker.setOperation("add");
+ invoker.setInput("x", 2);
+ invoker.setInput("y", 3);
+ invoker.invoke();
+
+ Object output = invoker.getOutput("z");
+ logger.info("z = " + output);
+
+ service.shutdownServer();
+ }
+
+ /**
+ * @throws WorkflowException
+ */
+ @SuppressWarnings("boxing")
+ public void testComplexMath() throws WorkflowException {
+
+ AdderService adder = new AdderService();
+ adder.run();
+ String adderWSDLLoc = adder.getServiceWsdlLocation();
+
+ MultiplierService multiplier = new MultiplierService();
+ multiplier.run();
+ String multiplierWSDLLoc = multiplier.getServiceWsdlLocation();
+
+ WorkflowNotifiable notifier = new NotificationSender(XBayaConstants.DEFAULT_BROKER_URL.toString(), "test-topic");
+
+ Invoker adderInvoker1 = new GenericInvoker(null, adderWSDLLoc, "adder", null, null, notifier);
+ adderInvoker1.setup();
+ adderInvoker1.setOperation("add");
+ adderInvoker1.setInput("x", 2);
+ adderInvoker1.setInput("y", 3);
+ adderInvoker1.invoke();
+
+ Object output1 = adderInvoker1.getOutput("z");
+ logger.info("output1 = " + output1);
+
+ Invoker adderInvoker2 = new GenericInvoker(null, adderWSDLLoc, "adder", null, null, notifier);
+ adderInvoker2.setup();
+ adderInvoker2.setOperation("add");
+ adderInvoker2.setInput("x", 4);
+ adderInvoker2.setInput("y", 5);
+ adderInvoker2.invoke();
+
+ Object output2 = adderInvoker2.getOutput("z");
+ logger.info("output2 = " + output2);
+
+ Invoker multiplierInvoker = new GenericInvoker(null, multiplierWSDLLoc, "multiplier", null, null, notifier);
+ multiplierInvoker.setup();
+ multiplierInvoker.setOperation("multiply");
+ multiplierInvoker.setInput("x", output1);
+ multiplierInvoker.setInput("y", output2);
+ multiplierInvoker.invoke();
+
+ Object output3 = multiplierInvoker.getOutput("z");
+ logger.info("output3 = " + output3);
+
+ adder.shutdownServer();
+ multiplier.shutdownServer();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonOneTimeRunnerTestCase.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonOneTimeRunnerTestCase.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonOneTimeRunnerTestCase.java
new file mode 100644
index 0000000..fa3f2e4
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/jython/JythonOneTimeRunnerTestCase.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.test.jython;
+
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.xbaya.jython.runner.JythonOneTimeRunnerImpl;
+import org.apache.airavata.xbaya.jython.script.JythonScript;
+import org.apache.airavata.xbaya.test.XBayaTestCase;
+import org.apache.airavata.xbaya.test.service.adder.AdderService;
+import org.apache.airavata.xbaya.test.service.multiplier.MultiplierService;
+import org.apache.airavata.xbaya.test.util.WorkflowCreator;
+
+public class JythonOneTimeRunnerTestCase extends XBayaTestCase {
+
+ /**
+ * @throws WorkflowException
+ */
+ public void testRun() throws WorkflowException {
+
+ WorkflowCreator creator = new WorkflowCreator();
+ Workflow workflow = creator.createComplexMathWorkflow();
+ JythonScript script = new JythonScript(workflow, this.configuration);
+ script.create();
+ String jythonString = script.getJythonString();
+
+ AdderService adder = new AdderService();
+ adder.run();
+ String adderWSDLLoc = adder.getServiceWsdlLocation();
+
+ MultiplierService multiplier = new MultiplierService();
+ multiplier.run();
+ String multiplierWSDLLoc = multiplier.getServiceWsdlLocation();
+
+ String[] arguments = new String[] { "-topic", "complex-math", "-Adder_wsdl", adderWSDLLoc, "-Adder_2_wsdl",
+ adderWSDLLoc, "-Multiplier_wsdl", multiplierWSDLLoc };
+
+ JythonOneTimeRunnerImpl runner = new JythonOneTimeRunnerImpl();
+ runner.run(jythonString, arguments);
+
+ try {
+ runner.run(jythonString, arguments);
+ fail();
+ } catch (Exception e) {
+ // It succeeds only once.
+ }
+
+ adder.shutdownServer();
+ multiplier.shutdownServer();
+ }
+}
\ No newline at end of file