1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.appender;
15
16 import ch.qos.logback.core.Appender;
17 import ch.qos.logback.core.Context;
18 import ch.qos.logback.core.ContextBase;
19 import ch.qos.logback.core.status.testUtil.StatusChecker;
20 import ch.qos.logback.core.util.StatusPrinter;
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23
24 abstract public class AbstractAppenderTest<E> {
25
26 abstract protected Appender<E> getAppender();
27
28 abstract protected Appender<E> getConfiguredAppender();
29
30 Context context = new ContextBase();
31
32 @Test
33 public void testNewAppender() {
34
35 Appender<E> appender = getAppender();
36 Assertions.assertFalse(appender.isStarted());
37 }
38
39 @Test
40 public void testConfiguredAppender() {
41 Appender<E> appender = getConfiguredAppender();
42 appender.start();
43 Assertions.assertTrue(appender.isStarted());
44
45 appender.stop();
46 Assertions.assertFalse(appender.isStarted());
47
48 }
49
50 @Test
51 public void testNoStart() {
52 Appender<E> appender = getAppender();
53 appender.setContext(context);
54 appender.setName("doh");
55
56 appender.doAppend(null);
57 StatusChecker checker = new StatusChecker(context.getStatusManager());
58 StatusPrinter.print(context);
59 checker.assertContainsMatch("Attempted to append to non started appender \\[doh\\].");
60 }
61 }