]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java
Introduce end to end testing with logging of results
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / ant / test / SlcTestTask.java
index 69d08eee50727654ba534005592fe964effcff1b..299db2378859a0cf2c45dbc67e036858e8163dae 100644 (file)
@@ -2,24 +2,39 @@ package org.argeo.slc.ant.test;
 \r
 import org.apache.tools.ant.BuildException;\r
 \r
+import org.argeo.slc.ant.SlcAntConfig;\r
 import org.argeo.slc.ant.spring.AbstractSpringArg;\r
 import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
+import org.argeo.slc.core.structure.StructureAware;\r
+import org.argeo.slc.core.test.SimpleTestRun;\r
 import org.argeo.slc.core.test.TestData;\r
 import org.argeo.slc.core.test.TestDefinition;\r
 import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestRun;\r
 \r
 /** Ant task wrapping a test run. */\r
-public class SlcTestTask extends SAwareTask implements TestRun {\r
+public class SlcTestTask extends SAwareTask {\r
 \r
        private TestDefinitionArg testDefinitionArg;\r
        private TestDataArg testDataArg;\r
 \r
        @Override\r
        public void executeActions(String mode) throws BuildException {\r
-               TestDefinition testDefinition = testDefinitionArg.getTestDefinition();\r
-               testDefinition.execute(this);\r
+               SimpleTestRun simpleTestRun = (SimpleTestRun) getContext().getBean(\r
+                               getProject().getUserProperty(\r
+                                               SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY));\r
+               \r
+               if (testDataArg != null)\r
+                       simpleTestRun.setTestData(testDataArg.getTestData());\r
+               if (testDefinitionArg != null)\r
+                       simpleTestRun.setTestDefinition(testDefinitionArg\r
+                                       .getTestDefinition());\r
+\r
+               TestResult result = simpleTestRun.getTestResult();\r
+               if(result!=null && result instanceof StructureAware){\r
+                       ((StructureAware)result).notifyCurrentPath(getRegistry(), getPath());\r
+               }\r
+               \r
+               simpleTestRun.execute();\r
        }\r
 \r
        public TestDefinitionArg createTestDefinition() {\r
@@ -34,22 +49,6 @@ public class SlcTestTask extends SAwareTask implements TestRun {
                return testDataArg;\r
        }\r
 \r
-       public DeployedSystem getDeployedSystem() {\r
-               throw new RuntimeException("Not yet implemented.");\r
-       }\r
-\r
-       public TestDefinition getTestDefinition() {\r
-               return testDefinitionArg.getTestDefinition();\r
-       }\r
-\r
-       public TestData getTestData() {\r
-               return testDataArg.getTestData();\r
-       }\r
-\r
-       public TestResult getTestResult() {\r
-               throw new RuntimeException("Not yet implemented.");\r
-       }\r
-\r
 }\r
 \r
 class TestDefinitionArg extends AbstractSpringArg {\r