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;
15  
16  import org.junit.jupiter.api.Assertions;
17  import org.junit.jupiter.api.BeforeEach;
18  import org.junit.jupiter.api.Test;
19  
20  import ch.qos.logback.core.net.mock.MockContext;
21  import ch.qos.logback.core.spi.PreSerializationTransformer;
22  
23  /**
24   * Unit tests for {@link AbstractSSLSocketAppender}.
25   *
26   * @author Carl Harris
27   */
28  public class AbstractSSLSocketAppenderTest {
29  
30      private MockContext context = new MockContext();
31  
32      private InstrumentedSSLSocketAppenderBase appender = new InstrumentedSSLSocketAppenderBase();
33  
34      @BeforeEach
35      public void setUp() throws Exception {
36          appender.setContext(context);
37      }
38  
39      @Test
40      public void testUsingDefaultConfig() throws Exception {
41          // should be able to start and stop successfully with no SSL
42          // configuration at all
43          appender.start();
44          Assertions.assertNotNull(appender.getSocketFactory());
45          appender.stop();
46      }
47  
48      private static class InstrumentedSSLSocketAppenderBase extends AbstractSSLSocketAppender<Object> {
49  
50          @Override
51          protected void postProcessEvent(Object event) {
52              throw new UnsupportedOperationException();
53          }
54  
55          @Override
56          protected PreSerializationTransformer<Object> getPST() {
57              throw new UnsupportedOperationException();
58          }
59  
60      }
61  }