| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Assert |
|
| 2.0;2 |
| 1 | package com.nexwerk.log4junit; | |
| 2 | ||
| 3 | import com.nexwerk.log4junit.log4j.JUnitAppender; | |
| 4 | ||
| 5 | /** | |
| 6 | * Extension to the <code>org.junit.Assert</code> class, offering assertions | |
| 7 | * common for asserting a Log4J log file (actually the appender). | |
| 8 | * | |
| 9 | * @author Enrique Comba Riepenhausen | |
| 10 | * Date: Nov 4, 2007 | |
| 11 | * Time: 10:13:31 AM | |
| 12 | */ | |
| 13 | public class Assert extends org.junit.Assert { | |
| 14 | ||
| 15 | /** | |
| 16 | * Asserts that the log level threshold has not been reched. | |
| 17 | * | |
| 18 | * @param appender The JUnitAppender on which we are meking the assertion. | |
| 19 | */ | |
| 20 | public static void assertLogThresholdNotReached(JUnitAppender appender) { | |
| 21 | 2 | if (appender.logLevelReached()) { |
| 22 | fail(); | |
| 23 | } | |
| 24 | 2 | } |
| 25 | ||
| 26 | /** | |
| 27 | * Asserts that the log level threshold has not been reched. | |
| 28 | * | |
| 29 | * @param message The message displayed in case the test fails. | |
| 30 | * @param appender The JUnitAppender on which we are meking the assertion. | |
| 31 | */ | |
| 32 | public static void assertLogThresholdNotReached(String message, | |
| 33 | JUnitAppender appender) { | |
| 34 | 1 | if (appender.logLevelReached()) { |
| 35 | fail(message); | |
| 36 | } | |
| 37 | 1 | } |
| 38 | ||
| 39 | /** | |
| 40 | * Asserts that the log level threshold has been reched. | |
| 41 | * | |
| 42 | * @param appender The JUnitAppender on which we are meking the assertion. | |
| 43 | */ | |
| 44 | public static void assertLogThresholdReached(JUnitAppender appender) { | |
| 45 | 2 | if (!appender.logLevelReached()) { |
| 46 | 1 | fail(); |
| 47 | } | |
| 48 | 1 | } |
| 49 | ||
| 50 | /** | |
| 51 | * Asserts that the log level threshold has been reched. | |
| 52 | * | |
| 53 | * @param message The message displayed in case the test fails. | |
| 54 | * @param appender The JUnitAppender on which we are meking the assertion. | |
| 55 | */ | |
| 56 | public static void assertLogThresholdReached(String message, | |
| 57 | JUnitAppender appender) { | |
| 58 | if (!appender.logLevelReached()) { | |
| 59 | fail(message); | |
| 60 | } | |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Asserts the content (i.e. the message) of the appender is the one we are | |
| 65 | * expecting it to be. | |
| 66 | * | |
| 67 | * @param message The message we are expecting. | |
| 68 | * @param appender The appender on which we are going to make the assertion. | |
| 69 | */ | |
| 70 | public static void assertLogMessageIs(String message, | |
| 71 | JUnitAppender appender) { | |
| 72 | 2 | if (!appender.getLogMessages().equals(message)) { |
| 73 | 2 | fail(); |
| 74 | } | |
| 75 | } | |
| 76 | } |