1
2
3
4
5
6
7 package org.mule.test.integration.components;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12
13 import org.junit.Test;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertNull;
18
19
20
21
22
23 public class NoArgsCallComponentTestCase extends FunctionalTestCase
24 {
25
26 public static final String INPUT_DC_QUEUE_NAME = "vm://in";
27 public static final String OUTPUT_DC_QUEUE_NAME = "vm://out";
28 public static final String INPUT_DI_QUEUE_NAME = "vm://invokeWithInjected";
29 public static final String OUTPUT_DI_QUEUE_NAME = "vm://outWithInjected";
30
31 public static final String DEFAULT_INPUT_MESSAGE = "test";
32 public static final String DEFUALT_OUTPUT_MESSAGE = "Just an apple.";
33
34 public static final int TIMEOUT = 5000;
35
36 @Override
37 protected String getConfigResources()
38 {
39 return "org/mule/test/integration/components/no-args-call-component-functional-test.xml";
40 }
41
42 @Test
43 public void testDelegateClass() throws Exception
44 {
45 MuleClient client = new MuleClient(muleContext);
46 client.dispatch(INPUT_DC_QUEUE_NAME, "test", null);
47 MuleMessage message = client.request(OUTPUT_DC_QUEUE_NAME, TIMEOUT);
48 assertNotNull(message);
49 assertEquals(message.getPayload(), DEFUALT_OUTPUT_MESSAGE);
50 client.dispose();
51 }
52
53 @Test
54 public void testWithInjectedDelegate() throws Exception
55 {
56 MuleClient client = new MuleClient(muleContext);
57 client.dispatch(INPUT_DI_QUEUE_NAME, DEFAULT_INPUT_MESSAGE, null);
58 MuleMessage reply = client.request(OUTPUT_DI_QUEUE_NAME, TIMEOUT);
59 assertNotNull(reply);
60 assertNull(reply.getExceptionPayload());
61
62 assertEquals(DEFAULT_INPUT_MESSAGE, reply.getPayload());
63 }
64
65 }