1
2
3
4
5
6
7 package org.mule.transport.vm.functional;
8
9 import static org.junit.Assert.assertEquals;
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertNull;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleMessage;
15 import org.mule.api.client.MuleClient;
16 import org.mule.api.transport.PropertyScope;
17 import org.mule.tck.junit4.FunctionalTestCase;
18
19 import org.junit.Ignore;
20 import org.junit.Test;
21
22
23
24
25
26 public class PropertyScopesTestCase extends FunctionalTestCase
27 {
28
29 @Override
30 protected String getConfigResources()
31 {
32 return "vm/property-scopes.xml";
33 }
34
35 @Test
36 public void noPropagationOfInboundScopeSynchronous() throws Exception
37 {
38 MuleClient client = muleContext.getClient();
39 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
40 message.setProperty("foo", "bar", PropertyScope.INBOUND);
41
42 MuleMessage response = client.send("vm://in-synch", message);
43 assertNotNull(response);
44 assertNull("Property should not have been propogated for this scope",
45 response.getProperty("foo", PropertyScope.INBOUND));
46 }
47
48 @Test
49 public void noPropagationOfOutboundScopeSynchronous() throws Exception
50 {
51 MuleClient client = muleContext.getClient();
52 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
53 message.setProperty("foo", "bar", PropertyScope.OUTBOUND);
54
55 MuleMessage response = client.send("vm://in-synch", message);
56 assertNotNull(response);
57 assertNull("Property should not have been propogated for this scope",
58 response.getProperty("foo", PropertyScope.OUTBOUND));
59 }
60
61 @Test
62 public void propagationOfInvocationScopeSynchronous() throws Exception
63 {
64 MuleClient client = muleContext.getClient();
65 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
66 message.setProperty("foo", "bar", PropertyScope.INVOCATION);
67
68 MuleMessage response = client.send("vm://in-synch", message);
69 assertNotNull(response);
70
71
72
73 assertEquals("bar", response.getProperty("foo", PropertyScope.INVOCATION));
74 }
75
76 @Test
77 @Ignore
78
79 public void propagationOfSessionScopeSynchronous() throws Exception
80 {
81 MuleClient client = muleContext.getClient();
82 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
83 message.setProperty("foo", "bar", PropertyScope.SESSION);
84
85 MuleMessage response = client.send("vm://in-synch", message);
86 assertNotNull(response);
87 assertEquals("bar", response.getProperty("foo", PropertyScope.SESSION));
88 }
89
90 @Test
91 public void noPropagationOfInboundScopeAsynchronous() throws Exception
92 {
93 MuleClient client = muleContext.getClient();
94 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
95 message.setProperty("foo", "bar", PropertyScope.INBOUND);
96 client.dispatch("vm://in-asynch", message);
97 MuleMessage response = client.request("vm://out-asynch", RECEIVE_TIMEOUT);
98 assertNotNull(response);
99 assertNull("Property should not have been propogated for this scope",
100 response.getProperty("foo", PropertyScope.INBOUND));
101 }
102
103 @Test
104 public void noPropagationOfOutboundScopeAsynchronous() throws Exception
105 {
106 MuleClient client = muleContext.getClient();
107 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
108 message.setProperty("foo", "bar", PropertyScope.OUTBOUND);
109 client.dispatch("vm://in-asynch", message);
110 MuleMessage response = client.request("vm://out-asynch", RECEIVE_TIMEOUT);
111 assertNotNull(response);
112 assertNull("Property should not have been propogated for this scope",
113 response.getProperty("foo", PropertyScope.OUTBOUND));
114 }
115
116 @Test
117 public void noPropagationOfInvocationScopeAsynchronous() throws Exception
118 {
119 MuleClient client = muleContext.getClient();
120 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
121 message.setProperty("foo", "bar", PropertyScope.INVOCATION);
122 client.dispatch("vm://in-asynch", message);
123 MuleMessage response = client.request("vm://out-asynch", RECEIVE_TIMEOUT);
124 assertNotNull(response);
125
126 assertNull(response.getProperty("foo", PropertyScope.INVOCATION));
127 }
128
129 @Test
130 @Ignore
131
132 public void propagationOfSessionScopeAsynchronous() throws Exception
133 {
134 MuleClient client = muleContext.getClient();
135 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
136 message.setProperty("foo", "bar", PropertyScope.SESSION);
137 client.dispatch("vm://in-asynch", message);
138 MuleMessage response = client.request("vm://out-asynch", RECEIVE_TIMEOUT);
139 assertNotNull(response);
140 assertEquals("bar", response.getProperty("foo", PropertyScope.SESSION));
141 }
142 }