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 static org.junit.Assert.assertNotNull;
10  import static org.junit.Assert.assertTrue;
11  
12  import org.mule.api.MuleEvent;
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.client.MuleClient;
16  import org.mule.api.processor.MessageProcessor;
17  import org.mule.message.ExceptionMessage;
18  import org.mule.tck.junit4.FunctionalTestCase;
19  
20  import org.junit.Test;
21  
22  public class ExceptionStrategyWithFlowExceptionTestCase extends FunctionalTestCase
23  {
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/exceptions/exception-strategy-with-flow-exception.xml";
28      }
29  
30      @Test
31      public void testFlowExceptionExceptionStrategy() throws MuleException
32      {
33          MuleClient client = muleContext.getClient();
34          client.dispatch("vm://in", TEST_MESSAGE, null);
35          MuleMessage message = client.request("vm://out", RECEIVE_TIMEOUT);
36  
37          assertNotNull("request returned no message", message);
38          assertTrue(message.getPayload() instanceof ExceptionMessage);
39      }
40  
41      public static class ExceptionThrower implements MessageProcessor
42      {
43          public MuleEvent process(MuleEvent event) throws MuleException
44          {
45              throw new RuntimeException();
46          }
47      }
48  }