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.transformer.TransformerMessagingException;
11  import org.mule.message.ExceptionMessage;
12  import org.mule.module.client.MuleClient;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertTrue;
19  
20  public class ExceptionsWithRouterMule2715TestCase extends FunctionalTestCase
21  {
22  
23      public static final String MESSAGE = "message";
24      public static final long TIMEOUT = 5000L;
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/exceptions/exceptions-with-router-mule-2715.xml";
30      }
31  
32      @Test
33      public void testWithRouter() throws Exception
34      {
35          doTest("with-router-in");
36      }
37  
38      @Test
39      public void testWithoutRouter() throws Exception
40      {
41          doTest("without-router-in");
42      }
43  
44      protected void doTest(String path) throws Exception
45      {
46          MuleClient client = new MuleClient(muleContext);
47          client.dispatch("vm://" + path, MESSAGE, null);
48          MuleMessage response = client.request("vm://error", TIMEOUT);
49          assertNotNull(response);
50          assertTrue(response.getPayload() instanceof ExceptionMessage);
51          assertTrue(((ExceptionMessage) response.getPayload()).getException() instanceof TransformerMessagingException);
52      }
53  
54  }