View Javadoc

1   /*
2    * $Id: Http10FunctionalTestCase.java 20297 2010-11-22 18:49:18Z aperepel $
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.functional;
12  
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.DynamicPortTestCase;
16  import org.mule.transport.http.HttpConstants;
17  
18  import org.apache.commons.httpclient.HttpClient;
19  import org.apache.commons.httpclient.HttpVersion;
20  import org.apache.commons.httpclient.methods.GetMethod;
21  import org.apache.commons.httpclient.params.HttpClientParams;
22  
23  /**
24   * Tests as per http://www.io.com/~maus/HttpKeepAlive.html
25   */
26  public class Http10FunctionalTestCase extends DynamicPortTestCase
27  {
28      private HttpClient setupHttpClient()
29      {
30          HttpClientParams params = new HttpClientParams();
31          params.setVersion(HttpVersion.HTTP_1_0);
32          return new HttpClient(params);
33      }
34  
35      @Override
36      protected String getConfigResources()
37      {
38          return "http-10-config.xml";
39      }
40      
41      public void testHttp10EnforceNonChunking() throws Exception
42      {
43          HttpClient client = setupHttpClient();
44          MuleClient muleClient = new MuleClient(muleContext);
45          GetMethod request = new GetMethod(((InboundEndpoint) muleClient.getMuleContext().getRegistry().lookupObject("inStreaming")).getAddress());
46          client.executeMethod(request);
47          assertEquals("hello", request.getResponseBodyAsString());
48          
49          assertNull(request.getResponseHeader(HttpConstants.HEADER_TRANSFER_ENCODING));
50          assertNotNull(request.getResponseHeader(HttpConstants.HEADER_CONTENT_LENGTH));
51      }
52  
53      @Override
54      protected int getNumPortsToFind()
55      {
56          return 1;
57      }
58  }