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.core.net.server;
015
016import static org.junit.Assert.assertNotNull;
017
018import org.junit.Before;
019import org.junit.Test;
020
021import ch.qos.logback.core.net.mock.MockContext;
022import ch.qos.logback.core.spi.PreSerializationTransformer;
023import ch.qos.logback.core.util.ExecutorServiceUtil;
024
025/**
026 * Unit tests for {@link SSLServerSocketAppenderBase}.
027 *
028 * @author Carl Harris
029 */
030public class SSLServerSocketAppenderBaseTest {
031
032    private MockContext context = new MockContext(ExecutorServiceUtil.newScheduledExecutorService());
033
034    @SuppressWarnings("rawtypes")
035    private SSLServerSocketAppenderBase appender = new InstrumentedSSLServerSocketAppenderBase();
036
037    @Before
038    public void setUp() throws Exception {
039        appender.setContext(context);
040    }
041
042    @Test
043    public void testUsingDefaultConfig() throws Exception {
044        // should be able to start successfully with no SSL configuration at all
045        appender.start();
046        assertNotNull(appender.getServerSocketFactory());
047        appender.stop();
048    }
049
050    private static class InstrumentedSSLServerSocketAppenderBase extends SSLServerSocketAppenderBase<Object> {
051
052        @Override
053        protected void postProcessEvent(Object event) {
054            throw new UnsupportedOperationException();
055        }
056
057        @Override
058        protected PreSerializationTransformer<Object> getPST() {
059            throw new UnsupportedOperationException();
060        }
061
062    }
063
064}