You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/03/26 18:08:06 UTC
[07/50] [abbrv] airavata git commit: Make test machine independent
Make test machine independent
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0bc98a30
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0bc98a30
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0bc98a30
Branch: refs/heads/master
Commit: 0bc98a30df024ac3ff3f194c3079503779d32fc5
Parents: 308291f
Author: shamrath <sh...@gmail.com>
Authored: Wed Feb 18 08:36:07 2015 -0500
Committer: shamrath <sh...@gmail.com>
Committed: Wed Feb 18 08:36:07 2015 -0500
----------------------------------------------------------------------
modules/simple-workflow/pom.xml | 8 +++++++
.../workflow/engine/WorkflowFactoryImpl.java | 7 +++++-
.../engine/parser/AiravataDefaultParser.java | 23 +++++++++++---------
.../parser/AiravataDefaultParserTest.java | 18 +++++++--------
4 files changed, 35 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/0bc98a30/modules/simple-workflow/pom.xml
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/pom.xml b/modules/simple-workflow/pom.xml
index 623934d..6b36335 100644
--- a/modules/simple-workflow/pom.xml
+++ b/modules/simple-workflow/pom.xml
@@ -52,6 +52,14 @@
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
+
+ <!--test-->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/0bc98a30/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java
index f489a12..a6173ac 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java
@@ -21,6 +21,7 @@
package org.apache.ariavata.simple.workflow.engine;
+import org.apache.airavata.registry.cpi.RegistryException;
import org.apache.ariavata.simple.workflow.engine.parser.AiravataDefaultParser;
/**
@@ -51,7 +52,11 @@ public class WorkflowFactoryImpl implements WorkflowFactory {
@Override
public WorkflowParser getWorkflowParser(String experimentId, String credentialToken) {
if (workflowParser == null) {
- workflowParser = new AiravataDefaultParser(experimentId, credentialToken);
+ try {
+ workflowParser = new AiravataDefaultParser(experimentId, credentialToken);
+ } catch (RegistryException e) {
+ // TODO : handle this scenario
+ }
}
return workflowParser;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/0bc98a30/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
index b86e58b..39e422a 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
@@ -66,28 +66,28 @@ import java.util.Map;
public class AiravataDefaultParser implements WorkflowParser {
- private String experimentId;
private String credentialToken ;
private Workflow workflow;
- // TODO : remove this setter method
- public void setExperiment(Experiment experiment) {
- this.experiment = experiment;
- }
private Experiment experiment;
private Map<String, WorkflowNode> wfNodes = new HashMap<String, WorkflowNode>();
- public AiravataDefaultParser(String experimentId, String credentialToken) {
- this.experimentId = experimentId;
+ public AiravataDefaultParser(String experimentId, String credentialToken) throws RegistryException {
+ this.experiment = getExperiment(experimentId);
+ this.credentialToken = credentialToken;
+ }
+
+ public AiravataDefaultParser(Experiment experiment, String credentialToken) {
this.credentialToken = credentialToken;
+ this.experiment = experiment;
}
@Override
public List<WorkflowInputNode> parse() throws RegistryException, AppCatalogException,
ComponentException, GraphException {
- return parseWorkflow(getWorkflowFromExperiment());
+ return parseWorkflow(getWorkflowFromExperiment(experiment));
}
public List<WorkflowInputNode> parseWorkflow(Workflow workflow) {
@@ -216,9 +216,12 @@ public class AiravataDefaultParser implements WorkflowParser {
return outputDataObjectType;
}
- private Workflow getWorkflowFromExperiment() throws RegistryException, AppCatalogException, GraphException, ComponentException {
+ private Experiment getExperiment(String experimentId) throws RegistryException {
Registry registry = RegistryFactory.getDefaultRegistry();
- experiment = (Experiment)registry.get(RegistryModelType.EXPERIMENT, experimentId);
+ return (Experiment)registry.get(RegistryModelType.EXPERIMENT, experimentId);
+ }
+
+ private Workflow getWorkflowFromExperiment(Experiment experiment) throws RegistryException, AppCatalogException, GraphException, ComponentException {
WorkflowCatalog workflowCatalog = getWorkflowCatalog();
return new Workflow(workflowCatalog.getWorkflow(experiment.getApplicationId()).getGraph());
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/0bc98a30/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
index 15b2864..432a1c6 100644
--- a/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
+++ b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
@@ -21,7 +21,6 @@
package org.apache.ariavata.simple.workflow.engine.parser;
-import junit.framework.Assert;
import org.apache.airavata.model.appcatalog.appinterface.DataType;
import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
import org.apache.airavata.model.workspace.experiment.Experiment;
@@ -31,12 +30,12 @@ import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode;
import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode;
import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowOutputNode;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -55,18 +54,16 @@ public class AiravataDefaultParserTest {
@Test
public void testWorkflowParse() throws Exception {
-// File jsonWfFile = new File("modules/simple-workflow/src/test/resources/ComplexMathWorkflow.awf");
- File jsonWfFile = new File("/Users/shameera/work/source/git_airavata/modules/simple-workflow/src/test/resources/ComplexMathWorkflow.awf");
- BufferedReader br = new BufferedReader(new FileReader(jsonWfFile));
+ Assert.assertNotNull("Test file (ComplexMathWorkflow.awf) is missing", getClass().getResource("/ComplexMathWorkflow.awf"));
+ InputStreamReader isr = new InputStreamReader(this.getClass().getResourceAsStream("/ComplexMathWorkflow.awf"));
+ BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer();
String nextLine = br.readLine();
while (nextLine != null) {
sb.append(nextLine);
nextLine = br.readLine();
}
-
Workflow workflow = new Workflow(sb.toString());
- AiravataDefaultParser parser = new AiravataDefaultParser("testExperimentId", "testCredentialId");
Experiment experiment = new Experiment();
InputDataObjectType x = new InputDataObjectType();
x.setValue("6");
@@ -88,7 +85,8 @@ public class AiravataDefaultParserTest {
inputs.add(y);
inputs.add(z);
experiment.setExperimentInputs(inputs);
- parser.setExperiment(experiment);
+ // create parser
+ AiravataDefaultParser parser = new AiravataDefaultParser(experiment, "testCredentialId");
List<WorkflowInputNode> workflowInputNodes = parser.parseWorkflow(workflow);
Assert.assertNotNull(workflowInputNodes);
Assert.assertEquals(3, workflowInputNodes.size());
@@ -111,7 +109,7 @@ public class AiravataDefaultParserTest {
Assert.assertEquals(1, node.getOutputPorts().size());
Assert.assertEquals(1, node.getOutputPorts().get(0).getOutEdges().size());
Assert.assertNotNull(node.getOutputPorts().get(0).getOutEdges().get(0));
- }else if (wfNode instanceof WorkflowOutputNode) {
+ } else if (wfNode instanceof WorkflowOutputNode) {
WorkflowOutputNode workflowOutputNode = (WorkflowOutputNode) wfNode;
Assert.assertNotNull(workflowOutputNode.getInPort());
}