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