View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
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.assertNull;
16  
17  public class SynchronousMessagingExceptionStrategyTestCase extends AbstractExceptionStrategyTestCase
18  {
19  
20      @Override
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/exceptions/synch-messaging-exception-strategy.xml";
24      }
25  
26      @Test
27      public void testInboundTransformer() throws Exception
28      {
29          client.send("vm://in1", TEST_MESSAGE, null);
30          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
31          assertEquals(1, serviceExceptionCounter.get());
32          assertEquals(0, systemExceptionCounter.get());
33      }
34      
35      @Test
36      public void testInboundResponseTransformer() throws Exception
37      {
38          client.send("vm://in2", TEST_MESSAGE, null);
39          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
40          assertEquals(1, serviceExceptionCounter.get());
41          assertEquals(0, systemExceptionCounter.get());
42      }
43      
44      @Test
45      public void testOutboundTransformer() throws Exception
46      {
47          client.send("vm://in3", TEST_MESSAGE, null);
48          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
49          assertEquals(1, serviceExceptionCounter.get());
50          assertEquals(0, systemExceptionCounter.get());
51          MuleMessage response = client.request("vm://out3", 500);
52          assertNull(response);
53      }
54      
55      @Test
56      public void testOutboundResponseTransformer() throws Exception
57      {
58          client.send("vm://in4", TEST_MESSAGE, null);
59          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
60          assertEquals(1, serviceExceptionCounter.get());
61          assertEquals(0, systemExceptionCounter.get());
62          MuleMessage response = client.request("vm://out4", 500);
63          assertNull(response);
64      }
65      
66      @Test
67      public void testComponent() throws Exception
68      {
69          client.send("vm://in5", TEST_MESSAGE, null);
70          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
71          assertEquals(1, serviceExceptionCounter.get());
72          assertEquals(0, systemExceptionCounter.get());
73      }
74  
75      @Test
76      public void testInboundRouter() throws Exception
77      {
78          client.send("vm://in6", TEST_MESSAGE, null);
79          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
80          assertEquals(1, serviceExceptionCounter.get());
81          assertEquals(0, systemExceptionCounter.get());
82      }
83      
84      @Test
85      public void testOutboundRouter() throws Exception
86      {
87          client.send("vm://in7", TEST_MESSAGE, null);
88          latch.await(LATCH_AWAIT_TIMEOUT, TimeUnit.MILLISECONDS); 
89          assertEquals(1, serviceExceptionCounter.get());
90          assertEquals(0, systemExceptionCounter.get());
91          MuleMessage response = client.request("vm://out7", 500);
92          assertNull(response);
93      }    
94  }
95  
96