View Javadoc

1   /*
2    * $Id: MessagingExceptionComponentTestCase.java 20121 2010-11-08 17:33:48Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.module.jbpm;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.client.MuleClient;
15  import org.mule.api.transformer.TransformerException;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.tck.exceptions.FunctionalTestException;
18  import org.mule.util.ExceptionUtils;
19  
20  public class MessagingExceptionComponentTestCase extends FunctionalTestCase
21  {
22      protected String getConfigResources()
23      {
24          return "jbpm-component-functional-test.xml";
25      }
26  
27      public void testNoException() throws Exception
28      {
29          MuleClient client = muleContext.getClient();
30          client.send("vm://exception", "testNoException", null);                                  
31  
32          // Both messages should have been sent.
33          assertNotNull(client.request("vm://queueC", 1000));            
34          assertNotNull(client.request("vm://queueD", 1000));            
35      }
36  
37      public void testExceptionInService() throws Exception
38      {
39          MuleClient client = muleContext.getClient();
40          
41          MuleMessage response = client.send("vm://exception", "testExceptionInService", null);                      
42          assertNotNull("Should have thrown an exception", response.getExceptionPayload());
43          assertTrue(ExceptionUtils.getRootCause(response.getExceptionPayload().getException()) instanceof FunctionalTestException);
44          
45          // The first message should have been sent, but not the second one.
46          assertNotNull(client.request("vm://queueC", 1000));            
47          assertNull(client.request("vm://queueD", 1000));            
48      }
49  
50      public void testExceptionInTransformer() throws Exception
51      {
52          MuleClient client = muleContext.getClient();
53          
54          MuleMessage response = client.send("vm://exception", "testExceptionInTransformer", null);                      
55          assertNotNull("Should have thrown an exception", response.getExceptionPayload());
56          assertTrue(ExceptionUtils.getRootCause(response.getExceptionPayload().getException()) instanceof TransformerException);
57          
58          // The first message should have been sent, but not the second one.
59          assertNotNull(client.request("vm://queueC", 1000));            
60          assertNull(client.request("vm://queueD", 1000));            
61      }
62  }