View Javadoc

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