View Javadoc

1   /*
2    * $Id: HttpJmsBridgeTestCase.java 22431 2011-07-18 07:40:35Z 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.usecases.sync;
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  public class HttpJmsBridgeTestCase extends AbstractServiceAndFlowTestCase
29  {
30      @Parameters
31      public static Collection<Object[]> parameters()
32      {
33          return Arrays.asList(new Object[][]{
34              {ConfigVariant.SERVICE, "org/mule/test/usecases/sync/http-jms-bridge-service.xml"},
35              {ConfigVariant.FLOW, "org/mule/test/usecases/sync/http-jms-bridge-flow.xml"}
36          });
37      }
38  
39      public HttpJmsBridgeTestCase(ConfigVariant variant, String configResources)
40      {
41          super(variant, configResources);
42      }
43  
44      @Test
45      public void testBridge() throws Exception
46      {
47          MuleClient client = new MuleClient(muleContext);
48          String payload = "payload";
49  
50          Map<String, Object> headers = new HashMap<String, Object>();
51          final String customHeader = "X-Custom-Header";
52          headers.put(customHeader, "value");
53  
54          client.sendNoReceive("http://localhost:4444/in", payload, headers);
55  
56          MuleMessage msg = client.request("vm://out", 10000);
57          assertNotNull(msg);
58          assertEquals(payload, msg.getPayloadAsString());
59          assertEquals("value", msg.getInboundProperty(customHeader));
60      }
61  }