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
.beans
.factory
.config
.BeanDefinition
;
9 import org
.springframework
.context
.ConfigurableApplicationContext
;
10 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
12 public class ExecutionFlowTest
extends AbstractSpringTestCase
{
14 public void testSimpleExecution() throws Exception
{
15 // prepareExecution("applicationContext.xml");
16 configureAndExecuteSlcFlow("applicationContext.xml", "main_2");
18 // ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(inPackage("applicationContext.xml"));
19 // String[] beanNames = applicationContext.getBeanDefinitionNames();
20 // for(String beanName : beanNames) {
21 // log.info("beanName='" + beanName + "'");
22 //// if(beanName.equals("main_temp")) {
23 // BeanDefinition beanDef = applicationContext.getBeanFactory().getBeanDefinition(beanName);
24 // String scope = beanDef.getScope();
25 // String[] attrs = beanDef.();
26 // log.info("scope=" + scope + ", nbAttr=" + attrs.length);
27 // for(String attr : attrs) {
28 // log.info(attr + "=" + beanDef.getAttribute(attr));
35 public void testCanonic() throws Exception
{
36 // Parameter without default value in specification
37 // configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
38 // configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
41 // prepareExecution("canonic-003.error.xml");
42 // fail("Parameter not set - should be rejected.");
43 // } catch (BeanCreationException e) {
44 // // exception expected
49 configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
50 fail("Unknown parameter set - should be rejected.");
51 } catch (BeanCreationException e) {
57 public void testRecursive() throws Exception
{
58 // ConfigurableApplicationContext applicationContext = prepareExecution("test.xml");
59 // ExecutionFlow executionFlow = (ExecutionFlow) applicationContext.getBean("first");
60 // executionFlow.execute();
61 // SimpleTestResult res = (SimpleTestResult) applicationContext.getBean("basicTestResult");
62 // if(res.getParts().get(0).getStatus() != TestStatus.PASSED) {
63 // fail("Unexpected string returned");
65 // applicationContext.close();
68 public void testCreateRef() throws Exception
{
69 // configureAndExecuteSlcFlow("createRef.xml", "basic.001");
72 protected void logException(Throwable ex
) {
73 log
.info("Got Exception of class " + ex
.getClass().toString()
74 + " with message '" + ex
.getMessage() + "'.");
77 protected void initExecutionContext() {
78 /* // if an execution context was registered, unregister it
79 if(MapExecutionContext.getCurrent() != null) {
80 MapExecutionContext.unregisterExecutionContext();
82 // register a new ExecutionContext
83 MapExecutionContext.registerExecutionContext(new MapExecutionContext()); */
86 protected ConfigurableApplicationContext
prepareExecution(String applicationContextSuffix
) {
87 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(inPackage(applicationContextSuffix
));
88 applicationContext
.start();
89 initExecutionContext();
90 return applicationContext
;
93 protected void configureAndExecuteSlcFlow(String applicationContextSuffix
, String beanName
) {
94 ConfigurableApplicationContext applicationContext
= prepareExecution(applicationContextSuffix
);
95 ExecutionFlow executionFlow
= (ExecutionFlow
) applicationContext
.getBean(beanName
);
96 executionFlow
.execute();
97 applicationContext
.close();