1
2
3
4
5
6
7 package org.mule.transport.http;
8
9 import org.mule.tck.junit4.FunctionalTestCase;
10 import org.mule.tck.junit4.rule.DynamicPort;
11 import org.mule.tck.testmodels.mule.TestExceptionStrategy;
12 import org.mule.tck.testmodels.mule.TestExceptionStrategy.ExceptionCallback;
13 import org.mule.transport.ConnectException;
14
15 import org.junit.Rule;
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20
21 public class HttpsInvalidKeystoreTestCase extends FunctionalTestCase implements ExceptionCallback
22 {
23 @Rule
24 public DynamicPort port1 = new DynamicPort("port1");
25
26 private Throwable exceptionFromSystemExceptionHandler;
27
28 public HttpsInvalidKeystoreTestCase()
29 {
30 super();
31 setStartContext(false);
32 }
33
34 @Override
35 protected String getConfigResources()
36 {
37 return "https-invalid-keystore-config.xml";
38 }
39
40 @Test
41 public void startingSslMessageReceiverWithoutKeystoreShouldThrowConnectException() throws Exception
42 {
43 TestExceptionStrategy exceptionListener = new TestExceptionStrategy();
44 exceptionListener.setExceptionCallback(this);
45
46 muleContext.setExceptionListener(exceptionListener);
47 muleContext.start();
48
49 assertNotNull(exceptionFromSystemExceptionHandler);
50 assertTrue(exceptionFromSystemExceptionHandler instanceof ConnectException);
51 assertTrue(exceptionFromSystemExceptionHandler.getMessage().contains("tls-key-store"));
52 }
53
54 public void onException(Throwable t)
55 {
56 exceptionFromSystemExceptionHandler = t;
57 }
58 }
59
60