1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ssl;
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
19 import org.junit.Test;
20
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.fail;
23
24 public class SslConnectorTestCase extends AbstractConnectorTestCase
25 {
26 @Override
27 public Connector createConnector() throws Exception
28 {
29 SslConnector cnn = new SslConnector(muleContext);
30 cnn.setName("SslConnector");
31 cnn.setKeyStore("serverKeystore");
32 cnn.setClientKeyStore("clientKeystore");
33 cnn.setClientKeyStorePassword("mulepassword");
34 cnn.setKeyPassword("mulepassword");
35 cnn.setKeyStorePassword("mulepassword");
36 cnn.setTrustStore("trustStore");
37 cnn.setTrustStorePassword("mulepassword");
38 cnn.getDispatcherThreadingProfile().setDoThreading(false);
39 return cnn;
40 }
41
42 @Test
43 public void testClientConnector() throws Exception
44 {
45 SslConnector cnn = new SslConnector(muleContext);
46 cnn.setClientKeyStore("clientKeystore");
47 cnn.setClientKeyStorePassword("mulepassword");
48 cnn.getDispatcherThreadingProfile().setDoThreading(false);
49 }
50
51 @Override
52 public String getTestEndpointURI()
53 {
54 return "ssl://localhost:56801";
55 }
56
57 @Override
58 public Object getValidMessage() throws Exception
59 {
60 return "Hello".getBytes();
61 }
62
63 @Test
64 public void testValidListener() throws Exception
65 {
66 Service service = getTestService("orange", Orange.class);
67 Connector connector = getConnector();
68
69 InboundEndpoint endpoint2 =
70 muleContext.getEndpointFactory().getInboundEndpoint("ssl://localhost:30303");
71
72 connector.registerListener(endpoint2, getSensingNullMessageProcessor(), service);
73 try
74 {
75 connector.registerListener(endpoint2, getSensingNullMessageProcessor(), service);
76 fail("cannot register on the same endpointUri");
77 }
78 catch (Exception e)
79 {
80
81 }
82 }
83
84 @Test
85 public void testProperties() throws Exception
86 {
87 SslConnector c = (SslConnector)getConnector();
88
89 c.setSendBufferSize(1024);
90 assertEquals(1024, c.getSendBufferSize());
91 c.setSendBufferSize(0);
92 assertEquals(SslConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
93 }
94
95 }