View Javadoc

1   /*
2    * $Id: InOutTestCase.java 22422 2011-07-15 08:22:16Z dirk.olmes $
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.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  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  
25  import static org.junit.Assert.assertEquals;
26  import static org.junit.Assert.assertNotNull;
27  
28  //START SNIPPET: full-class
29  public class InOutTestCase extends AbstractServiceAndFlowTestCase
30  {
31      public static final long TIMEOUT = 3000;
32  
33      @Parameters
34      public static Collection<Object[]> parameters()
35      {
36          return Arrays.asList(new Object[][]{
37              {ConfigVariant.SERVICE, "org/mule/test/integration/messaging/meps/pattern_In-Out-service.xml"},
38              {ConfigVariant.FLOW, "org/mule/test/integration/messaging/meps/pattern_In-Out-flow.xml"}});
39      }
40  
41      public InOutTestCase(ConfigVariant variant, String configResources)
42      {
43          super(variant, configResources);
44      }
45  
46      @Test
47      public void testExchange() throws Exception
48      {
49          MuleClient client = new MuleClient(muleContext);
50  
51          MuleMessage result = client.send("inboundEndpoint", "some data", null);
52          assertNotNull(result);
53          assertEquals("foo header not received", result.getPayloadAsString());
54  
55          Map<String, Object> props = new HashMap<String, Object>();
56          props.put("foo", "bar");
57          result = client.send("inboundEndpoint", "some data", props);
58          assertNotNull(result);
59          assertEquals("foo header received", result.getPayloadAsString());
60      }
61  }