View Javadoc

1   /*
2    * $Id: ExceptionStrategyWithCustomExpressionEvaluatorTestCase.java 22993 2011-09-19 21:22:08Z 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 org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.client.MuleClient;
16  import org.mule.api.expression.ExpressionEvaluator;
17  import org.mule.message.ExceptionMessage;
18  import org.mule.tck.junit4.FunctionalTestCase;
19  
20  import static org.junit.Assert.assertNotNull;
21  import static org.junit.Assert.assertTrue;
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertNotNull;
25  import static org.junit.Assert.assertTrue;
26  
27  public class ExceptionStrategyWithCustomExpressionEvaluatorTestCase extends FunctionalTestCase
28  {
29      @Override
30      protected String getConfigResources()
31      {
32          return "org/mule/test/integration/exceptions/exception-strategy-with-custom-expression-evaluator.xml";
33      }
34  
35      @Test
36      public void testCustomExpressionEvaluatorExceptionStrategy() throws MuleException
37      {
38          MuleClient client = muleContext.getClient();
39          client.dispatch("vm://in", TEST_MESSAGE, null);
40          MuleMessage message = client.request("vm://out", RECEIVE_TIMEOUT);
41  
42          assertNotNull("request returned no message", message);
43          assertTrue(message.getPayload() instanceof ExceptionMessage);
44      }
45  
46      public static class FooExpressionEvaluator implements ExpressionEvaluator
47      {
48          public Object evaluate(String expression, MuleMessage message)
49          {
50              throw new UnsupportedOperationException("evaluate");
51          }
52  
53          public void setName(String name)
54          {
55              throw new UnsupportedOperationException("setName");
56          }
57  
58          public String getName()
59          {
60              return "Foo";
61          }
62      }
63  }