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.testUtil;
15  
16  import ch.qos.logback.core.Context;
17  import ch.qos.logback.core.status.StatusManager;
18  import ch.qos.logback.core.status.StatusUtil;
19  
20  import static org.junit.Assert.assertTrue;
21  import static org.junit.Assert.assertFalse;
22  
23  /**
24   * Extend  StatusUtil with assertions.
25   */
26  public class StatusChecker extends StatusUtil {
27  
28      public StatusChecker(StatusManager sm) {
29          super(sm);
30      }
31  
32      public StatusChecker(Context context) {
33          super(context);
34      }
35  
36      public void assertContainsMatch(int level, String regex) {
37          assertTrue(containsMatch(level, regex));
38      }
39  
40      public void assertNoMatch(String regex) {
41          assertFalse(containsMatch(regex));
42      }
43      
44      public void assertContainsMatch(String regex) {
45          assertTrue(containsMatch(regex));
46      }
47  
48      public void asssertContainsException(Class<?> scanExceptionClass) {
49          assertTrue(containsException(scanExceptionClass));
50      }
51  
52      public void assertIsErrorFree() {
53          assertTrue(isErrorFree(0));
54      }
55  
56      public void assertIsWarningOrErrorFree() {
57          assertTrue(isWarningOrErrorFree(0));
58      }
59  }