View Javadoc

1   /*
2    * $Id: MessagingExceptionTestCase.java 19708 2010-09-23 14:18:11Z 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.transport.jbpm;
12  
13  import org.mule.api.transformer.TransformerException;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.tck.exceptions.FunctionalTestException;
17  
18  /**
19   * @deprecated It is recommended to configure BPM as a component rather than a transport for 3.x
20   */
21  public class MessagingExceptionTestCase extends FunctionalTestCase
22  {
23      protected String getConfigResources()
24      {
25          return "jbpm-functional-test.xml";
26      }
27  
28      public void testNoException() throws Exception
29      {
30          MuleClient client = new MuleClient(muleContext);
31          client.send("bpm://exception", "testNoException", null);                                  
32  
33          // Both messages should have been sent.
34          assertNotNull(client.request("vm://queueC", 1000));            
35          assertNotNull(client.request("vm://queueD", 1000));            
36      }
37  
38      public void testExceptionInService() throws Exception
39      {
40          MuleClient client = new MuleClient(muleContext);
41          try
42          {
43              client.send("bpm://exception", "testExceptionInService", null);                      
44              fail("Should have thrown an exception");
45          }
46          catch (Exception e)
47          {
48              assertTrue(e.getCause().getCause().getCause() instanceof FunctionalTestException);
49          }
50          
51          // The first message should have been sent, but not the second one.
52          assertNotNull(client.request("vm://queueC", 1000));            
53          assertNull(client.request("vm://queueD", 1000));            
54      }
55  
56      public void testExceptionInTransformer() throws Exception
57      {
58          MuleClient client = new MuleClient(muleContext);
59          try
60          {
61              client.send("bpm://exception", "testExceptionInTransformer", null);                      
62              fail("Should have thrown an exception");
63          }
64          catch (Exception e)
65          {
66              assertTrue(e.getCause().getCause().getCause() instanceof TransformerException);
67          }
68          
69          // The first message should have been sent, but not the second one.
70          assertNotNull(client.request("vm://queueC", 1000));            
71          assertNull(client.request("vm://queueD", 1000));            
72      }
73  }