View Javadoc

1   /*
2    * $Id: ExceptionStrategyWithFlowExceptionTestCase.java 23129 2011-10-07 01:45:53Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.assertNotNull;
14  import static org.junit.Assert.assertTrue;
15  
16  import org.mule.api.MuleEvent;
17  import org.mule.api.MuleException;
18  import org.mule.api.MuleMessage;
19  import org.mule.api.client.MuleClient;
20  import org.mule.api.processor.MessageProcessor;
21  import org.mule.message.ExceptionMessage;
22  import org.mule.tck.junit4.FunctionalTestCase;
23  
24  import org.junit.Test;
25  
26  public class ExceptionStrategyWithFlowExceptionTestCase extends FunctionalTestCase
27  {
28      @Override
29      protected String getConfigResources()
30      {
31          return "org/mule/test/integration/exceptions/exception-strategy-with-flow-exception.xml";
32      }
33  
34      @Test
35      public void testFlowExceptionExceptionStrategy() throws MuleException
36      {
37          MuleClient client = muleContext.getClient();
38          client.dispatch("vm://in", TEST_MESSAGE, null);
39          MuleMessage message = client.request("vm://out", RECEIVE_TIMEOUT);
40  
41          assertNotNull("request returned no message", message);
42          assertTrue(message.getPayload() instanceof ExceptionMessage);
43      }
44  
45      public static class ExceptionThrower implements MessageProcessor
46      {
47          public MuleEvent process(MuleEvent event) throws MuleException
48          {
49              throw new RuntimeException();
50          }
51      }
52  }