View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.net.server;
15  
16  import org.junit.jupiter.api.BeforeEach;
17  import org.junit.jupiter.api.Test;
18  
19  import ch.qos.logback.core.net.mock.MockContext;
20  import ch.qos.logback.core.spi.PreSerializationTransformer;
21  import ch.qos.logback.core.util.ExecutorServiceUtil;
22  
23  import static org.junit.jupiter.api.Assertions.assertNotNull;
24  
25  /**
26   * Unit tests for {@link SSLServerSocketAppenderBase}.
27   *
28   * @author Carl Harris
29   */
30  public class SSLServerSocketAppenderBaseTest {
31  
32      private MockContext context = new MockContext(ExecutorServiceUtil.newThreadPoolExecutor());
33  
34      @SuppressWarnings("rawtypes")
35      private SSLServerSocketAppenderBase appender = new InstrumentedSSLServerSocketAppenderBase();
36  
37      @BeforeEach
38      public void setUp() throws Exception {
39          appender.setContext(context);
40      }
41  
42      @Test
43      public void testUsingDefaultConfig() throws Exception {
44          // should be able to start successfully with no SSL configuration at all
45          appender.start();
46          assertNotNull(appender.getServerSocketFactory());
47          appender.stop();
48      }
49  
50      private static class InstrumentedSSLServerSocketAppenderBase extends SSLServerSocketAppenderBase<Object> {
51  
52          @Override
53          protected void postProcessEvent(Object event) {
54              throw new UnsupportedOperationException();
55          }
56  
57          @Override
58          protected PreSerializationTransformer<Object> getPST() {
59              throw new UnsupportedOperationException();
60          }
61  
62      }
63  
64  }