]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/execution/BasicExecutionFlowTest.java
Restructure modules
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / test / java / org / argeo / slc / core / execution / BasicExecutionFlowTest.java
diff --git a/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/execution/BasicExecutionFlowTest.java b/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/execution/BasicExecutionFlowTest.java
new file mode 100644 (file)
index 0000000..ae0a1fd
--- /dev/null
@@ -0,0 +1,164 @@
+package org.argeo.slc.core.execution;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.argeo.slc.core.test.SimpleTestResult;\r
+import org.argeo.slc.execution.ExecutionContext;\r
+import org.argeo.slc.execution.ExecutionFlow;\r
+import org.argeo.slc.test.TestStatus;\r
+import org.springframework.beans.factory.BeanCreationException;\r
+import org.springframework.context.ConfigurableApplicationContext;\r
+\r
+public class BasicExecutionFlowTest extends AbstractExecutionFlowTestCase {\r
+       // TO TEST\r
+       // - post-processing for @{} replacement in beans with complex properties\r
+       // - bean of scope other than execution are not resolved at execution\r
+\r
+       // public void testMyTest() throws Exception {\r
+       // ConfigurableApplicationContext applicationContext =\r
+       // createApplicationContext("test.xml");\r
+       // log.info("Start Execution");\r
+       // ((ExecutionFlow) applicationContext.getBean("flow1")).execute();\r
+       // applicationContext.close();\r
+       // }\r
+\r
+       public void testSpecOverriding() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("specOverriding.xml");\r
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();\r
+               SimpleTestResult res = (SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult");\r
+               validateTestResult(res);\r
+       }\r
+\r
+       public void testMultipleFlows() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("multipleFlow.xml");\r
+               ((ExecutionFlow) applicationContext.getBean("flow1")).run();\r
+               SimpleTestResult res = (SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult");\r
+               validateTestResult(res);\r
+               res.getParts().clear();\r
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();\r
+               validateTestResult(res, TestStatus.FAILED);\r
+               applicationContext.close();\r
+       }\r
+\r
+       /**\r
+        * Test placeholder resolution in a context without scope execution or proxy\r
+        * and with cascading flows (the flow A contains the flow B)\r
+        * \r
+        * @throws Exception\r
+        */\r
+       public void testPlaceHolders() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");\r
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();\r
+               validateTestResult((SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult"));\r
+               applicationContext.close();\r
+       }\r
+\r
+       /**\r
+        * Test placeholder resolution in a context without scope execution or proxy\r
+        * and with cascading flows (the flow A contains the flow B) setting\r
+        * execution values (should have no effect)\r
+        * \r
+        * @throws Exception\r
+        */\r
+       public void testPlaceHoldersWithExecutionValues() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");\r
+\r
+               ExecutionContext executionContext = (ExecutionContext) applicationContext\r
+                               .getBean("executionContext");\r
+               Map<String, String> executionParameters = new HashMap<String, String>();\r
+               executionParameters.put("p1", "e1");\r
+               executionParameters.put("p2", "e2");\r
+               executionParameters.put("p3", "e3");\r
+               executionParameters.put("p4", "e4");\r
+               executionParameters.put("p5", "e5");\r
+               executionParameters.put("p6", "e6");\r
+               executionParameters.put("p7", "e7");\r
+               executionParameters.put("p8", "e8");\r
+               executionContext.addVariables(executionParameters);\r
+\r
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();\r
+               validateTestResult((SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult"));\r
+               applicationContext.close();\r
+       }\r
+\r
+       public void testPlaceHoldersExec() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.exec.xml");\r
+\r
+               ExecutionContext executionContext = (ExecutionContext) applicationContext\r
+                               .getBean("executionContext");\r
+               Map<String, String> executionParameters = new HashMap<String, String>();\r
+               executionParameters.put("p1", "e1");\r
+               executionParameters.put("p2", "e2");\r
+               executionParameters.put("p3", "e3");\r
+               executionParameters.put("p4", "e4");\r
+               executionParameters.put("p5", "e5");\r
+               executionParameters.put("p6", "e6");\r
+               executionContext.addVariables(executionParameters);\r
+\r
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();\r
+               validateTestResult((SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult"));\r
+               applicationContext.close();\r
+       }\r
+\r
+       public void testCanonicFlowParameters() throws Exception {\r
+               configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");\r
+       }\r
+\r
+       public void testCanonicDefaultValues() throws Exception {\r
+               configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");\r
+       }\r
+\r
+       public void testCanonicMissingValues() throws Exception {\r
+               try {\r
+                       configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");\r
+                       fail("Parameter not set - should be rejected.");\r
+               } catch (BeanCreationException e) {\r
+                       // exception expected\r
+                       logException(e);\r
+               }\r
+       }\r
+\r
+       public void testCanonicUnknownParameter() throws Exception {\r
+               try {\r
+                       configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");\r
+                       fail("Unknown parameter set - should be rejected.");\r
+               } catch (BeanCreationException e) {\r
+                       // exception expected\r
+                       logException(e);\r
+               }\r
+       }\r
+\r
+       public void testListSetMap() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMap.xml");\r
+               ExecutionFlow executionFlow = (ExecutionFlow) applicationContext\r
+                               .getBean("myFlow");\r
+               executionFlow.run();\r
+\r
+               validateTestResult((SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult"));\r
+\r
+               // BasicTestData res = (BasicTestData)\r
+               // applicationContext.getBean("cascadingComplex.testData");\r
+               // log.info("res=" + res.getReached().toString());\r
+\r
+               applicationContext.close();\r
+       }\r
+\r
+       public void testListSetMapMultipleFlows() throws Exception {\r
+               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMapMultipleFlow.xml");\r
+               ((ExecutionFlow) applicationContext.getBean("flow1")).run();\r
+               SimpleTestResult res = (SimpleTestResult) applicationContext\r
+                               .getBean("myTestResult");\r
+               validateTestResult(res);\r
+               res.getParts().clear();\r
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();\r
+               validateTestResult(res, TestStatus.FAILED);\r
+               applicationContext.close();\r
+       }\r
+}\r