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