]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/test/SlcTestTask.java
Remove moved projects
[gpl/argeo-slc.git] / org.argeo.slc.agent / src / main / java / org / argeo / slc / ant / test / SlcTestTask.java
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
deleted file mode 100644 (file)
index 66444f1..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-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
-import org.argeo.slc.ant.AntConstants;\r
-import org.argeo.slc.ant.spring.SpringArg;\r
-import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\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.SimpleResultPart;\r
-import org.argeo.slc.core.test.SimpleTestResult;\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.TestResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\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
-       private Log log = LogFactory.getLog(SlcTestTask.class);\r
-\r
-       private String testRunBean = null;\r
-\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
-               // find test run\r
-               final String testRunBeanT;\r
-               if (testRunBean != null) {\r
-                       testRunBeanT = testRunBean;\r
-               } else {\r
-                       testRunBeanT = getProject().getProperty(\r
-                                       AntConstants.DEFAULT_TEST_RUN_PROPERTY);\r
-               }\r
-               WritableTestRun testRun = null;\r
-\r
-               if (testRunBeanT != null) {\r
-                       try {\r
-                               testRun = (WritableTestRun) getContext().getBean(testRunBeanT);\r
-                               if (log.isTraceEnabled())\r
-                                       log.trace("Load test run bean from bean name "\r
-                                                       + testRunBeanT);\r
-                       } catch (BeansException e) {\r
-                               // silent, will try defaults\r
-                       }\r
-               }\r
-\r
-               if (testRun == null) {\r
-                       testRun = loadSingleFromContext(WritableTestRun.class);\r
-                       if (testRun == null) {\r
-                               testRun = new SimpleTestRun();\r
-                               log.trace("Created default simple test run");\r
-                       } else {\r
-                               if (log.isTraceEnabled())\r
-                                       log.trace("Load test run from scanning Spring context");\r
-                       }\r
-               }\r
-\r
-               // set overridden references\r
-               if (testDataArg != null) {\r
-                       testRun.setTestData(testDataArg.getInstance());\r
-                       log.trace("Overrides test data");\r
-               }\r
-\r
-               if (testDefinitionArg != null) {\r
-                       testRun.setTestDefinition(testDefinitionArg.getInstance());\r
-                       log.trace("Overrides test definition");\r
-               }\r
-\r
-               if (deployedSystemArg != null) {\r
-                       testRun.setDeployedSystem(deployedSystemArg.getInstance());\r
-                       log.trace("Overrides deployed system");\r
-               }\r
-\r
-               if (testResultArg != null) {\r
-                       testRun.setTestResult(testResultArg.getInstance());\r
-                       log.trace("Overrides test result");\r
-               }\r
-\r
-               // notify path to test result\r
-               TestResult result = testRun.getTestResult();\r
-               if (result == null) {\r
-                       result = loadSingleFromContext(TestResult.class);\r
-                       if (result == null) {\r
-                               result = new SimpleTestResult();\r
-                               log.warn("Created default simple test result");\r
-                       } else {\r
-                               if (log.isTraceEnabled())\r
-                                       log.trace("Load test result from scanning Spring context");\r
-                       }\r
-                       testRun.setTestResult(result);\r
-               }\r
-\r
-               SlcExecution slcExecution = getSlcExecution();\r
-               testRun.notifySlcExecution(slcExecution);\r
-\r
-               if (result != null && result instanceof StructureAware) {\r
-                       ((StructureAware<TreeSPath>) result).notifyCurrentPath(\r
-                                       getRegistry(), getTreeSPath());\r
-               }\r
-\r
-               try {\r
-                       ((ExecutableTestRun) testRun).execute();\r
-               } catch (RuntimeException e) {\r
-                       if (result != null) {\r
-                               SimpleResultPart errorPart = new SimpleResultPart(\r
-                                               TestStatus.ERROR,\r
-                                               "Unexpected exception when running test", e);\r
-                               result.addResultPart(errorPart);\r
-                       }\r
-                       throw e;\r
-               }\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
-       /** Creates sub tag. */\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 SpringArg<TestData> createTestData() {\r
-               testDataArg = new SpringArg<TestData>();\r
-               return testDataArg;\r
-       }\r
-\r
-       /** Creates sub tag. */\r
-       public SpringArg<DeployedSystem> createDeployedSystem() {\r
-               deployedSystemArg = new SpringArg<DeployedSystem>();\r
-               return deployedSystemArg;\r
-       }\r
-\r
-       /** Creates sub tag. */\r
-       public SpringArg<TestResult> createTestResult() {\r
-               testResultArg = new SpringArg<TestResult>();\r
-               return testResultArg;\r
-       }\r
-\r
-       protected <T> T loadSingleFromContext(Class<T> clss) {\r
-               return SpringUtils.loadSingleFromContext(getContext(), clss);\r
-       }\r
-}\r