View Javadoc

1   /*
2    * $Id: ChunkingTestCase.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.MuleMessage;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.DynamicPortTestCase;
17  import org.mule.transport.http.HttpConnector;
18  
19  public class ChunkingTestCase extends DynamicPortTestCase
20  {
21  
22      protected String getConfigResources()
23      {
24          return "chunking-test.xml";
25      }
26  
27      public void testPartiallyReadRequest() throws Exception
28      {
29          MuleClient client = new MuleClient(muleContext);
30          
31          byte[] msg = new byte[100*1024];
32          
33          MuleMessage result = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inMain")).getAddress(), 
34              msg, null);
35          assertEquals("Hello", result.getPayloadAsString());
36          int status = result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0);
37          assertEquals(200, status);
38          
39          result = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inMain")).getAddress(),
40              msg, null);
41          assertEquals("Hello", result.getPayloadAsString());
42          status = result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0);
43          assertEquals(200, status);
44      }
45  
46      @Override
47      protected int getNumPortsToFind()
48      {
49          return 1;
50      }
51  
52  }
53  
54