1 package org
.argeo
.slc
.core
.execution
;
3 import java
.util
.HashMap
;
6 import org
.argeo
.slc
.execution
.ExecutionContext
;
7 import org
.argeo
.slc
.execution
.ExecutionFlow
;
8 import org
.argeo
.slc
.runtime
.test
.SimpleTestResult
;
9 import org
.argeo
.slc
.test
.TestStatus
;
10 import org
.springframework
.beans
.factory
.BeanCreationException
;
11 import org
.springframework
.context
.ConfigurableApplicationContext
;
13 public class BasicExecutionFlowTest
extends AbstractExecutionFlowTestCase
{
15 // - post-processing for @{} replacement in beans with complex properties
16 // - bean of scope other than execution are not resolved at execution
18 // public void testMyTest() throws Exception {
19 // ConfigurableApplicationContext applicationContext =
20 // createApplicationContext("test.xml");
21 // log.info("Start Execution");
22 // ((ExecutionFlow) applicationContext.getBean("flow1")).execute();
23 // applicationContext.close();
26 public void XXXtestSpecOverriding() throws Exception
{
27 ConfigurableApplicationContext applicationContext
= createApplicationContext("specOverriding.xml");
28 ((ExecutionFlow
) applicationContext
.getBean("flow2")).run();
29 SimpleTestResult res
= (SimpleTestResult
) applicationContext
30 .getBean("myTestResult");
31 validateTestResult(res
);
34 public void testMultipleFlows() throws Exception
{
35 ConfigurableApplicationContext applicationContext
= createApplicationContext("multipleFlow.xml");
36 ((ExecutionFlow
) applicationContext
.getBean("flow1")).run();
37 SimpleTestResult res
= (SimpleTestResult
) applicationContext
38 .getBean("myTestResult");
39 validateTestResult(res
);
40 res
.getParts().clear();
41 ((ExecutionFlow
) applicationContext
.getBean("flow2")).run();
42 validateTestResult(res
, TestStatus
.FAILED
);
43 applicationContext
.close();
47 * Test placeholder resolution in a context without scope execution or proxy
48 * and with cascading flows (the flow A contains the flow B)
52 public void testPlaceHolders() throws Exception
{
53 ConfigurableApplicationContext applicationContext
= createApplicationContext("placeHolders.cascading.xml");
54 ((ExecutionFlow
) applicationContext
.getBean("flowA")).run();
55 validateTestResult((SimpleTestResult
) applicationContext
56 .getBean("myTestResult"));
57 applicationContext
.close();
61 * Test placeholder resolution in a context without scope execution or proxy
62 * and with cascading flows (the flow A contains the flow B) setting
63 * execution values (should have no effect)
67 public void testPlaceHoldersWithExecutionValues() throws Exception
{
68 ConfigurableApplicationContext applicationContext
= createApplicationContext("placeHolders.cascading.xml");
70 ExecutionContext executionContext
= (ExecutionContext
) applicationContext
71 .getBean("executionContext");
72 Map
<String
, String
> executionParameters
= new HashMap
<String
, String
>();
73 executionParameters
.put("p1", "e1");
74 executionParameters
.put("p2", "e2");
75 executionParameters
.put("p3", "e3");
76 executionParameters
.put("p4", "e4");
77 executionParameters
.put("p5", "e5");
78 executionParameters
.put("p6", "e6");
79 executionParameters
.put("p7", "e7");
80 executionParameters
.put("p8", "e8");
81 addVariables(executionContext
, executionParameters
);
83 ((ExecutionFlow
) applicationContext
.getBean("flowA")).run();
84 validateTestResult((SimpleTestResult
) applicationContext
85 .getBean("myTestResult"));
86 applicationContext
.close();
89 public void XXXtestPlaceHoldersExec() throws Exception
{
90 ConfigurableApplicationContext applicationContext
= createApplicationContext("placeHolders.cascading.exec.xml");
92 ExecutionContext executionContext
= (ExecutionContext
) applicationContext
93 .getBean("executionContext");
94 Map
<String
, String
> executionParameters
= new HashMap
<String
, String
>();
95 executionParameters
.put("p1", "e1");
96 executionParameters
.put("p2", "e2");
97 executionParameters
.put("p3", "e3");
98 executionParameters
.put("p4", "e4");
99 executionParameters
.put("p5", "e5");
100 executionParameters
.put("p6", "e6");
101 addVariables(executionContext
, executionParameters
);
103 ((ExecutionFlow
) applicationContext
.getBean("flowA")).run();
104 validateTestResult((SimpleTestResult
) applicationContext
105 .getBean("myTestResult"));
106 applicationContext
.close();
109 public void testCanonicFlowParameters() throws Exception
{
110 configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
113 public void testCanonicDefaultValues() throws Exception
{
114 configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
117 public void testCanonicMissingValues() throws Exception
{
119 configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");
120 fail("Parameter not set - should be rejected.");
121 } catch (BeanCreationException e
) {
122 // exception expected
127 public void testCanonicUnknownParameter() throws Exception
{
129 configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
130 fail("Unknown parameter set - should be rejected.");
131 } catch (BeanCreationException e
) {
132 // exception expected
137 public void testListSetMap() throws Exception
{
138 ConfigurableApplicationContext applicationContext
= createApplicationContext("listSetMap.xml");
139 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
143 validateTestResult((SimpleTestResult
) applicationContext
144 .getBean("myTestResult"));
146 // BasicTestData res = (BasicTestData)
147 // applicationContext.getBean("cascadingComplex.testData");
148 // log.info("res=" + res.getReached().toString());
150 applicationContext
.close();
153 public void testListSetMapMultipleFlows() throws Exception
{
154 ConfigurableApplicationContext applicationContext
= createApplicationContext("listSetMapMultipleFlow.xml");
155 ((ExecutionFlow
) applicationContext
.getBean("flow1")).run();
156 SimpleTestResult res
= (SimpleTestResult
) applicationContext
157 .getBean("myTestResult");
158 validateTestResult(res
);
159 res
.getParts().clear();
160 ((ExecutionFlow
) applicationContext
.getBean("flow2")).run();
161 validateTestResult(res
, TestStatus
.FAILED
);
162 applicationContext
.close();
165 protected void addVariables(ExecutionContext executionContext
,
166 Map
<String
, String
> vars
) {
167 for (String key
: vars
.keySet())
168 executionContext
.setVariable(key
, vars
.get(key
));