View Javadoc

1   /*
2    * $Id: InOutAsyncTestCase.java 22551 2011-07-25 06:32:00Z mike.schilling $
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.test.integration.messaging.meps;
12  
13  import org.junit.runners.Parameterized;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.config.MuleProperties;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.AbstractServiceAndFlowTestCase;
18  import org.mule.tck.junit4.FunctionalTestCase;
19  
20  import java.util.Arrays;
21  import java.util.Collection;
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertEquals;
28  import static org.junit.Assert.assertNotNull;
29  
30  public class InOutAsyncTestCase extends AbstractServiceAndFlowTestCase
31  {
32  
33      public static final long TIMEOUT = 3000;
34  
35       @Parameterized.Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              { ConfigVariant.SERVICE, "org/mule/test/integration/messaging/meps/pattern_In-Out-Async.xml" } ,
40              { ConfigVariant.FLOW, "org/mule/test/integration/messaging/meps/pattern_In-Out-Async-flow.xml"}
41          });
42      }
43  
44      public InOutAsyncTestCase(ConfigVariant variant, String configResources)
45      {
46          super(variant, configResources);
47      }
48  
49      @Test
50      public void testExchange() throws Exception
51      {
52          MuleClient client = new MuleClient(muleContext);
53          Map props = new HashMap();
54          //Almost any endpoint can be used here
55          props.put(MuleProperties.MULE_REPLY_TO_PROPERTY, "jms://client-reply");
56  
57          MuleMessage result = client.send("inboundEndpoint", "some data", props);
58          assertNotNull(result);
59          assertEquals("got it!", result.getPayloadAsString());
60  
61          final Object foo = result.getInboundProperty("foo");
62          assertNotNull(foo);
63          assertEquals("bar", foo);
64      }
65  }