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.appender;
015
016import static org.junit.Assert.assertEquals;
017
018import java.io.ByteArrayOutputStream;
019import java.io.IOException;
020
021import org.junit.Test;
022
023import ch.qos.logback.core.Appender;
024import ch.qos.logback.core.encoder.DummyEncoder;
025import ch.qos.logback.core.encoder.Encoder;
026import ch.qos.logback.core.layout.DummyLayout;
027
028public class DummyAppenderTest extends AbstractAppenderTest<Object> {
029
030    ByteArrayOutputStream baos = new ByteArrayOutputStream();
031    DummyWriterAppender<Object> da = new DummyWriterAppender<Object>(baos);
032
033    protected Appender<Object> getAppender() {
034        return da;
035    }
036
037    protected Appender<Object> getConfiguredAppender() {
038        da.setEncoder(new DummyEncoder<Object>());
039        da.start();
040        return da;
041    }
042
043    @Test
044    public void testBasic() throws IOException {
045        Encoder<Object> encoder = new DummyEncoder<Object>();
046        da.setEncoder(encoder);
047        da.start();
048        da.doAppend(new Object());
049        assertEquals(DummyLayout.DUMMY, baos.toString());
050    }
051
052}