1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.bpm.config;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertNull;
16
17 import org.mule.construct.Flow;
18 import org.mule.module.bpm.BPMS;
19 import org.mule.module.bpm.ProcessComponent;
20 import org.mule.module.bpm.test.TestBpms;
21 import org.mule.tck.AbstractServiceAndFlowTestCase;
22
23 import java.util.Arrays;
24 import java.util.Collection;
25
26 import org.junit.Test;
27 import org.junit.runners.Parameterized.Parameters;
28
29
30
31
32 public class BpmNamespaceHandlerTestCase extends AbstractServiceAndFlowTestCase
33 {
34 public BpmNamespaceHandlerTestCase(ConfigVariant variant, String configResources)
35 {
36 super(variant, configResources);
37 }
38
39 @Parameters
40 public static Collection<Object[]> parameters()
41 {
42 return Arrays.asList(new Object[][]{{ConfigVariant.SERVICE, "bpm-namespace-config-service.xml"},
43 {ConfigVariant.FLOW, "bpm-namespace-config-flow.xml"}});
44 }
45
46 @Test
47 public void testDefaultsComponent() throws Exception
48 {
49 ProcessComponent c;
50
51 if (variant.equals(ConfigVariant.FLOW))
52 {
53 c = (ProcessComponent) ((Flow) muleContext.getRegistry().lookupObject("Service1")).getMessageProcessors()
54 .get(0);
55 }
56 else
57 {
58 c = (ProcessComponent) muleContext.getRegistry().lookupService("Service1").getComponent();
59 }
60
61 assertNotNull(c);
62
63 assertEquals("test.def", c.getResource());
64 assertNull(c.getProcessIdField());
65
66
67 BPMS bpms = c.getBpms();
68 assertNotNull(bpms);
69 assertEquals(TestBpms.class, bpms.getClass());
70 assertEquals("bar", ((TestBpms) bpms).getFoo());
71 }
72
73 @Test
74 public void testConfigComponent() throws Exception
75 {
76 ProcessComponent c;
77
78 if (variant.equals(ConfigVariant.FLOW))
79 {
80 c = (ProcessComponent) ((Flow) muleContext.getRegistry().lookupObject("Service2")).getMessageProcessors()
81 .get(0);
82 }
83 else
84 {
85 c = (ProcessComponent) muleContext.getRegistry().lookupService("Service2").getComponent();
86 }
87
88 assertNotNull(c);
89
90 assertEquals("test.def", c.getResource());
91 assertEquals("myId", c.getProcessIdField());
92
93
94 BPMS bpms = c.getBpms();
95 assertNotNull(bpms);
96 assertEquals(TestBpms.class, bpms.getClass());
97 assertEquals("bar", ((TestBpms) bpms).getFoo());
98 }
99
100 }