]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.example/src/test/java/org/argeo/slc/example/junit/ExampleIntegrationTest.java
Introduce runtime selection
[gpl/argeo-slc.git] / org.argeo.slc.example / src / test / java / org / argeo / slc / example / junit / ExampleIntegrationTest.java
1 package org.argeo.slc.example.junit;
2
3 import java.io.File;
4
5 import junit.framework.TestCase;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9 import org.apache.tools.ant.Project;
10 import org.argeo.slc.ant.AntRegistryUtil;
11 import org.argeo.slc.ant.SlcAntConstants;
12 import org.argeo.slc.core.test.TestStatus;
13 import org.argeo.slc.core.test.tree.TreeTestResult;
14 import org.argeo.slc.dao.test.TestResultDao;
15 import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;
16 import org.springframework.context.ApplicationContext;
17
18 /** High level tests for SLC Ant. */
19 public class ExampleIntegrationTest extends TestCase {
20 private static Log log = LogFactory.getLog(ExampleIntegrationTest.class);
21
22 /** Tests an end-to-end Ant run. */
23 public void testAllRunSimple() throws Exception {
24 String slcBase = System.getProperty("it.slc.base", "exampleSlcAppli");
25 File slcBaseDir = new File(slcBase).getCanonicalFile();
26 log.info("SLC base: " + slcBaseDir);
27
28 String reportDirPath = slcBaseDir.getPath() + "/work/results/report/";
29 File[] reportFiles = new File(reportDirPath).listFiles();
30 for (File file : reportFiles) {
31 file.delete();
32 }
33
34 File antFile = new File(slcBaseDir.getPath()
35 + "/root/Category1/SubCategory2/build.xml");
36 Project p = AntRegistryUtil.runAll(antFile);
37
38 ApplicationContext context = (ApplicationContext) p
39 .getReference(SlcAntConstants.REF_ROOT_CONTEXT);
40
41 TestResultDao testResultDao = (TestResultDao) context
42 .getBean("testResultDao");
43
44 TreeTestResult testResult1 = (TreeTestResult) testResultDao
45 .getTestResult("1");
46 // assertPart(testResult1, "", 0, TestStatus.PASSED, "");
47 UnitTestTreeUtil
48 .assertPart(
49 testResult1,
50 "/root/Category1/SubCategory2/testComplex/slc.test0/0",
51 0,
52 TestStatus.PASSED,
53 "Sub task with path /root/Category1/SubCategory2/testComplex/slc.test0/0 executed");
54 UnitTestTreeUtil.assertPart(testResult1,
55 "/root/Category1/SubCategory2/testSimple/slc.test0", 1,
56 TestStatus.FAILED,
57 "Compare nato-expected.txt with nato-reached.txt");
58 UnitTestTreeUtil.assertPart(testResult1,
59 "/root/Category1/SubCategory2/testError/slc.test0", 0,
60 TestStatus.ERROR, "Execute example appli");
61
62 // TreeTestResult testResult2 = (TreeTestResult) testResultDao
63 // .getTestResult("2");
64 // UnitTestTreeUtil.assertPart(testResult2,
65 // "/root/Category1/SubCategory2/testSimple/slc.test2", 1,
66 // TestStatus.PASSED,
67 // "Compare eu-reform-expected.txt with eu-reform-reached.txt");
68 // UnitTestTreeUtil.assertPart(testResult2,
69 // "/root/Category1/SubCategory2/testSimple/slc.test3", 1,
70 // TestStatus.FAILED,
71 // "Compare eu-reform-expected.txt with eu-reform-reached.txt");
72
73 assertTrue(new File(reportDirPath + "index.html").exists());
74 assertTrue(new File(reportDirPath + "slc-resultsList.html").exists());
75 assertTrue(new File(reportDirPath + "slc-result-1.html").exists());
76 // assertTrue(new File(reportDirPath + "slc-result-2.html").exists());
77 }
78
79 }