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 java.io.ByteArrayOutputStream;
17  import java.io.IOException;
18  
19  import org.junit.jupiter.api.Test;
20  
21  import ch.qos.logback.core.Appender;
22  import ch.qos.logback.core.testUtil.DummyEncoder;
23  import ch.qos.logback.core.encoder.Encoder;
24  import ch.qos.logback.core.layout.DummyLayout;
25  
26  import static org.junit.jupiter.api.Assertions.assertEquals;
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  }