001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.net.server;
015
016import static org.junit.Assert.assertNotNull;
017import static org.junit.Assert.assertTrue;
018
019import javax.net.ServerSocketFactory;
020
021import org.junit.Before;
022import org.junit.Test;
023
024import ch.qos.logback.core.net.mock.MockContext;
025
026/**
027 * Unit tests for {@link SSLServerSocketReceiver}.
028 *
029 * @author Carl Harris
030 */
031public class SSLServerSocketReceiverTest {
032
033    private MockContext context = new MockContext();
034
035    private MockSSLConfiguration ssl = new MockSSLConfiguration();
036
037    private MockSSLParametersConfiguration parameters = new MockSSLParametersConfiguration();
038
039    private SSLServerSocketReceiver receiver = new SSLServerSocketReceiver();
040
041    @Before
042    public void setUp() throws Exception {
043        receiver.setContext(context);
044        receiver.setSsl(ssl);
045        ssl.setParameters(parameters);
046    }
047
048    @Test
049    public void testGetServerSocketFactory() throws Exception {
050        ServerSocketFactory socketFactory = receiver.getServerSocketFactory();
051        assertNotNull(socketFactory);
052        assertTrue(ssl.isContextCreated());
053        assertTrue(parameters.isContextInjected());
054    }
055
056}