From cdad00a2b6000a3baccf8fe062ede3ecaaf44f44 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Wed, 30 Jan 2008 18:26:45 +0000 Subject: [PATCH] Introduce context at ant level git-svn-id: https://svn.argeo.org/slc/trunk@938 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../conf/applicationContext.xml | 1 + .../exampleSlcAppli/conf/contextTests.xml | 41 +++++++++++++++++++ .../exampleSlcAppli/conf/log4j.properties | 2 +- .../exampleSlcAppli/conf/testDefinitions.xml | 5 +++ .../root/Category1/SubCategory2/build.xml | 8 ++-- .../root/Category1/SubCategory2/complex.xml | 25 +++++++++++ org.argeo.slc.example/pom.xml | 2 +- .../slc/example/ContextExampleTestDef.java | 24 +++++++++++ .../example/junit/ExampleIntegrationTest.java | 15 ++++++- 9 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 org.argeo.slc.example/exampleSlcAppli/conf/contextTests.xml create mode 100644 org.argeo.slc.example/src/main/java/org/argeo/slc/example/ContextExampleTestDef.java diff --git a/org.argeo.slc.example/exampleSlcAppli/conf/applicationContext.xml b/org.argeo.slc.example/exampleSlcAppli/conf/applicationContext.xml index f8a240998..8a658dda6 100644 --- a/org.argeo.slc.example/exampleSlcAppli/conf/applicationContext.xml +++ b/org.argeo.slc.example/exampleSlcAppli/conf/applicationContext.xml @@ -7,4 +7,5 @@ + \ No newline at end of file diff --git a/org.argeo.slc.example/exampleSlcAppli/conf/contextTests.xml b/org.argeo.slc.example/exampleSlcAppli/conf/contextTests.xml new file mode 100644 index 000000000..440c6b87b --- /dev/null +++ b/org.argeo.slc.example/exampleSlcAppli/conf/contextTests.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.argeo.slc.example/exampleSlcAppli/conf/log4j.properties b/org.argeo.slc.example/exampleSlcAppli/conf/log4j.properties index b92b4cca7..783bc0699 100644 --- a/org.argeo.slc.example/exampleSlcAppli/conf/log4j.properties +++ b/org.argeo.slc.example/exampleSlcAppli/conf/log4j.properties @@ -3,7 +3,7 @@ log4j.rootLogger=INFO, console ## Levels # Slc -log4j.logger.org.argeo.slc=TRACE +log4j.logger.org.argeo.slc=INFO # Spring log4j.logger.org.springframework=INFO # Hibernate diff --git a/org.argeo.slc.example/exampleSlcAppli/conf/testDefinitions.xml b/org.argeo.slc.example/exampleSlcAppli/conf/testDefinitions.xml index 2522d280f..8d7387d19 100644 --- a/org.argeo.slc.example/exampleSlcAppli/conf/testDefinitions.xml +++ b/org.argeo.slc.example/exampleSlcAppli/conf/testDefinitions.xml @@ -8,6 +8,11 @@ scope="prototype"> + + + diff --git a/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/build.xml b/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/build.xml index 27780d316..d27ad20fc 100644 --- a/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/build.xml +++ b/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/build.xml @@ -1,9 +1,9 @@ A Test project - - - + + + @@ -13,7 +13,7 @@ - + diff --git a/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/complex.xml b/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/complex.xml index 57c39e586..88cbf3fad 100644 --- a/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/complex.xml +++ b/org.argeo.slc.example/exampleSlcAppli/root/Category1/SubCategory2/complex.xml @@ -19,5 +19,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.argeo.slc.example/pom.xml b/org.argeo.slc.example/pom.xml index c1e7c66a0..1ce16aea0 100644 --- a/org.argeo.slc.example/pom.xml +++ b/org.argeo.slc.example/pom.xml @@ -6,7 +6,7 @@ org.argeo.slc argeo-slc - 0.8.1 + 0.8-SNAPSHOT ../org.argeo.slc argeo-slc-example diff --git a/org.argeo.slc.example/src/main/java/org/argeo/slc/example/ContextExampleTestDef.java b/org.argeo.slc.example/src/main/java/org/argeo/slc/example/ContextExampleTestDef.java new file mode 100644 index 000000000..7fec8e75f --- /dev/null +++ b/org.argeo.slc.example/src/main/java/org/argeo/slc/example/ContextExampleTestDef.java @@ -0,0 +1,24 @@ +package org.argeo.slc.example; + +import org.argeo.slc.core.structure.SimpleSElement; +import org.argeo.slc.core.structure.StructureElement; +import org.argeo.slc.core.structure.tree.TreeSRelatedHelper; +import org.argeo.slc.core.test.TestDefinition; +import org.argeo.slc.core.test.TestRun; +import org.argeo.slc.core.test.context.ContextUtils; +import org.argeo.slc.core.test.context.DefaultContextTestData; + +public class ContextExampleTestDef extends TreeSRelatedHelper implements + TestDefinition { + + public void execute(TestRun testRun) { + DefaultContextTestData data = testRun.getTestData(); + ContextUtils + .compareReachedExpected(data, testRun.getTestResult(), this); + } + + public StructureElement getStructureElement(String key) { + return new SimpleSElement(key); + } + +} diff --git a/org.argeo.slc.example/src/test/java/org/argeo/slc/example/junit/ExampleIntegrationTest.java b/org.argeo.slc.example/src/test/java/org/argeo/slc/example/junit/ExampleIntegrationTest.java index 592d228d8..cdc8fd596 100644 --- a/org.argeo.slc.example/src/test/java/org/argeo/slc/example/junit/ExampleIntegrationTest.java +++ b/org.argeo.slc.example/src/test/java/org/argeo/slc/example/junit/ExampleIntegrationTest.java @@ -25,8 +25,8 @@ public class ExampleIntegrationTest extends TestCase { private static Log log = LogFactory.getLog(ExampleIntegrationTest.class); /** Tests an end-to-end Ant run. */ - public void testAllRunSimple() throws Exception{ - String slcBase = System.getProperty("it.slc.base","exampleSlcAppli"); + public void testAllRunSimple() throws Exception { + String slcBase = System.getProperty("it.slc.base", "exampleSlcAppli"); File slcBaseDir = new File(slcBase).getCanonicalFile(); log.info("SLC base: " + slcBaseDir); @@ -65,6 +65,17 @@ public class ExampleIntegrationTest extends TestCase { "/root/Category1/SubCategory2/testError/slc.test0", 0, TestStatus.ERROR, "Execute example appli"); + // Context + assertPart(testResult1, + "/root/Category1/SubCategory2/testContext/slc.test1/reference", + 0, TestStatus.PASSED, "Values matched for key 'reference'"); + assertPart(testResult1, + "/root/Category1/SubCategory2/testContext/slc.test1/varIntern", + 0, TestStatus.PASSED, "Values matched for key 'varIntern'"); + assertPart(testResult1, + "/root/Category1/SubCategory2/testContext/slc.test1/varExtern", + 0, TestStatus.PASSED, "Values matched for key 'varExtern'"); + numericTRId.setValue(2l); TreeTestResult testResult2 = (TreeTestResult) testResultDao .getTestResult(numericTRId); -- 2.39.5