View Javadoc

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