View Javadoc

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