1
2
3
4
5
6
7
8 package net.kwfgrid.gwes;
9
10 import junit.framework.Test;
11 import junit.framework.TestSuite;
12 import junit.framework.Assert;
13 import net.kwfgrid.gwes.exception.LoggingException;
14 import net.kwfgrid.gwes.workflowgenerator.WorkflowGenerator;
15 import net.kwfgrid.gwes.workflowgenerator.SingleJob;
16 import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
17 import net.kwfgrid.gworkflowdl.structure.CapacityException;
18 import org.apache.log4j.Logger;
19
20 import java.io.IOException;
21 import java.util.*;
22
23
24
25
26
27
28
29
30
31
32 public final class WorkflowGeneratorTest extends LocalGWESAbstractTestCase {
33
34 static Logger logger = Logger.getLogger(WorkflowGeneratorTest.class);
35
36
37
38
39
40
41 public WorkflowGeneratorTest(String testName) throws LoggingException {
42 super(testName);
43 }
44
45
46
47
48 public static Test suite() {
49 return new TestSuite(WorkflowGeneratorTest.class);
50 }
51
52
53
54
55
56
57
58
59
60
61 public void testSingleJobWithoutInputs() throws WorkflowFormatException, CapacityException, IOException {
62
63 WorkflowGenerator generator = new SingleJob("date","wsgram", "/bin/date@software:date", "https://countess.first.fhrg.fraunhofer.de:8443/wsrf/services/ManagedJobFactoryService@hardware:countess.first.fhrg.fraunhofer.de",null,null);
64 String workflowXml = generator.getXML();
65 logger.info(workflowXml);
66 Assert.assertEquals("<description>Single job invoking 'date'</description>\r\n" +
67 " <place ID=\"start\">\r\n" +
68 " <token ID=\"cX\">\r\n" +
69 " <control>true</control>\r\n" +
70 " </token>\r\n" +
71 " </place>\r\n" +
72 " <place ID=\"end\" />\r\n" +
73 " <transition ID=\"date\">\r\n" +
74 " <inputPlace placeID=\"start\" />\r\n" +
75 " <outputPlace placeID=\"end\" />\r\n" +
76 " <operation>\r\n" +
77 " <oc:operationClass name=\"date\">\r\n" +
78 " <oc:operationCandidate type=\"wsgram\" operationName=\"/bin/date@software:date\" resourceName=\"https://countess.first.fhrg.fraunhofer.de:8443/wsrf/services/ManagedJobFactoryService@hardware:countess.first.fhrg.fraunhofer.de\" quality=\"0.0\" selected=\"true\" />\r\n" +
79 " </oc:operationClass>\r\n" +
80 " </operation>\r\n" +
81 " </transition>\r\n" +
82 "</workflow>\r\n\r\n",stripTokenIDs(workflowXml.substring(workflowXml.indexOf("<description>"))));
83 }
84
85
86
87
88
89
90
91 public void testSingleJobWithInputs() throws WorkflowFormatException, CapacityException, IOException {
92 Map<String,String> inputs = new LinkedHashMap<String,String>();
93 inputs.put("input1","value1");
94 inputs.put("input2","value2");
95 inputs.put("input3","value3");
96 List<String> outputs = new ArrayList<String>();
97 outputs.add("output1");
98 WorkflowGenerator generator = new SingleJob("oclass1", "type1", "operation1", "resource1",inputs,outputs);
99 String workflowXml = generator.getXML();
100 logger.info(workflowXml);
101
102 Assert.assertEquals("<description>Single job invoking 'oclass1'</description>\r\n" +
103 " <place ID=\"input1\">\r\n" +
104 " <token ID=\"dX\">\r\n" +
105 " <data>\r\n" +
106 " <input1 xmlns=\"\">value1</input1>\r\n" +
107 " </data>\r\n" +
108 " </token>\r\n" +
109 " </place>\r\n" +
110 " <place ID=\"input2\">\r\n" +
111 " <token ID=\"dX\">\r\n" +
112 " <data>\r\n" +
113 " <input2 xmlns=\"\">value2</input2>\r\n" +
114 " </data>\r\n" +
115 " </token>\r\n" +
116 " </place>\r\n" +
117 " <place ID=\"input3\">\r\n" +
118 " <token ID=\"dX\">\r\n" +
119 " <data>\r\n" +
120 " <input3 xmlns=\"\">value3</input3>\r\n" +
121 " </data>\r\n" +
122 " </token>\r\n" +
123 " </place>\r\n" +
124 " <place ID=\"output1\" />\r\n" +
125 " <transition ID=\"oclass1\">\r\n" +
126 " <inputPlace placeID=\"input1\" edgeExpression=\"input1\" />\r\n" +
127 " <inputPlace placeID=\"input2\" edgeExpression=\"input2\" />\r\n" +
128 " <inputPlace placeID=\"input3\" edgeExpression=\"input3\" />\r\n" +
129 " <outputPlace placeID=\"output1\" edgeExpression=\"output1\" />\r\n" +
130 " <operation>\r\n" +
131 " <oc:operationClass name=\"oclass1\">\r\n" +
132 " <oc:operationCandidate type=\"type1\" operationName=\"operation1\" resourceName=\"resource1\" quality=\"0.0\" selected=\"true\" />\r\n" +
133 " </oc:operationClass>\r\n" +
134 " </operation>\r\n" +
135 " </transition>\r\n" +
136 "</workflow>\r\n\r\n",stripTokenIDs(workflowXml.substring(workflowXml.indexOf("<description>"))));
137 }
138
139
140
141
142
143
144
145
146 }