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  import org.mule.api.client.MuleClient;
11  import org.mule.api.routing.filter.Filter;
12  import org.mule.message.ExceptionMessage;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertNotNull;
19  import static org.junit.Assert.assertTrue;
20  
21  public class ExceptionStrategyFilterMule5342TestCase extends FunctionalTestCase
22  {
23  
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/exceptions/exception-strategy-filter-mule-5342.xml";
28      }
29  
30      @Test
31      public void testExceptionThrownFromMessageFilterIsHandledByExceptionHandler() throws Exception
32      {
33          MuleClient client = muleContext.getClient();
34          client.send("vm://in", TEST_MESSAGE, null);
35          MuleMessage handleException = client.request("vm://handleException", RECEIVE_TIMEOUT);
36          assertNotNull(handleException);
37          assertTrue(handleException.getPayload() instanceof ExceptionMessage);
38          assertEquals(TEST_MESSAGE, ((ExceptionMessage) handleException.getPayload()).getPayload());
39      }
40      
41      public static class FalseFilter implements Filter
42      {
43          public boolean accept(MuleMessage message)
44          {
45              return false;
46          }
47      }
48  }