1 package org
.argeo
.slc
.example
.junit
;
5 import junit
.framework
.TestCase
;
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
;
18 public class ContextIntegrationTest
extends TestCase
{
19 private static Log log
= LogFactory
.getLog(ContextIntegrationTest
.class);
21 public void testContext() throws Exception
{
22 TestResultDao
<TreeTestResult
> testResultDao
= runAnt(
23 "root/Context/build.xml", null);
25 TreeTestResult testResult1
= (TreeTestResult
) testResultDao
28 String basePath
= "/root/Context/testContext/";
29 UnitTestTreeUtil
.assertPart(testResult1
, basePath
30 + "slc.test0/reference", 0, TestStatus
.PASSED
,
31 "Values matched for key 'reference'");
32 UnitTestTreeUtil
.assertPart(testResult1
, basePath
33 + "slc.test1/reference2", 0, TestStatus
.PASSED
,
34 "Values matched for key 'reference2'");
35 UnitTestTreeUtil
.assertPart(testResult1
, basePath
+ "slc.test1/var", 0,
36 TestStatus
.PASSED
, "Values matched for key 'var'");
37 UnitTestTreeUtil
.assertPart(testResult1
, basePath
38 + "slc.test1/varIntern", 0, TestStatus
.PASSED
,
39 "Values matched for key 'varIntern'");
40 UnitTestTreeUtil
.assertPart(testResult1
, basePath
41 + "slc.test1/varExtern", 0, TestStatus
.PASSED
,
42 "Values matched for key 'varExtern'");
43 UnitTestTreeUtil
.assertPart(testResult1
, basePath
44 + "slc.test1/greeting", 0, TestStatus
.PASSED
,
45 "Values matched for key 'greeting'");
49 public void testBaseContext() throws Exception
{
50 TestResultDao
<TreeTestResult
> testResultDao
= runAnt(
51 "root/Context/build.xml", "testBaseContext");
53 TreeTestResult testResult1
= (TreeTestResult
) testResultDao
56 String basePath
= "/root/Context/testBaseContext/";
57 UnitTestTreeUtil
.assertPart(testResult1
, basePath
58 + "slc.test0/reference", 0, TestStatus
.PASSED
,
59 "Values matched for key 'reference'");
60 UnitTestTreeUtil
.assertPart(testResult1
, basePath
61 + "slc.test1/reference", 0, TestStatus
.PASSED
,
62 "Values matched for key 'reference'");
63 UnitTestTreeUtil
.assertPart(testResult1
, basePath
64 + "slc.test1/varIntern", 0, TestStatus
.PASSED
,
65 "Values matched for key 'varIntern'");
69 private TestResultDao
<TreeTestResult
> runAnt(String antFileRelPath
,
70 String target
) throws Exception
{
71 String slcBase
= System
.getProperty("it.slc.base", "exampleSlcAppli");
72 File slcBaseDir
= new File(slcBase
).getCanonicalFile();
73 log
.info("SLC base: " + slcBaseDir
);
75 File antFile
= new File(slcBaseDir
.getPath() + File
.separator
77 Project p
= AntRegistryUtil
.runAll(antFile
, target
);
79 ApplicationContext context
= (ApplicationContext
) p
80 .getReference(SlcAntConstants
.REF_ROOT_CONTEXT
);
82 TestResultDao
<TreeTestResult
> testResultDao
= (TestResultDao
<TreeTestResult
>) context
83 .getBean("testResultDao");