View Javadoc

1   /*
2    * $Id: AbstractPropertyScopeTestCase.java 22450 2011-07-19 08:20:41Z 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.message;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.client.LocalMuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  import org.mule.tck.junit4.rule.DynamicPort;
18  
19  import org.junit.Rule;
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  
24  public abstract class AbstractPropertyScopeTestCase extends AbstractServiceAndFlowTestCase
25  {
26      @Rule
27      public DynamicPort port1 = new DynamicPort("port1");
28  
29      public AbstractPropertyScopeTestCase(ConfigVariant variant, String configResources)
30      {
31          super(variant, configResources);
32      }
33  
34      @Test
35      public void testRequestResponse() throws Exception
36      {
37          LocalMuleClient client = muleContext.getClient();
38          MuleMessage message = new DefaultMuleMessage("test", muleContext);
39          message.setOutboundProperty("foo", "fooValue");
40  
41          MuleMessage result = client.send("inbound", message);
42          assertEquals("test bar", result.getPayloadAsString());
43          assertEquals("fooValue", result.<Object> getInboundProperty("foo"));
44      }
45  }