1 package org
.argeo
.slc
.core
.execution
;
3 import org
.argeo
.slc
.core
.test
.SimpleTestResult
;
4 import org
.argeo
.slc
.execution
.ExecutionFlow
;
5 import org
.argeo
.slc
.test
.TestStatus
;
6 import org
.argeo
.slc
.unit
.AbstractSpringTestCase
;
7 import org
.springframework
.beans
.factory
.BeanCreationException
;
8 import org
.springframework
.context
.ConfigurableApplicationContext
;
9 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
11 public class ExecutionFlowTest
extends AbstractSpringTestCase
{
13 public void testSimpleExecution() throws Exception
{
14 configureAndExecuteSlcFlow("applicationContext.xml", "main");
17 public void testCanonic() throws Exception
{
18 // Parameter without default value in specification
19 /* configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
20 configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
23 configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");
24 fail("Parameter not set - should be rejected.");
25 } catch (BeanCreationException e) {
31 configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
32 fail("Unknown parameter set - should be rejected.");
33 } catch (BeanCreationException e) {
39 /* public void testRecursive() throws Exception {
40 ConfigurableApplicationContext applicationContext = prepareExecution("test.xml");
41 ExecutionFlow executionFlow = (ExecutionFlow) applicationContext.getBean("first");
42 executionFlow.execute();
43 SimpleTestResult res = (SimpleTestResult) applicationContext.getBean("basicTestResult");
44 if(res.getParts().get(0).getStatus() != TestStatus.PASSED) {
45 fail("Unexpected string returned");
47 applicationContext.close();
50 protected void logException(Throwable ex
) {
51 log
.info("Got Exception of class " + ex
.getClass().toString()
52 + " with message '" + ex
.getMessage() + "'.");
55 protected void initExecutionContext() {
56 /* // if an execution context was registered, unregister it
57 if(MapExecutionContext.getCurrent() != null) {
58 MapExecutionContext.unregisterExecutionContext();
60 // register a new ExecutionContext
61 MapExecutionContext.registerExecutionContext(new MapExecutionContext()); */
64 protected ConfigurableApplicationContext
prepareExecution(String applicationContextSuffix
) {
65 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(inPackage(applicationContextSuffix
));
66 applicationContext
.start();
67 initExecutionContext();
68 return applicationContext
;
71 protected void configureAndExecuteSlcFlow(String applicationContextSuffix
, String beanName
) {
72 ConfigurableApplicationContext applicationContext
= prepareExecution(applicationContextSuffix
);
73 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
.getBean(beanName
);
74 executionFlow
.execute();
75 applicationContext
.close();