1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jbpm;
12
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertTrue;
16
17 import org.mule.api.MuleMessage;
18 import org.mule.api.client.MuleClient;
19 import org.mule.api.transformer.TransformerException;
20 import org.mule.tck.AbstractServiceAndFlowTestCase;
21 import org.mule.tck.exceptions.FunctionalTestException;
22 import org.mule.util.ExceptionUtils;
23
24 import java.util.Arrays;
25 import java.util.Collection;
26
27 import org.junit.Test;
28 import org.junit.runners.Parameterized.Parameters;
29
30 public class MessagingExceptionComponentTestCase extends AbstractServiceAndFlowTestCase
31 {
32 public MessagingExceptionComponentTestCase(ConfigVariant variant, String configResources)
33 {
34 super(variant, configResources);
35 }
36
37 @Parameters
38 public static Collection<Object[]> parameters()
39 {
40 return Arrays.asList(new Object[][]{
41 {ConfigVariant.SERVICE, "jbpm-component-functional-test-flow.xml"},
42 {ConfigVariant.FLOW, "jbpm-component-functional-test-service.xml"}});
43 }
44
45 @Test
46 public void testNoException() throws Exception
47 {
48 MuleClient client = muleContext.getClient();
49 client.send("vm://exception", "testNoException", null);
50
51
52 assertNotNull(client.request("vm://queueC", 1000));
53 assertNotNull(client.request("vm://queueD", 1000));
54 }
55
56 @Test
57 public void testExceptionInService() throws Exception
58 {
59 MuleClient client = muleContext.getClient();
60 MuleMessage result = client.send("vm://exception", "testExceptionInService", null);
61 assertNotNull(result);
62 assertNotNull(result.getExceptionPayload());
63 assertTrue(ExceptionUtils.getRootCause(result.getExceptionPayload().getException()) instanceof FunctionalTestException);
64
65
66 assertNotNull(client.request("vm://queueC", 1000));
67 assertNull(client.request("vm://queueD", 1000));
68 }
69
70 @Test
71 public void testExceptionInTransformer() throws Exception
72 {
73 MuleClient client = muleContext.getClient();
74
75 MuleMessage result = client.send("vm://exception", "testExceptionInTransformer", null);
76 assertNotNull(result);
77 assertNotNull(result.getExceptionPayload());
78 assertTrue(ExceptionUtils.getRootCause(result.getExceptionPayload().getException()) instanceof TransformerException);
79
80
81 assertNotNull(client.request("vm://queueC", 1000));
82 assertNull(client.request("vm://queueD", 1000));
83 }
84 }