1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.construct;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.client.MuleClient;
15 import org.mule.lifecycle.LifecycleTrackerProcessor;
16 import org.mule.tck.junit4.FunctionalTestCase;
17
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertEquals;
21
22 public class SubFlowTestCase extends FunctionalTestCase
23 {
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "org/mule/test/construct/sub-flow.xml";
29 }
30
31 @Test
32 public void testProcessorChainViaProcessorRef() throws Exception
33 {
34 MuleClient client = muleContext.getClient();
35 MuleMessage result = client.send("vm://ProcessorChainViaProcessorRef", "", null);
36 assertEquals("1xyz2", result.getPayloadAsString());
37
38 assertEquals("[setMuleContext, initialise, setService, setMuleContext, initialise, start]",
39 result.getInboundProperty(LifecycleTrackerProcessor.LIFECYCLE_TRACKER_PROCESSOR_PROPERTY));
40 assertEquals(muleContext.getRegistry().lookupFlowConstruct("ProcessorChainViaProcessorRef"),
41 result.getInboundProperty(LifecycleTrackerProcessor.FLOW_CONSRUCT_PROPERTY));
42 }
43
44 @Test
45 public void testProcessorChainViaFlowRef() throws Exception
46 {
47 MuleClient client = muleContext.getClient();
48 MuleMessage result = client.send("vm://ProcessorChainViaFlowRef", "", null);
49
50 assertEquals("1xyz2", result.getPayloadAsString());
51
52 assertEquals("[setMuleContext, initialise, setService, setMuleContext, initialise, start]",
53 result.getInboundProperty(LifecycleTrackerProcessor.LIFECYCLE_TRACKER_PROCESSOR_PROPERTY));
54 assertEquals(muleContext.getRegistry().lookupFlowConstruct("ProcessorChainViaFlowRef"),
55 result.getInboundProperty(LifecycleTrackerProcessor.FLOW_CONSRUCT_PROPERTY));
56 }
57
58 @Test
59 public void testSubFlowViaProcessorRef() throws Exception
60 {
61 MuleClient client = muleContext.getClient();
62 MuleMessage result = client.send("vm://SubFlowViaProcessorRef", "", null);
63 assertEquals("1xyz2", result.getPayloadAsString());
64
65 assertEquals("[setMuleContext, initialise, setService, setMuleContext, initialise, start]",
66 result.getInboundProperty(LifecycleTrackerProcessor.LIFECYCLE_TRACKER_PROCESSOR_PROPERTY));
67 assertEquals(muleContext.getRegistry().lookupFlowConstruct("SubFlowViaProcessorRef"),
68 result.getInboundProperty(LifecycleTrackerProcessor.FLOW_CONSRUCT_PROPERTY));
69 }
70
71 @Test
72 public void testSubFlowViaFlowRef() throws Exception
73 {
74 MuleClient client = muleContext.getClient();
75 MuleMessage result = client.send("vm://SubFlowViaFlowRef", "", null);
76
77 assertEquals("1xyz2", result.getPayloadAsString());
78
79 assertEquals("[setMuleContext, initialise, setService, setMuleContext, initialise, start]",
80 result.getInboundProperty(LifecycleTrackerProcessor.LIFECYCLE_TRACKER_PROCESSOR_PROPERTY));
81 assertEquals(muleContext.getRegistry().lookupFlowConstruct("SubFlowViaFlowRef"),
82 result.getInboundProperty(LifecycleTrackerProcessor.FLOW_CONSRUCT_PROPERTY));
83 }
84
85 @Test
86 public void testFlowviaFlowRef() throws Exception
87 {
88 MuleClient client = muleContext.getClient();
89 assertEquals("1xyz2", client.send("vm://FlowViaFlowRef", "", null).getPayloadAsString());
90 }
91
92 @Test
93 public void testServiceviaFlowRef() throws Exception
94 {
95 MuleClient client = muleContext.getClient();
96 assertEquals("1xyz2", client.send("vm://ServiceViaFlowRef", "", null).getPayloadAsString());
97 }
98
99 @Test
100 public void testFlowWithSubFlowWithComponent() throws Exception
101 {
102 MuleClient client = muleContext.getClient();
103 assertEquals("0", client.send("vm://flowWithsubFlowWithComponent", "0", null).getPayloadAsString());
104
105 }
106
107 @Test
108 public void testFlowWithSameSubFlowTwice() throws Exception
109 {
110 MuleClient client = muleContext.getClient();
111 assertEquals("0xyzxyz", client.send("vm://flowWithSameSubFlowTwice", "0", null).getPayloadAsString());
112 }
113
114 @Test
115 public void testFlowWithSameSubFlowSingletonTwice() throws Exception
116 {
117 MuleClient client = muleContext.getClient();
118 assertEquals("0xyzxyz", client.send("vm://flowWithSameSubFlowSingletonTwice", "0", null).getPayloadAsString());
119 }
120
121 @Test
122 public void testFlowWithSameGlobalChainTwice() throws Exception
123 {
124 MuleClient client = muleContext.getClient();
125 assertEquals("0xyzxyz", client.send("vm://flowWithSameGlobalChainTwice", "0", null).getPayloadAsString());
126 }
127
128 @Test
129 public void testFlowWithSameGlobalChainSingletonTwice() throws Exception
130 {
131 MuleClient client = muleContext.getClient();
132 assertEquals("0xyzxyz", client.send("vm://flowWithSameGlobalChainSingletonTwice", "0", null).getPayloadAsString());
133 }
134
135 }