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 import org.mule.api.client.MuleClient;
15 import org.mule.api.routing.filter.Filter;
16 import org.mule.api.routing.filter.FilterUnacceptedException;
17 import org.mule.api.transport.DispatchException;
18 import org.mule.tck.junit4.FunctionalTestCase;
19 import org.mule.util.ExceptionUtils;
20
21 import org.junit.Test;
22
23 import static org.junit.Assert.assertTrue;
24
25 public class ExceptionStrategyFilterMule5342TestCase extends FunctionalTestCase
26 {
27 @Override
28 protected String getConfigResources()
29 {
30 return "org/mule/test/integration/exceptions/exception-strategy-filter-mule-5342.xml";
31 }
32
33 @Test
34 public void exceptionThrownFromMessageFilterIsHandledByExceptionHandler() throws Exception
35 {
36 try
37 {
38 MuleClient client = muleContext.getClient();
39 client.send("vm://in", TEST_MESSAGE, null);
40 }
41 catch (DispatchException e)
42 {
43 assertThatRootCauseIsFilterUnacceptedException(e);
44 }
45 }
46
47 private void assertThatRootCauseIsFilterUnacceptedException(DispatchException e)
48 {
49 int index = ExceptionUtils.indexOfThrowable(e, FilterUnacceptedException.class);
50 assertTrue(index > -1);
51 }
52
53 public static class FalseFilter implements Filter
54 {
55 @Override
56 public boolean accept(MuleMessage message)
57 {
58 return false;
59 }
60 }
61 }