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.MuleException;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.message.ExceptionMessage;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertNotNull;
19  import static org.junit.Assert.assertNull;
20  
21  public class DLQExceptionHandlerTestCase extends FunctionalTestCase
22  {
23  
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/exceptions/exception-dlq.xml";
28      }
29  
30      @Test
31      public void testDLQ() throws Exception
32      {
33          MuleClient client = new MuleClient(muleContext);
34          client.dispatch("jms://request.queue", "testing 1 2 3", null);
35  
36          MuleMessage message = client.request("jms://out.queue", 3000);
37          assertNull(message);
38  
39          try
40          {
41              message = client.request("jms://DLQ", 20000);
42          }
43          catch (MuleException e)
44          {
45              e.printStackTrace(System.err);
46          }
47          assertNotNull(message);
48  
49          ExceptionMessage em = (ExceptionMessage)message.getPayload();
50          assertEquals("testing 1 2 3", em.getPayload());
51      }
52  }