1
2
3
4
5
6
7 package org.mule.transport.http;
8
9 import org.mule.api.MuleContext;
10 import org.mule.api.endpoint.InboundEndpoint;
11 import org.mule.api.lifecycle.InitialisationException;
12 import org.mule.api.service.Service;
13 import org.mule.api.transport.Connector;
14 import org.mule.tck.testmodels.fruit.Orange;
15 import org.mule.transport.AbstractConnectorTestCase;
16 import org.mule.transport.tcp.TcpConnector;
17
18 import java.io.IOException;
19
20 import org.junit.Test;
21
22 import static org.junit.Assert.assertEquals;
23
24
25 public class HttpsConnectorTestCase extends AbstractConnectorTestCase
26 {
27
28 @Override
29 public Connector createConnector() throws Exception
30 {
31 return createConnector(muleContext, false);
32 }
33
34 public static HttpsConnector createConnector(MuleContext context, boolean initialised)
35 throws IOException, InitialisationException
36 {
37 HttpsConnector cnn = new HttpsConnector(muleContext);
38 cnn.setName("HttpsConnector");
39 cnn.setKeyStore("serverKeystore");
40 cnn.setClientKeyStore("clientKeystore");
41 cnn.setClientKeyStorePassword("mulepassword");
42 cnn.setKeyPassword("mulepassword");
43 cnn.setKeyStorePassword("mulepassword");
44 cnn.setTrustStore("trustStore");
45 cnn.setTrustStorePassword("mulepassword");
46 cnn.getDispatcherThreadingProfile().setDoThreading(false);
47
48 if (initialised)
49 {
50 cnn.initialise();
51 }
52 return cnn;
53 }
54
55 public String getTestEndpointURI()
56 {
57 return "https://localhost:60127";
58 }
59
60 public Object getValidMessage() throws Exception
61 {
62 return "Hello".getBytes();
63 }
64
65 @Test
66 public void testValidListener() throws Exception
67 {
68 Service service = getTestService("orange", Orange.class);
69 InboundEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint(
70 getTestEndpointURI());
71
72 getConnector().registerListener(endpoint, getSensingNullMessageProcessor(), service);
73 }
74
75 @Test
76 public void testProperties() throws Exception
77 {
78 HttpsConnector c = (HttpsConnector)getConnector();
79
80 c.setSendBufferSize(1024);
81 assertEquals(1024, c.getSendBufferSize());
82 c.setSendBufferSize(0);
83 assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
84
85
86 }
87 }