public abstract class MockLogAppender extends Object
MockLogAppender class. If you do not specify the log level specifically, the level
will default to DEBUG. You can control the level by using the setupLogging(boolean, String)
or setupLogging(boolean, String, Properties)
methods.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_LOG_LEVEL |
Constructor and Description |
---|
MockLogAppender() |
Modifier and Type | Method and Description |
---|---|
static void |
addEvent(LoggingEvent loggingEvent) |
static void |
assertLogAtLevel(Level level)
assertLogAtLevel
|
static void |
assertLogMatched(Level level,
String message) |
static void |
assertNoErrorOrGreater() |
static void |
assertNoFatalOrGreater() |
static void |
assertNoLogging() |
static void |
assertNoLogMatched(Level level,
String message) |
static void |
assertNotGreaterOrEqual(Level level)
assertNotGreaterOrEqual
|
static void |
assertNoWarningsOrGreater()
assertNoWarningsOrGreater
|
static LoggingEvent[] |
getEvents()
getEvents
|
static LoggingEvent[] |
getEventsAtLevel(Level level)
getEventsAtLevel
|
static LoggingEvent[] |
getEventsGreaterOrEqual(Level level)
getEventsGreaterOrEqual
|
static boolean |
noWarningsOrHigherLogged()
noWarningsOrHigherLogged
|
static void |
resetState()
resetEvents
|
static void |
setupLogging()
setupLogging
|
static void |
setupLogging(boolean toConsole)
setupLogging
|
static void |
setupLogging(boolean toConsole,
Properties props)
setupLogging
|
static void |
setupLogging(boolean toConsole,
String level)
setupLogging
|
static void |
setupLogging(boolean toConsole,
String level,
Properties config)
setupLogging
|
static void |
setupLogging(Properties config)
setupLogging
|
public static final String DEFAULT_LOG_LEVEL
public static void resetState()
resetEvents
public static LoggingEvent[] getEvents()
getEvents
public static LoggingEvent[] getEventsGreaterOrEqual(Level level)
getEventsGreaterOrEqual
public static LoggingEvent[] getEventsAtLevel(Level level)
getEventsAtLevel
Returns events that were logged at the specified levelpublic static void setupLogging()
setupLogging
public static void setupLogging(Properties config)
setupLogging
config
- a Properties
object.public static void setupLogging(boolean toConsole)
setupLogging
toConsole
- a boolean.public static void setupLogging(boolean toConsole, Properties props)
setupLogging
toConsole
- a boolean.props
- a Properties
object.public static void setupLogging(boolean toConsole, String level)
setupLogging
toConsole
- a boolean.level
- a String
object.public static void setupLogging(boolean toConsole, String level, Properties config)
setupLogging
toConsole
- a boolean.level
- a String
object.config
- a Properties
object.public static boolean noWarningsOrHigherLogged()
noWarningsOrHigherLogged
public static void assertNotGreaterOrEqual(Level level) throws junit.framework.AssertionFailedError
assertNotGreaterOrEqual
junit.framework.AssertionFailedError
- if any.public static void assertNoWarningsOrGreater() throws junit.framework.AssertionFailedError
assertNoWarningsOrGreater
junit.framework.AssertionFailedError
- if any.public static void assertNoErrorOrGreater() throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
public static void assertNoFatalOrGreater() throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
public static void assertLogAtLevel(Level level) throws junit.framework.AssertionFailedError
assertLogAtLevel
Asserts that a message was logged at the requested level. Useful for testing code that *should* have logged an error message (or a notice or some other special case)junit.framework.AssertionFailedError
- if any.public static void addEvent(LoggingEvent loggingEvent)
public static void assertNoLogging() throws junit.framework.AssertionFailedError
junit.framework.AssertionFailedError
Copyright © 2021. All rights reserved.