1 package org
.argeo
.slc
.core
.execution
;
3 import junit
.framework
.TestCase
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.core
.test
.SimpleTestResult
;
8 import org
.argeo
.slc
.execution
.ExecutionFlow
;
9 import org
.argeo
.slc
.test
.TestResultPart
;
10 import org
.argeo
.slc
.test
.TestStatus
;
11 import org
.springframework
.context
.ConfigurableApplicationContext
;
12 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
14 public abstract class AbstractExecutionFlowTestCase
extends TestCase
{
16 protected final Log log
= LogFactory
.getLog(getClass());
18 protected void logException(Throwable ex
) {
19 log
.info("Got Exception of class " + ex
.getClass().toString()
20 + " with message '" + ex
.getMessage() + "'.");
23 protected void validateTestResult(SimpleTestResult testResult
) {
24 validateTestResult(testResult
, TestStatus
.PASSED
);
27 protected void validateTestResult(SimpleTestResult testResult
,
29 for (TestResultPart part
: testResult
.getParts()) {
30 if (part
.getStatus() != expectedStatus
) {
31 fail("Error found in TestResult: " + part
.getMessage());
36 protected ConfigurableApplicationContext
createApplicationContext(
37 String applicationContextSuffix
) {
38 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(
39 inPackage(applicationContextSuffix
));
40 // applicationContext.start();
41 return applicationContext
;
44 protected void configureAndExecuteSlcFlow(String applicationContextSuffix
,
46 ConfigurableApplicationContext applicationContext
= createApplicationContext(applicationContextSuffix
);
47 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
50 applicationContext
.close();
53 protected String
inPackage(String suffix
) {
54 String prefix
= getClass().getPackage().getName().replace('.', '/');
55 return prefix
+ '/' + suffix
;