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.testUtil; 015 016import ch.qos.logback.core.Context; 017import ch.qos.logback.core.status.StatusManager; 018import ch.qos.logback.core.status.StatusUtil; 019 020import static org.junit.Assert.assertTrue; 021import static org.junit.Assert.assertFalse; 022 023/** 024 * Extend StatusUtil with assertions. 025 */ 026public class StatusChecker extends StatusUtil { 027 028 public StatusChecker(StatusManager sm) { 029 super(sm); 030 } 031 032 public StatusChecker(Context context) { 033 super(context); 034 } 035 036 public void assertContainsMatch(int level, String regex) { 037 assertTrue(containsMatch(level, regex)); 038 } 039 040 public void assertNoMatch(String regex) { 041 assertFalse(containsMatch(regex)); 042 } 043 044 public void assertContainsMatch(String regex) { 045 assertTrue(containsMatch(regex)); 046 } 047 048 public void asssertContainsException(Class<?> scanExceptionClass) { 049 assertTrue(containsException(scanExceptionClass)); 050 } 051 052 public void assertIsErrorFree() { 053 assertTrue(isErrorFree(0)); 054 } 055 056 public void assertIsWarningOrErrorFree() { 057 assertTrue(isWarningOrErrorFree(0)); 058 } 059}