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.classic.net.server;
15  
16  import javax.net.ServerSocketFactory;
17  
18  import org.junit.jupiter.api.BeforeEach;
19  
20  import ch.qos.logback.core.net.mock.MockContext;
21  import org.junit.jupiter.api.Test;
22  
23  import static org.junit.jupiter.api.Assertions.assertNotNull;
24  import static org.junit.jupiter.api.Assertions.assertTrue;
25  
26  /**
27   * Unit tests for {@link SSLServerSocketReceiver}.
28   *
29   * @author Carl Harris
30   */
31  public class SSLServerSocketReceiverTest {
32  
33      private MockContext context = new MockContext();
34  
35      private MockSSLConfiguration ssl = new MockSSLConfiguration();
36  
37      private MockSSLParametersConfiguration parameters = new MockSSLParametersConfiguration();
38  
39      private SSLServerSocketReceiver receiver = new SSLServerSocketReceiver();
40  
41      @BeforeEach
42      public void setUp() throws Exception {
43          receiver.setContext(context);
44          receiver.setSsl(ssl);
45          ssl.setParameters(parameters);
46      }
47  
48      @Test
49      public void testGetServerSocketFactory() throws Exception {
50          ServerSocketFactory socketFactory = receiver.getServerSocketFactory();
51          assertNotNull(socketFactory);
52          assertTrue(ssl.isContextCreated());
53          assertTrue(parameters.isContextInjected());
54      }
55  
56  }