View Javadoc

1   /*
2    * $Id: SessionPropertiesTestCase.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.transport.http.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.DynamicPortTestCase;
16  import org.mule.tck.FunctionalTestCase;
17  
18  import java.util.Collections;
19  
20  public class SessionPropertiesTestCase extends DynamicPortTestCase
21  {
22  
23      @Override
24      protected String getConfigResources() {
25          return "session-properties.xml";
26      }
27  
28      public void testHttp1ToHttp2ToHttp3SessionPropertiesTestCase() throws Exception
29      {
30          final MuleClient client = new MuleClient(muleContext);
31          MuleMessage response = client.send("http://localhost:" + getPorts().get(0) + "/Flow1s1", "some message", Collections.emptyMap());
32          assertNotNullAndNotExceptionResponse(response);
33      }
34  
35      public void testHttp1ToHttp2ThenHttp1ToHttp3SessionPropertiesTestCase() throws Exception
36      {
37          final MuleClient client = new MuleClient(muleContext);
38          MuleMessage response = client.send("http://localhost:" + getPorts().get(3) + "/Flow1s2", "some message", Collections.emptyMap());
39          assertNotNullAndNotExceptionResponse(response);
40      }
41  
42      private void assertNotNullAndNotExceptionResponse(MuleMessage response)
43      {
44          assertNotNull(response);
45          if (response.getExceptionPayload() != null)
46          {
47              fail(response.getExceptionPayload().getException().getCause().toString());
48          }
49      }
50  
51  
52      @Override
53      protected int getNumPortsToFind()
54      {
55          return 6;
56      }
57  }