View Javadoc

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