1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.components;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.AbstractServiceAndFlowTestCase;
16
17 import java.util.Arrays;
18 import java.util.Collection;
19
20 import org.junit.Test;
21 import org.junit.runners.Parameterized.Parameters;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26
27
28
29
30
31 public class NoArgsCallComponentTestCase extends AbstractServiceAndFlowTestCase
32 {
33 public static final String INPUT_DC_QUEUE_NAME = "vm://in";
34 public static final String OUTPUT_DC_QUEUE_NAME = "vm://out";
35 public static final String INPUT_DI_QUEUE_NAME = "vm://invokeWithInjected";
36 public static final String OUTPUT_DI_QUEUE_NAME = "vm://outWithInjected";
37
38 public static final String DEFAULT_INPUT_MESSAGE = "test";
39 public static final String DEFUALT_OUTPUT_MESSAGE = "Just an apple.";
40
41 public static final int TIMEOUT = 5000;
42
43 @Parameters
44 public static Collection<Object[]> parameters()
45 {
46 return Arrays.asList(new Object[][]{
47 {ConfigVariant.SERVICE, "org/mule/test/integration/components/no-args-call-component-functional-test-service.xml"},
48 {ConfigVariant.FLOW, "org/mule/test/integration/components/no-args-call-component-functional-test-flow.xml"}
49 });
50 }
51
52 public NoArgsCallComponentTestCase(ConfigVariant variant, String configResources)
53 {
54 super(variant, configResources);
55 }
56
57 @Test
58 public void testDelegateClass() throws Exception
59 {
60 MuleClient client = new MuleClient(muleContext);
61 client.dispatch(INPUT_DC_QUEUE_NAME, "test", null);
62 MuleMessage message = client.request(OUTPUT_DC_QUEUE_NAME, TIMEOUT);
63 assertNotNull(message);
64 assertEquals(message.getPayload(), DEFUALT_OUTPUT_MESSAGE);
65 client.dispose();
66 }
67
68 @Test
69 public void testWithInjectedDelegate() throws Exception
70 {
71 MuleClient client = new MuleClient(muleContext);
72 client.dispatch(INPUT_DI_QUEUE_NAME, DEFAULT_INPUT_MESSAGE, null);
73 MuleMessage reply = client.request(OUTPUT_DI_QUEUE_NAME, TIMEOUT);
74 assertNotNull(reply);
75 assertNull(reply.getExceptionPayload());
76
77 assertEquals(DEFAULT_INPUT_MESSAGE, reply.getPayload());
78 }
79 }