1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.routing.replyto;
12
13 import org.hamcrest.core.Is;
14 import org.hamcrest.core.IsNull;
15 import org.junit.Test;
16 import org.mule.tck.functional.EventCallback;
17 import org.mule.tck.functional.FunctionalTestComponent;
18 import org.mule.tck.junit4.FunctionalTestCase;
19
20 import java.util.concurrent.TimeUnit;
21
22 import static org.junit.Assert.assertThat;
23
24 public class ReplyToChainIntegration5TestCase extends FunctionalTestCase
25 {
26
27 public static final String TEST_PAYLOAD = "test payload";
28 public static final String EXPECTED_PAYLOAD = TEST_PAYLOAD + " modified";
29 public static final int TIMEOUT = 5000;
30
31 @Override
32 protected String getConfigResources()
33 {
34 return "org/mule/test/integration/routing/replyto/replyto-chain-integration-test-5.xml";
35 }
36
37 @Test
38 public void testReplyToIsHonoredInFlowUsingAsyncBlock() throws Exception
39 {
40 org.mule.api.client.LocalMuleClient client = muleContext.getClient();
41 final org.mule.util.concurrent.Latch flowExecutedLatch = new org.mule.util.concurrent.Latch();
42 FunctionalTestComponent ftc = getFunctionalTestComponent("replierService");
43 ftc.setEventCallback(new EventCallback()
44 {
45 @Override
46 public void eventReceived(org.mule.api.MuleEventContext context, Object component) throws Exception
47 {
48 flowExecutedLatch.release();
49 }
50 });
51 org.mule.api.MuleMessage muleMessage = new org.mule.DefaultMuleMessage(TEST_PAYLOAD, muleContext);
52 muleMessage.setOutboundProperty(org.mule.api.config.MuleProperties.MULE_REPLY_TO_PROPERTY,"jms://response");
53 client.dispatch("jms://jmsIn1", muleMessage);
54 flowExecutedLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
55 org.mule.api.MuleMessage response = client.request("jms://response", TIMEOUT);
56 assertThat(response, IsNull.<Object>notNullValue());
57 assertThat(response.getPayloadAsString(), Is.is(EXPECTED_PAYLOAD));
58 }
59 }