Package org.nuxeo.runtime.test.runner
Class LogFeature
- java.lang.Object
-
- org.nuxeo.runtime.test.runner.LogFeature
-
- All Implemented Interfaces:
RunnerFeature
public class LogFeature extends Object implements RunnerFeature
- Since:
- 9.3
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
CONSOLE_APPENDER
protected static String
CONSOLE_LOG_FEATURE_APPENDER
protected org.apache.logging.log4j.core.appender.ConsoleAppender
consoleAppender
protected org.apache.logging.log4j.core.appender.ConsoleAppender
hiddenAppender
protected Map<LoggerLevelKey,org.apache.logging.log4j.Level>
originalLevelByLogger
Stores the original log level for a given logger name, which allows us to restore the level as defined before launching the tests.
-
Constructor Summary
Constructors Constructor Description LogFeature()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Adds the console threshold log level.protected void
addOrUpdateLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Adds or updates the logger level.void
afterMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test)
After a test method was ran.void
afterRun(FeaturesRunner runner)
After tests were run.void
beforeMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test)
Before a test method is invoked.void
beforeRun(FeaturesRunner runner)
Before running tests.protected LoggerLevelKey
buildKey(LoggerLevel logger, org.junit.runners.model.FrameworkMethod method)
Builds the logger key.protected String
getLoggerName(LoggerLevel logLevel)
Gets the logger name from a givenLoggerLevel
.void
hideErrorFromConsoleLog()
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1.void
hideWarningFromConsoleLog()
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1.void
restoreConsoleLog()
protected void
restoreConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Restores the console threshold log level.protected void
restoreLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Restores the original value of the logger level.void
setConsoleLogThreshold(String level)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.test.runner.RunnerFeature
afterTeardown, afterTeardown, beforeSetup, beforeSetup, configure, initialize, start, stop, testCreated
-
-
-
-
Field Detail
-
CONSOLE_APPENDER
protected static final String CONSOLE_APPENDER
- See Also:
- Constant Field Values
-
CONSOLE_LOG_FEATURE_APPENDER
protected static final String CONSOLE_LOG_FEATURE_APPENDER
- See Also:
- Constant Field Values
-
consoleAppender
protected org.apache.logging.log4j.core.appender.ConsoleAppender consoleAppender
-
hiddenAppender
protected org.apache.logging.log4j.core.appender.ConsoleAppender hiddenAppender
-
originalLevelByLogger
protected Map<LoggerLevelKey,org.apache.logging.log4j.Level> originalLevelByLogger
Stores the original log level for a given logger name, which allows us to restore the level as defined before launching the tests.- Since:
- 11.1
-
-
Method Detail
-
beforeRun
public void beforeRun(FeaturesRunner runner)
Before running tests. At this point Guice modules are registered and injector created.- Specified by:
beforeRun
in interfaceRunnerFeature
- Since:
- 11.1
-
afterRun
public void afterRun(FeaturesRunner runner)
After tests were run.- Specified by:
afterRun
in interfaceRunnerFeature
- Since:
- 11.1
-
beforeMethodRun
public void beforeMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test)
Before a test method is invoked.- Specified by:
beforeMethodRun
in interfaceRunnerFeature
- Since:
- 11.1
-
afterMethodRun
public void afterMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test)
After a test method was ran.- Specified by:
afterMethodRun
in interfaceRunnerFeature
- Since:
- 11.1
-
hideWarningFromConsoleLog
@Deprecated(since="11.1", forRemoval=true) public void hideWarningFromConsoleLog()
Deprecated, for removal: This API element is subject to removal in a future version.
-
hideErrorFromConsoleLog
@Deprecated(since="11.1", forRemoval=true) public void hideErrorFromConsoleLog()
Deprecated, for removal: This API element is subject to removal in a future version.- Since:
- 9.10
-
setConsoleLogThreshold
public void setConsoleLogThreshold(String level)
- Since:
- 9.10
-
restoreConsoleLog
public void restoreConsoleLog()
-
addConsoleThresholdLogLevel
protected void addConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Adds the console threshold log level. To be proceed aClass
/Method
should be annotated by- Parameters:
runner
- the feature runner, cannot benull
method
- the framework method, can benull
- Since:
- 11.1
- See Also:
ConsoleLogLevelThreshold
,setConsoleLogThreshold(String)
-
restoreConsoleThresholdLogLevel
protected void restoreConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Restores the console threshold log level. Based on ifClass
orMethod
is annotated byConsoleLogLevelThreshold
.- Since:
- 11.1
-
addOrUpdateLoggerLevel
protected void addOrUpdateLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Adds or updates the logger level.The definition of
LoggerLevel
can be done on a givenClass
/Method
test. At the end of the test each overriding logger must be restored to its original value for this the purpose we should save the original level.restoreLoggerLevel(FeaturesRunner, FrameworkMethod)
to see how the restore part will be happened.- Parameters:
runner
- the feature runner, cannot benull
method
- the framework method, can benull
- Since:
- 11.1
-
restoreLoggerLevel
protected void restoreLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method)
Restores the original value of the logger level.addOrUpdateLoggerLevel(FeaturesRunner, FrameworkMethod)
} to see how we store the original value and set the new one.- Parameters:
runner
- the feature runner, cannot benull
method
- the framework method, can benull
- Since:
- 11.1
-
getLoggerName
protected String getLoggerName(LoggerLevel logLevel)
Gets the logger name from a givenLoggerLevel
.- Since:
- 11.1
-
buildKey
protected LoggerLevelKey buildKey(LoggerLevel logger, org.junit.runners.model.FrameworkMethod method)
Builds the logger key.- Since:
- 11.1
-
-