X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.agent%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fant%2Ftest%2FSlcTestTask.java;h=651ccad7b959eefd4c79f6825b7454a214dc6fef;hb=a26a4e7277526fe17e13652362821ac2a1fc273a;hp=6f2411c0093ea9454a43caf95538dc8683e6fa8d;hpb=a7b136d40c14e4559faa5c34dc2b4dd2170ac2d4;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java index 6f2411c00..651ccad7b 100644 --- a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java +++ b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java @@ -3,14 +3,12 @@ package org.argeo.slc.ant.test; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.BuildException; - import org.argeo.slc.ant.SlcAntConfig; -import org.argeo.slc.ant.spring.AbstractSpringArg; +import org.argeo.slc.ant.SlcAntConstants; +import org.argeo.slc.ant.spring.SpringArg; import org.argeo.slc.ant.structure.SAwareTask; -import org.argeo.slc.core.SlcException; import org.argeo.slc.core.deploy.DeployedSystem; import org.argeo.slc.core.process.SlcExecution; -import org.argeo.slc.core.process.SlcExecutionAware; import org.argeo.slc.core.structure.StructureAware; import org.argeo.slc.core.structure.tree.TreeSPath; import org.argeo.slc.core.test.ExecutableTestRun; @@ -21,6 +19,7 @@ import org.argeo.slc.core.test.TestDefinition; import org.argeo.slc.core.test.TestResult; import org.argeo.slc.core.test.WritableTestRun; import org.argeo.slc.spring.SpringUtils; +import org.springframework.beans.BeansException; /** Ant task wrapping a test run. */ public class SlcTestTask extends SAwareTask { @@ -28,10 +27,10 @@ public class SlcTestTask extends SAwareTask { private String testRunBean = null; - private TestDefinitionArg testDefinitionArg; - private TestDataArg testDataArg; - private DeployedSystemArg deployedSystemArg; - private TestResultArg testResultArg; + private SpringArg testDefinitionArg; + private SpringArg testDataArg; + private SpringArg deployedSystemArg; + private SpringArg testResultArg; @Override public void executeActions(String mode) throws BuildException { @@ -40,15 +39,19 @@ public class SlcTestTask extends SAwareTask { if (testRunBean != null) { testRunBeanT = testRunBean; } else { - testRunBeanT = getProject().getUserProperty( - SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY); + testRunBeanT = getProject().getProperty( + SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY); } WritableTestRun testRun = null; if (testRunBeanT != null) { - testRun = (WritableTestRun) getContext().getBean(testRunBeanT); - if (log.isTraceEnabled()) - log.trace("Load test run bean from bean name " + testRunBeanT); + try { + testRun = (WritableTestRun) getContext().getBean(testRunBeanT); + if (log.isTraceEnabled()) + log.trace("Load test run bean from bean name " + testRunBeanT); + } catch (BeansException e) { + // silent, will try defaults + } } if (testRun == null) { @@ -64,22 +67,22 @@ public class SlcTestTask extends SAwareTask { // set overridden references if (testDataArg != null) { - testRun.setTestData(testDataArg.getTestData()); + testRun.setTestData(testDataArg.getBeanInstance()); log.trace("Overrides test data"); } if (testDefinitionArg != null) { - testRun.setTestDefinition(testDefinitionArg.getTestDefinition()); + testRun.setTestDefinition(testDefinitionArg.getBeanInstance()); log.trace("Overrides test definition"); } if (deployedSystemArg != null) { - testRun.setDeployedSystem(deployedSystemArg.getDeployedSystem()); + testRun.setDeployedSystem(deployedSystemArg.getBeanInstance()); log.trace("Overrides deployed system"); } if (testResultArg != null) { - testRun.setTestResult(testResultArg.getTestResult()); + testRun.setTestResult(testResultArg.getBeanInstance()); log.trace("Overrides test result"); } @@ -118,28 +121,28 @@ public class SlcTestTask extends SAwareTask { } /** Creates sub tag. */ - public TestDefinitionArg createTestDefinition() { - testDefinitionArg = new TestDefinitionArg(); + public SpringArg createTestDefinition() { + testDefinitionArg = new SpringArg(); // only test definitions can add to path addSAwareArg(testDefinitionArg); return testDefinitionArg; } /** Creates sub tag. */ - public TestDataArg createTestData() { - testDataArg = new TestDataArg(); + public SpringArg createTestData() { + testDataArg = new SpringArg(); return testDataArg; } /** Creates sub tag. */ - public DeployedSystemArg createDeployedSystem() { - deployedSystemArg = new DeployedSystemArg(); + public SpringArg createDeployedSystem() { + deployedSystemArg = new SpringArg(); return deployedSystemArg; } /** Creates sub tag. */ - public TestResultArg createTestResult() { - testResultArg = new TestResultArg(); + public SpringArg createTestResult() { + testResultArg = new SpringArg(); return testResultArg; } @@ -147,30 +150,3 @@ public class SlcTestTask extends SAwareTask { return SpringUtils.loadSingleFromContext(getContext(), clss); } } - -class TestDefinitionArg extends AbstractSpringArg { - TestDefinition getTestDefinition() { - return (TestDefinition) getBeanInstance(); - } -} - -class TestDataArg extends AbstractSpringArg { - TestData getTestData() { - return (TestData) getBeanInstance(); - } - -} - -class DeployedSystemArg extends AbstractSpringArg { - DeployedSystem getDeployedSystem() { - return (DeployedSystem) getBeanInstance(); - } - -} - -class TestResultArg extends AbstractSpringArg { - TestResult getTestResult() { - return (TestResult) getBeanInstance(); - } - -}