package org.argeo.slc.ant.test;\r
\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\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.WritableTestRun;\r
\r
/** Ant task wrapping a test run. */\r
public class SlcTestTask extends SAwareTask {\r
+ private Log log = LogFactory.getLog(SlcTestTask.class);\r
+\r
+ private String testRunBean = null;\r
\r
private TestDefinitionArg testDefinitionArg;\r
private TestDataArg testDataArg;\r
+ private DeployedSystemArg deployedSystemArg;\r
+ private TestResultArg testResultArg;\r
\r
@Override\r
public void executeActions(String mode) throws BuildException {\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
+ final String testRunBeanT;\r
+ if (testRunBean != null) {\r
+ testRunBeanT = testRunBean;\r
+ } else {\r
+ testRunBeanT = getProject().getUserProperty(\r
+ SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY);\r
+ }\r
+ WritableTestRun testRun = (WritableTestRun) getContext().getBean(\r
+ testRunBeanT);\r
+\r
+ // set overridden references\r
+ if (testDataArg != null) {\r
+ testRun.setTestData(testDataArg.getTestData());\r
+ log.trace("Overrides test data");\r
+ }\r
+\r
+ if (testDefinitionArg != null) {\r
+ testRun.setTestDefinition(testDefinitionArg.getTestDefinition());\r
+ log.trace("Overrides test definition");\r
+ }\r
+\r
+ if (deployedSystemArg != null) {\r
+ testRun.setDeployedSystem(deployedSystemArg.getDeployedSystem());\r
+ log.trace("Overrides deployed system");\r
}\r
- \r
- simpleTestRun.execute();\r
+\r
+ if (testResultArg != null) {\r
+ testRun.setTestResult(testResultArg.getTestResult());\r
+ log.trace("Overrides test result");\r
+ }\r
+\r
+ // notify path to test result\r
+ TestResult result = testRun.getTestResult();\r
+ if (result != null && result instanceof StructureAware) {\r
+ ((StructureAware) result).notifyCurrentPath(getRegistry(),\r
+ getPath());\r
+ }\r
+\r
+ testRun.execute();\r
+ }\r
+\r
+ /**\r
+ * The bean name of the test run to use. If not set the default is used.\r
+ * \r
+ * @see SlcAntConfig\r
+ */\r
+ public void setTestRun(String testRunBean) {\r
+ this.testRunBean = testRunBean;\r
}\r
\r
public TestDefinitionArg createTestDefinition() {\r
testDefinitionArg = new TestDefinitionArg();\r
+ // only test definitions can add to path\r
addSAwareArg(testDefinitionArg);\r
return testDefinitionArg;\r
}\r
\r
public TestDataArg createTestData() {\r
testDataArg = new TestDataArg();\r
- addSAwareArg(testDataArg);\r
return testDataArg;\r
}\r
\r
+ public DeployedSystemArg createDeployedSystem() {\r
+ deployedSystemArg = new DeployedSystemArg();\r
+ return deployedSystemArg;\r
+ }\r
+\r
+ public TestResultArg createTestResult() {\r
+ testResultArg = new TestResultArg();\r
+ return testResultArg;\r
+ }\r
+\r
}\r
\r
class TestDefinitionArg extends AbstractSpringArg {\r
}\r
\r
}\r
+\r
+class DeployedSystemArg extends AbstractSpringArg {\r
+ public DeployedSystem getDeployedSystem() {\r
+ return (DeployedSystem) getBeanInstance();\r
+ }\r
+\r
+}\r
+\r
+class TestResultArg extends AbstractSpringArg {\r
+ public TestResult getTestResult() {\r
+ return (TestResult) getBeanInstance();\r
+ }\r
+\r
+}\r