Package org.nuxeo.runtime.test.runner
Class LogFeature
java.lang.Object
org.nuxeo.runtime.test.runner.LogFeature
- All Implemented Interfaces:
RunnerFeature
- Since:
- 9.3
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected org.apache.logging.log4j.core.appender.ConsoleAppenderprotected org.apache.logging.log4j.core.appender.ConsoleAppenderprotected Map<LoggerLevelKey,LogFeature.LoggerLightConfig> 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAppendersFromRefs(org.apache.logging.log4j.core.config.LoggerConfig loggerConfig, org.apache.logging.log4j.core.config.Configuration configuration) protected voidaddConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method) Adds the console threshold log level.protected voidaddOrUpdateLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method) Adds or updates the logger level.voidafterMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test) After a test method was ran.voidbeforeMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test) Before a test method is invoked.protected LoggerLevelKeybuildKey(LoggerLevel logger, org.junit.runners.model.FrameworkMethod method) Builds the logger key.protected StringgetLoggerName(LoggerLevel logLevel) Gets the logger name from a givenLoggerLevel.voidDeprecated, for removal: This API element is subject to removal in a future version.since 11.1.voidDeprecated, for removal: This API element is subject to removal in a future version.since 11.1.voidinitialize(FeaturesRunner runner) Called when preparing to run the test class.voidprotected voidrestoreConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method) Restores the console threshold log level.protected voidrestoreLoggerLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method) Restores the original value of the logger level.voidsetConsoleLogThreshold(String level) voidstop(FeaturesRunner runner) Before exiting the test.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.runtime.test.runner.RunnerFeature
afterRun, afterTeardown, afterTeardown, beforeRun, beforeSetup, beforeSetup, configure, start, testCreated
-
Field Details
-
CONSOLE_APPENDER
- See Also:
-
CONSOLE_LOG_FEATURE_APPENDER
- See Also:
-
consoleAppender
protected org.apache.logging.log4j.core.appender.ConsoleAppender consoleAppender -
originalConfigurationByLogger
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
-
-
Constructor Details
-
LogFeature
public LogFeature()
-
-
Method Details
-
initialize
Called when preparing to run the test class. Framework is not started at this point. Here is time for the feature to configure the runner from annotations on the test class.- Specified by:
initializein interfaceRunnerFeature- Since:
- 11.1
-
stop
Before exiting the test.- Specified by:
stopin 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:
beforeMethodRunin 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:
afterMethodRunin interfaceRunnerFeature- Since:
- 11.1
-
hideWarningFromConsoleLog
Deprecated, for removal: This API element is subject to removal in a future version. -
hideErrorFromConsoleLog
Deprecated, for removal: This API element is subject to removal in a future version.- Since:
- 9.10
-
setConsoleLogThreshold
- 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/Methodshould be annotated by- Parameters:
runner- the feature runner, cannot benullmethod- the framework method, can benull- Since:
- 11.1
- See Also:
-
restoreConsoleThresholdLogLevel
protected void restoreConsoleThresholdLogLevel(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method) Restores the console threshold log level. Based on ifClassorMethodis 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
LoggerLevelcan be done on a givenClass/Methodtest. 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 benullmethod- 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 benullmethod- the framework method, can benull- Since:
- 11.1
-
addAppendersFromRefs
protected void addAppendersFromRefs(org.apache.logging.log4j.core.config.LoggerConfig loggerConfig, org.apache.logging.log4j.core.config.Configuration configuration) -
getLoggerName
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
-