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.properties;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  
14  import java.util.Collections;
15  
16  import org.hamcrest.core.IsNull;
17  import org.junit.Rule;
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertThat;
21  
22  public class HttpVmSessionPropertiesTestCase extends FunctionalTestCase
23  {
24      @Rule
25      public DynamicPort dynamicPort1 = new DynamicPort("port1");
26  
27      @Rule
28      public DynamicPort dynamicPort2 = new DynamicPort("port2");
29      
30      @Override
31      protected String getConfigResources()
32      {
33          return "org/mule/test/properties/session-properties-http-vm-config.xml";
34      }
35  
36      /**
37       * Test that the Session property are copied correctly from Http flow to VM flows transport
38       * correctly copies outbound to inbound property both for requests amd responses
39       */
40      @Test
41      public void testPropertiesFromHttpToVm() throws Exception
42      {
43          final MuleClient client = new MuleClient(muleContext);
44          MuleMessage message = client.send("http://localhost:" + dynamicPort1.getNumber() + "/http-inbound-flow", "some message", Collections.emptyMap());
45          assertThat(message, IsNull.<Object>notNullValue());
46          assertThat(message.getExceptionPayload(), IsNull.<Object>nullValue());
47      }
48  
49      /**
50       * Test that the Session property are copied correctly from VM flow to Http flows transport correctly copies outbound to inbound property both for requests amd responses
51       */
52      @Test
53      public void testPropertiesFromVmToHttp() throws Exception
54      {
55          final MuleClient client = new MuleClient(muleContext);
56          MuleMessage message = client.send("vm://vm-inbound-flow", "some message", Collections.emptyMap());
57          assertThat(message, IsNull.<Object>notNullValue());
58          assertThat(message.getExceptionPayload(), IsNull.<Object>nullValue());
59      }
60  }