1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.http;
12
13 import org.mule.impl.MuleDescriptor;
14 import org.mule.impl.endpoint.MuleEndpointURI;
15 import org.mule.providers.tcp.TcpConnector;
16 import org.mule.tck.providers.AbstractConnectorTestCase;
17 import org.mule.tck.testmodels.fruit.Orange;
18 import org.mule.umo.UMOComponent;
19 import org.mule.umo.endpoint.UMOEndpoint;
20 import org.mule.umo.provider.UMOConnector;
21
22 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
23
24 public class HttpConnectorTestCase extends AbstractConnectorTestCase
25 {
26
27
28 public UMOConnector createConnector() throws Exception
29 {
30 HttpConnector c = new HttpConnector();
31 c.setName("HttpConnector");
32 c.initialise();
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 public void testValidListener() throws Exception
47 {
48 HttpConnector connector = (HttpConnector) getConnector();
49
50 MuleDescriptor d = getTestDescriptor("orange", Orange.class.getName());
51 UMOComponent component = getTestComponent(d);
52 UMOEndpoint endpoint = getTestEndpoint("Test", UMOEndpoint.ENDPOINT_TYPE_RECEIVER);
53 endpoint.setEndpointURI(null);
54 endpoint.setConnector(connector);
55
56 try
57 {
58 connector.registerListener(component, endpoint);
59 fail("cannot register with null endpointUri");
60 }
61 catch (Exception e)
62 {
63
64 }
65
66 endpoint.setEndpointURI(null);
67 try
68 {
69 connector.registerListener(component, endpoint);
70 fail("cannot register with empty endpointUri");
71 }
72 catch (Exception e)
73 {
74
75 }
76
77 endpoint.setEndpointURI(new MuleEndpointURI("http://localhost:0"));
78 connector.registerListener(component, endpoint);
79 try
80 {
81 connector.registerListener(component, endpoint);
82 fail("cannot register on the same endpointUri");
83 }
84 catch (Exception e)
85 {
86
87 }
88
89 connector.dispose();
90 }
91
92 public void testProperties() throws Exception
93 {
94 HttpConnector c = (HttpConnector) getConnector();
95
96 c.setSendBufferSize(1024);
97 assertEquals(1024, c.getSendBufferSize());
98 c.setSendBufferSize(0);
99 assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
100
101 int maxThreadsActive = c.getDispatcherThreadingProfile().getMaxThreadsActive();
102 HttpConnectionManagerParams params = c.getClientConnectionManager().getParams();
103 assertEquals(maxThreadsActive, params.getDefaultMaxConnectionsPerHost());
104 assertEquals(maxThreadsActive, params.getMaxTotalConnections());
105
106 c.dispose();
107
108
109 }
110
111 }