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.appender;
15  
16  import static org.junit.Assert.assertEquals;
17  
18  import java.io.ByteArrayOutputStream;
19  import java.io.IOException;
20  
21  import org.junit.Test;
22  
23  import ch.qos.logback.core.Appender;
24  import ch.qos.logback.core.encoder.DummyEncoder;
25  import ch.qos.logback.core.encoder.Encoder;
26  import ch.qos.logback.core.layout.DummyLayout;
27  
28  public class DummyAppenderTest extends AbstractAppenderTest<Object> {
29  
30      ByteArrayOutputStream baos = new ByteArrayOutputStream();
31      DummyWriterAppender<Object> da = new DummyWriterAppender<Object>(baos);
32  
33      protected Appender<Object> getAppender() {
34          return da;
35      }
36  
37      protected Appender<Object> getConfiguredAppender() {
38          da.setEncoder(new DummyEncoder<Object>());
39          da.start();
40          return da;
41      }
42  
43      @Test
44      public void testBasic() throws IOException {
45          Encoder<Object> encoder = new DummyEncoder<Object>();
46          da.setEncoder(encoder);
47          da.start();
48          da.doAppend(new Object());
49          assertEquals(DummyLayout.DUMMY, baos.toString());
50      }
51  
52  }