]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java
Improve launching of executions
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / test / SimpleTestRun.java
index bbe5b215cc332d5bfec88249552a4a56002738ac..bab085990ba9a22560a1f70c417cbc67e2436203 100644 (file)
@@ -2,20 +2,33 @@ package org.argeo.slc.core.test;
 \r
 import java.util.UUID;\r
 \r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
+import org.argeo.slc.core.structure.tree.TreeSPath;\r
+import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
+import org.argeo.slc.deploy.DeployedSystem;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.process.SlcExecutionRelated;\r
+import org.argeo.slc.process.SlcExecutionStep;\r
+import org.argeo.slc.structure.StructureAware;\r
+import org.argeo.slc.structure.StructureRegistry;\r
+import org.argeo.slc.test.ExecutableTestRun;\r
+import org.argeo.slc.test.TestData;\r
+import org.argeo.slc.test.TestDefinition;\r
+import org.argeo.slc.test.TestResult;\r
+import org.argeo.slc.test.WritableTestRun;\r
 \r
 /**\r
  * A basic bean implementation of a <code>WritableTestRun</code>, holding\r
  * references to the various parts of a test run.\r
  */\r
-public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {\r
+public class SimpleTestRun implements WritableTestRun, ExecutableTestRun,\r
+               SlcExecutionRelated {\r
        private String uuid;\r
 \r
        private String slcExecutionUuid;\r
        private String slcExecutionStepUuid;\r
 \r
+       private String path;\r
+\r
        private DeployedSystem deployedSystem;\r
        private TestData testData;\r
        private TestDefinition testDefinition;\r
@@ -23,9 +36,28 @@ public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {
 \r
        /** Executes the underlying test definition. */\r
        public void execute() {\r
+               TreeSPath basePath = null;\r
+               StructureRegistry<TreeSPath> registry = null;\r
+               if (path != null) {\r
+                       // TODO: generalize\r
+                       basePath = new TreeSPath(path);\r
+                       registry = new TreeSRegistry();\r
+               }\r
+\r
                uuid = UUID.randomUUID().toString();\r
                if (testResult != null)\r
                        testResult.notifyTestRun(this);\r
+\r
+               // Structure\r
+               if (testResult != null && basePath != null\r
+                               && testResult instanceof StructureAware)\r
+                       ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(\r
+                                       registry, basePath);\r
+\r
+               if (basePath != null && testDefinition instanceof StructureAware)\r
+                       ((StructureAware<TreeSPath>) testDefinition).notifyCurrentPath(\r
+                                       registry, basePath);\r
+\r
                testDefinition.execute(this);\r
        }\r
 \r
@@ -95,4 +127,8 @@ public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {
                }\r
        }\r
 \r
+       public void setPath(String path) {\r
+               this.path = path;\r
+       }\r
+\r
 }\r