View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.messaging.meps;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import java.util.HashMap;
14  import java.util.Map;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertNull;
21  
22  public class InOnlyOptionalOutTestCase extends FunctionalTestCase
23  {
24  
25      public static final long TIMEOUT = 3000;
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "org/mule/test/integration/messaging/meps/pattern_In-Only_Optional-Out.xml";
31      }
32  
33      @Test
34      public void testExchange() throws Exception
35      {
36          MuleClient client = new MuleClient(muleContext);
37  
38          client.dispatch("inboundEndpoint", "some data", null);
39          Map props = new HashMap();
40          props.put("foo", "bar");
41          client.dispatch("inboundEndpoint", "some data", props);
42  
43          MuleMessage result = client.request("receivedEndpoint", TIMEOUT);
44          assertNotNull(result);
45          assertEquals("foo header received", result.getPayloadAsString());
46  
47          result = client.request("notReceivedEndpoint", TIMEOUT);
48          assertNull(result);
49      }
50  }