1
2
3
4
5
6
7 package org.mule.test.integration.exceptions;
8
9 import org.mule.api.MuleMessage;
10
11 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
12 import org.junit.Test;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertNull;
17
18 public class AsynchronousMessagingExceptionStrategyTestCase extends AbstractExceptionStrategyTestCase
19 {
20
21 @Override
22 protected String getConfigResources()
23 {
24 return "org/mule/test/integration/exceptions/asynch-messaging-exception-strategy.xml";
25 }
26
27 @Test
28 public void testInboundTransformer() throws Exception
29 {
30 client.dispatch("vm://in1", TEST_MESSAGE, null);
31 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
32 assertEquals(1, serviceExceptionCounter.get());
33 assertEquals(0, systemExceptionCounter.get());
34 }
35
36 @Test
37 public void testInboundResponseTransformer() throws Exception
38 {
39 client.dispatch("vm://in2", TEST_MESSAGE, null);
40 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
41
42 assertEquals(0, serviceExceptionCounter.get());
43 assertEquals(0, systemExceptionCounter.get());
44 }
45
46 @Test
47 public void testOutboundTransformer() throws Exception
48 {
49 client.dispatch("vm://in3", TEST_MESSAGE, null);
50 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
51 assertEquals(1, serviceExceptionCounter.get());
52 assertEquals(0, systemExceptionCounter.get());
53 MuleMessage response = client.request("vm://out3", 500);
54 assertNull(response);
55 }
56
57 @Test
58 public void testOutboundResponseTransformer() throws Exception
59 {
60 client.dispatch("vm://in4", TEST_MESSAGE, null);
61 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
62
63 assertEquals(0, serviceExceptionCounter.get());
64 assertEquals(0, systemExceptionCounter.get());
65 MuleMessage response = client.request("vm://out4", 500);
66 assertNotNull(response);
67 }
68
69 @Test
70 public void testComponent() throws Exception
71 {
72 client.dispatch("vm://in5", TEST_MESSAGE, null);
73 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
74 assertEquals(1, serviceExceptionCounter.get());
75 assertEquals(0, systemExceptionCounter.get());
76 }
77
78 @Test
79 public void testInboundRouter() throws Exception
80 {
81 client.dispatch("vm://in6", TEST_MESSAGE, null);
82 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
83 assertEquals(1, serviceExceptionCounter.get());
84 assertEquals(0, systemExceptionCounter.get());
85 }
86
87 @Test
88 public void testOutboundRouter() throws Exception
89 {
90 client.dispatch("vm://in7", TEST_MESSAGE, null);
91 latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS);
92 assertEquals(1, serviceExceptionCounter.get());
93 assertEquals(0, systemExceptionCounter.get());
94 MuleMessage response = client.request("vm://out7", 500);
95 assertNull(response);
96 }
97 }
98
99