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.transport.http;
8   
9   import org.mule.tck.junit4.FunctionalTestCase;
10  import org.mule.tck.junit4.rule.DynamicPort;
11  
12  import org.apache.commons.httpclient.HttpClient;
13  import org.apache.commons.httpclient.methods.GetMethod;
14  import org.junit.Rule;
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  
19  public class HttpsFlowTestCase extends FunctionalTestCase
20  {
21  
22      @Rule
23      public DynamicPort dynamicPort = new DynamicPort("port1");
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "https-flow-config.xml";
29      }
30  
31      @Test
32      public void testSecureFlow() throws Exception
33      {
34          String url = String.format("https://localhost:%1d/?message=Hello", dynamicPort.getNumber());
35  
36          GetMethod method = new GetMethod(url);
37          HttpClient client = new HttpClient();
38  
39          int responseCode = client.executeMethod(method);
40          assertEquals(HttpConstants.SC_OK, responseCode);
41  
42          String result = method.getResponseBodyAsString();
43          assertEquals("/?message=Hello received", result);
44      }
45  }
46  
47