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