View Javadoc

1   /*
2    * $Id: HttpsFlowTestCase.java 20209 2010-11-17 14:41:36Z 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.transport.http;
12  
13  import org.mule.tck.DynamicPortTestCase;
14  
15  import org.apache.commons.httpclient.HttpClient;
16  import org.apache.commons.httpclient.methods.GetMethod;
17  
18  public class HttpsFlowTestCase extends DynamicPortTestCase
19  {
20      @Override
21      protected String getConfigResources()
22      {
23          return "https-flow-config.xml";
24      }
25  
26      @Override
27      protected int getNumPortsToFind()
28      {
29          return 1;
30      }
31  
32      public void testSecureFlow() throws Exception
33      {
34          String url = String.format("https://localhost:%1d/?message=Hello", getPorts().get(0));
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