1 package org
.argeo
.slc
.core
.execution
;
3 import java
.util
.ArrayList
;
4 import java
.util
.HashMap
;
8 import org
.argeo
.slc
.SlcException
;
9 import org
.argeo
.slc
.execution
.ExecutionFlowDescriptor
;
10 import org
.argeo
.slc
.execution
.ExecutionModule
;
11 import org
.argeo
.slc
.process
.RealizedFlow
;
12 import org
.argeo
.slc
.process
.SlcExecution
;
13 import org
.argeo
.slc
.unit
.AbstractSpringTestCase
;
14 import org
.springframework
.context
.ApplicationContext
;
15 import org
.springframework
.context
.ConfigurableApplicationContext
;
16 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
18 import junit
.framework
.TestCase
;
20 public class DefaultModulesMangerTest
extends AbstractSpringTestCase
{
22 public void testSimpleExecution() throws Exception
{
25 // create an execution
26 SlcExecution execution
= new SlcExecution();
27 execution
.setUuid("TestUUID");
28 List
<RealizedFlow
> realizedFlows
= new ArrayList
<RealizedFlow
>();
29 RealizedFlow flow
= new RealizedFlow();
30 flow
.setModuleName("dummyname");
31 flow
.setModuleVersion("dummyversion");
32 ExecutionFlowDescriptor executionFlowDescriptor
= new ExecutionFlowDescriptor();
33 executionFlowDescriptor
.setName("main");
34 Map
<String
, Object
> values
= new HashMap
<String
, Object
>();
35 values
.put("testKey", new PrimitiveValue(
36 PrimitiveSpecAttribute
.TYPE_INTEGER
, 22));
37 executionFlowDescriptor
.setValues(values
);
38 flow
.setFlowDescriptor(executionFlowDescriptor
);
39 realizedFlows
.add(flow
);
40 execution
.setRealizedFlows(realizedFlows
);
43 ApplicationContext applicationContext
= prepareExecution("applicationContext.xml");
44 ExecutionModule module
= createExecutionModule(applicationContext
);
46 // create an Execution Module Manager
47 DefaultModulesManager manager
= new DefaultModulesManager();
48 List
<ExecutionModule
> modules
= new ArrayList
<ExecutionModule
>();
50 manager
.setExecutionModules(modules
);
52 manager
.process(execution
);
55 protected ExecutionModule
createExecutionModule(ApplicationContext applicationContext
) {
56 AbstractSpringExecutionModule module
= new AbstractSpringExecutionModule() {
57 public String
getName() {return "dummyname";}
58 public String
getVersion() {return "dummyversion";}
60 module
.setApplicationContext(applicationContext
);
64 protected ConfigurableApplicationContext
prepareExecution(String applicationContextSuffix
) {
65 ConfigurableApplicationContext applicationContext
= new ClassPathXmlApplicationContext(inPackage(applicationContextSuffix
));
66 applicationContext
.start();
67 return applicationContext
;