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