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
.execution
.ExecutionContext
;
8 import org
.argeo
.slc
.execution
.ExecutionFlow
;
9 import org
.argeo
.slc
.runtime
.test
.SimpleTestResult
;
10 import org
.argeo
.slc
.test
.TestResultPart
;
11 import org
.argeo
.slc
.test
.TestStatus
;
12 import org
.springframework
.context
.ConfigurableApplicationContext
;
13 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
15 public abstract class AbstractExecutionFlowTestCase
extends TestCase
{
17 protected final Log log
= LogFactory
.getLog(getClass());
19 protected void logException(Throwable ex
) {
20 log
.info("Got Exception of class " + ex
.getClass().toString()
21 + " with message '" + ex
.getMessage() + "'.");
24 protected void validateTestResult(SimpleTestResult testResult
) {
25 validateTestResult(testResult
, TestStatus
.PASSED
);
28 protected void validateTestResult(SimpleTestResult testResult
,
30 for (TestResultPart part
: testResult
.getParts()) {
31 if (part
.getStatus() != expectedStatus
) {
32 fail("Error found in TestResult: " + part
.getMessage());
37 protected ConfigurableApplicationContext
createApplicationContext(
38 String applicationContextSuffix
) {
39 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(
40 inPackage(applicationContextSuffix
));
41 // applicationContext.start();
42 return applicationContext
;
45 protected void configureAndExecuteSlcFlow(String applicationContextSuffix
,
47 ConfigurableApplicationContext applicationContext
= createApplicationContext(applicationContextSuffix
);
48 ExecutionContext executionContext
= (ExecutionContext
) applicationContext
49 .getBean("executionContext");
50 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
52 if (executionFlow
instanceof DefaultExecutionFlow
)
53 ((DefaultExecutionFlow
) executionFlow
)
54 .setExecutionContext(executionContext
);
56 executionContext
.beforeFlow(executionFlow
);
59 executionContext
.afterFlow(executionFlow
);
61 applicationContext
.close();
64 protected String
inPackage(String suffix
) {
65 String prefix
= getClass().getPackage().getName().replace('.', '/');
66 return prefix
+ '/' + suffix
;