1 package org
.argeo
.slc
.ant
.test
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.apache
.tools
.ant
.BuildException
;
7 import org
.argeo
.slc
.ant
.SlcAntConfig
;
8 import org
.argeo
.slc
.ant
.spring
.AbstractSpringArg
;
9 import org
.argeo
.slc
.ant
.structure
.SAwareTask
;
10 import org
.argeo
.slc
.core
.deploy
.DeployedSystem
;
11 import org
.argeo
.slc
.core
.structure
.StructureAware
;
12 import org
.argeo
.slc
.core
.test
.TestData
;
13 import org
.argeo
.slc
.core
.test
.TestDefinition
;
14 import org
.argeo
.slc
.core
.test
.TestResult
;
15 import org
.argeo
.slc
.core
.test
.WritableTestRun
;
17 /** Ant task wrapping a test run. */
18 public class SlcTestTask
extends SAwareTask
{
19 private Log log
= LogFactory
.getLog(SlcTestTask
.class);
21 private String testRunBean
= null;
23 private TestDefinitionArg testDefinitionArg
;
24 private TestDataArg testDataArg
;
25 private DeployedSystemArg deployedSystemArg
;
26 private TestResultArg testResultArg
;
29 public void executeActions(String mode
) throws BuildException
{
30 final String testRunBeanT
;
31 if (testRunBean
!= null) {
32 testRunBeanT
= testRunBean
;
34 testRunBeanT
= getProject().getUserProperty(
35 SlcAntConfig
.DEFAULT_TEST_RUN_PROPERTY
);
37 WritableTestRun testRun
= (WritableTestRun
) getContext().getBean(
40 // set overridden references
41 if (testDataArg
!= null) {
42 testRun
.setTestData(testDataArg
.getTestData());
43 log
.trace("Overrides test data");
46 if (testDefinitionArg
!= null) {
47 testRun
.setTestDefinition(testDefinitionArg
.getTestDefinition());
48 log
.trace("Overrides test definition");
51 if (deployedSystemArg
!= null) {
52 testRun
.setDeployedSystem(deployedSystemArg
.getDeployedSystem());
53 log
.trace("Overrides deployed system");
56 if (testResultArg
!= null) {
57 testRun
.setTestResult(testResultArg
.getTestResult());
58 log
.trace("Overrides test result");
61 // notify path to test result
62 TestResult result
= testRun
.getTestResult();
63 if (result
!= null && result
instanceof StructureAware
) {
64 ((StructureAware
) result
).notifyCurrentPath(getRegistry(),
72 * The bean name of the test run to use. If not set the default is used.
76 public void setTestRun(String testRunBean
) {
77 this.testRunBean
= testRunBean
;
80 public TestDefinitionArg
createTestDefinition() {
81 testDefinitionArg
= new TestDefinitionArg();
82 // only test definitions can add to path
83 addSAwareArg(testDefinitionArg
);
84 return testDefinitionArg
;
87 public TestDataArg
createTestData() {
88 testDataArg
= new TestDataArg();
92 public DeployedSystemArg
createDeployedSystem() {
93 deployedSystemArg
= new DeployedSystemArg();
94 return deployedSystemArg
;
97 public TestResultArg
createTestResult() {
98 testResultArg
= new TestResultArg();
104 class TestDefinitionArg
extends AbstractSpringArg
{
105 public TestDefinition
getTestDefinition() {
106 return (TestDefinition
) getBeanInstance();
110 class TestDataArg
extends AbstractSpringArg
{
111 public TestData
getTestData() {
112 return (TestData
) getBeanInstance();
117 class DeployedSystemArg
extends AbstractSpringArg
{
118 public DeployedSystem
getDeployedSystem() {
119 return (DeployedSystem
) getBeanInstance();
124 class TestResultArg
extends AbstractSpringArg
{
125 public TestResult
getTestResult() {
126 return (TestResult
) getBeanInstance();