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