View Javadoc

1   /*
2    * $Id: HttpVmSessionPropertiesTestCase.java 22697 2011-08-18 05:21:25Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.properties;
12  
13  import org.hamcrest.core.IsNull;
14  import org.mule.api.MuleEventContext;
15  import org.mule.api.MuleMessage;
16  import org.mule.api.lifecycle.Callable;
17  import org.mule.module.client.MuleClient;
18  import org.mule.tck.DynamicPortTestCase;
19  import org.mule.tck.FunctionalTestCase;
20  
21  import java.util.Collections;
22  
23  import static org.hamcrest.core.Is.is;
24  import static org.junit.Assert.assertThat;
25  
26  public class HttpVmSessionPropertiesTestCase extends DynamicPortTestCase
27  {
28      @Override
29      protected String getConfigResources()
30      {
31          return "org/mule/test/properties/session-properties-http-vm-config.xml";
32      }
33  
34      /**
35       * Test that the Session property are copied correctly from Http flow to VM flows transport
36       * correctly copies outbound to inbound property both for requests amd responses
37       */
38      public void testPropertiesFromHttpToVm() throws Exception
39      {
40          final MuleClient client = new MuleClient(muleContext);
41          MuleMessage message = client.send("http://localhost:" + getPorts().get(0) + "/http-inbound-flow", "some message", Collections.emptyMap());
42          assertThat(message, IsNull.<Object>notNullValue());
43          assertThat(message.getExceptionPayload(), IsNull.<Object>nullValue());
44      }
45  
46      /**
47       * 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
48       */
49      public void testPropertiesFromVmToHttp() throws Exception
50      {
51          final MuleClient client = new MuleClient(muleContext);
52          MuleMessage message = client.send("vm://vm-inbound-flow", "some message", Collections.emptyMap());
53          assertThat(message, IsNull.<Object>notNullValue());
54          assertThat(message.getExceptionPayload(), IsNull.<Object>nullValue());
55      }
56  
57      @Override
58      protected int getNumPortsToFind()
59      {
60          return 2;
61      }
62  }