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.SlcAntConstants;\r
+import org.argeo.slc.ant.spring.SpringArg;\r
import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.SlcException;\r
import org.argeo.slc.core.deploy.DeployedSystem;\r
import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionAware;\r
import org.argeo.slc.core.structure.StructureAware;\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.ExecutableTestRun;\r
import org.argeo.slc.core.test.TestResult;\r
import org.argeo.slc.core.test.WritableTestRun;\r
import org.argeo.slc.spring.SpringUtils;\r
+import org.springframework.beans.BeansException;\r
\r
/** Ant task wrapping a test run. */\r
public class SlcTestTask extends SAwareTask {\r
\r
private String testRunBean = null;\r
\r
- private TestDefinitionArg testDefinitionArg;\r
- private TestDataArg testDataArg;\r
- private DeployedSystemArg deployedSystemArg;\r
- private TestResultArg testResultArg;\r
+ private SpringArg<TestDefinition> testDefinitionArg;\r
+ private SpringArg<TestData> testDataArg;\r
+ private SpringArg<DeployedSystem> deployedSystemArg;\r
+ private SpringArg<TestResult> testResultArg;\r
\r
@Override\r
public void executeActions(String mode) throws BuildException {\r
if (testRunBean != null) {\r
testRunBeanT = testRunBean;\r
} else {\r
- testRunBeanT = getProject().getUserProperty(\r
- SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY);\r
+ testRunBeanT = getProject().getProperty(\r
+ SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY);\r
}\r
WritableTestRun testRun = null;\r
\r
if (testRunBeanT != null) {\r
- testRun = (WritableTestRun) getContext().getBean(testRunBeanT);\r
- if (log.isTraceEnabled())\r
- log.trace("Load test run bean from bean name " + testRunBeanT);\r
+ try {\r
+ testRun = (WritableTestRun) getContext().getBean(testRunBeanT);\r
+ if (log.isTraceEnabled())\r
+ log.trace("Load test run bean from bean name " + testRunBeanT);\r
+ } catch (BeansException e) {\r
+ // silent, will try defaults\r
+ }\r
}\r
\r
if (testRun == null) {\r
\r
// set overridden references\r
if (testDataArg != null) {\r
- testRun.setTestData(testDataArg.getTestData());\r
+ testRun.setTestData(testDataArg.getBeanInstance());\r
log.trace("Overrides test data");\r
}\r
\r
if (testDefinitionArg != null) {\r
- testRun.setTestDefinition(testDefinitionArg.getTestDefinition());\r
+ testRun.setTestDefinition(testDefinitionArg.getBeanInstance());\r
log.trace("Overrides test definition");\r
}\r
\r
if (deployedSystemArg != null) {\r
- testRun.setDeployedSystem(deployedSystemArg.getDeployedSystem());\r
+ testRun.setDeployedSystem(deployedSystemArg.getBeanInstance());\r
log.trace("Overrides deployed system");\r
}\r
\r
if (testResultArg != null) {\r
- testRun.setTestResult(testResultArg.getTestResult());\r
+ testRun.setTestResult(testResultArg.getBeanInstance());\r
log.trace("Overrides test result");\r
}\r
\r
}\r
\r
/** Creates sub tag. */\r
- public TestDefinitionArg createTestDefinition() {\r
- testDefinitionArg = new TestDefinitionArg();\r
+ public SpringArg<TestDefinition> createTestDefinition() {\r
+ testDefinitionArg = new SpringArg<TestDefinition>();\r
// only test definitions can add to path\r
addSAwareArg(testDefinitionArg);\r
return testDefinitionArg;\r
}\r
\r
/** Creates sub tag. */\r
- public TestDataArg createTestData() {\r
- testDataArg = new TestDataArg();\r
+ public SpringArg<TestData> createTestData() {\r
+ testDataArg = new SpringArg<TestData>();\r
return testDataArg;\r
}\r
\r
/** Creates sub tag. */\r
- public DeployedSystemArg createDeployedSystem() {\r
- deployedSystemArg = new DeployedSystemArg();\r
+ public SpringArg<DeployedSystem> createDeployedSystem() {\r
+ deployedSystemArg = new SpringArg<DeployedSystem>();\r
return deployedSystemArg;\r
}\r
\r
/** Creates sub tag. */\r
- public TestResultArg createTestResult() {\r
- testResultArg = new TestResultArg();\r
+ public SpringArg<TestResult> createTestResult() {\r
+ testResultArg = new SpringArg<TestResult>();\r
return testResultArg;\r
}\r
\r
return SpringUtils.loadSingleFromContext(getContext(), clss);\r
}\r
}\r
-\r
-class TestDefinitionArg extends AbstractSpringArg {\r
- TestDefinition getTestDefinition() {\r
- return (TestDefinition) getBeanInstance();\r
- }\r
-}\r
-\r
-class TestDataArg extends AbstractSpringArg {\r
- TestData getTestData() {\r
- return (TestData) getBeanInstance();\r
- }\r
-\r
-}\r
-\r
-class DeployedSystemArg extends AbstractSpringArg {\r
- DeployedSystem getDeployedSystem() {\r
- return (DeployedSystem) getBeanInstance();\r
- }\r
-\r
-}\r
-\r
-class TestResultArg extends AbstractSpringArg {\r
- TestResult getTestResult() {\r
- return (TestResult) getBeanInstance();\r
- }\r
-\r
-}\r