View Javadoc

1   /*
2    * $Id: HttpConnectorTestCase.java 20385 2010-11-29 20:25:26Z dfeist $
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;
12  
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.api.service.Service;
15  import org.mule.api.transport.Connector;
16  import org.mule.tck.testmodels.fruit.Orange;
17  import org.mule.transport.AbstractConnectorTestCase;
18  import org.mule.transport.tcp.TcpConnector;
19  
20  import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
21  
22  public class HttpConnectorTestCase extends AbstractConnectorTestCase
23  {
24  
25      @Override
26      public Connector createConnector() throws Exception
27      {
28          HttpConnector c = new HttpConnector(muleContext);
29          c.setName("HttpConnector");
30          return c;
31      }
32  
33      public String getTestEndpointURI()
34      {
35          return "http://localhost:60127";
36      }
37  
38      public Object getValidMessage() throws Exception
39      {
40          return "Hello".getBytes();
41      }
42  
43      public void testValidListener() throws Exception
44      {
45          Service service = getTestService("orange", Orange.class);
46          InboundEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint(
47              getTestEndpointURI());
48  
49          getConnector().registerListener(endpoint, getSensingNullMessageProcessor(), service);
50      }
51  
52      public void testProperties() throws Exception
53      {
54          HttpConnector c = (HttpConnector) getConnector();
55  
56          c.setSendBufferSize(1024);
57          assertEquals(1024, c.getSendBufferSize());
58          c.setSendBufferSize(0);
59          assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
60  
61          int maxDispatchers = c.getMaxTotalDispatchers();
62          HttpConnectionManagerParams params = c.getClientConnectionManager().getParams();
63          assertEquals(maxDispatchers, params.getDefaultMaxConnectionsPerHost());
64          assertEquals(maxDispatchers, params.getMaxTotalConnections());
65  
66          // all kinds of timeouts are now being tested in TcpConnectorTestCase
67      }
68  
69  }