View Javadoc

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