public class LogCaptureFeature extends Object implements RunnerFeature
LogCaptureFeature.FilterOn
or a custom one implementing LogCaptureFeature.Filter
class can be
provided with the annotation LogCaptureFeature.FilterWith
to select the log events to capture.
A LogCaptureFeature.Result
instance is to be injected with Inject
as an attribute of the
test.
The method LogCaptureFeature.Result.assertHasEvent()
can then be called from test methods to check that
matching log calls (events) have been captured.Modifier and Type | Class and Description |
---|---|
protected static class |
LogCaptureFeature.DefaultFilter
Default Nuxeo filter which takes a logger name and a log level to accept only events matching both.
|
static interface |
LogCaptureFeature.Filter |
static interface |
LogCaptureFeature.FilterOn |
static interface |
LogCaptureFeature.FilterWith |
static class |
LogCaptureFeature.NoLogCaptureFilterException |
static class |
LogCaptureFeature.Result
Log result class.
|
Modifier and Type | Field and Description |
---|---|
protected LogCaptureFeature.Filter |
classFilter
Filter defined on class.
|
protected LogCaptureFeature.Filter |
currentFilter
Filter used when appending a log to
appender . |
protected org.apache.logging.log4j.core.Appender |
logAppender
A Log4j
Appender added to LoggerContext at beginning of tests. |
protected LogCaptureFeature.Filter |
methodFilter
Filter defined on method.
|
protected LogCaptureFeature.Result |
myResult |
Constructor and Description |
---|
LogCaptureFeature() |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
configure(FeaturesRunner runner,
com.google.inject.Binder binder)
Configures Guice bindings if any is required by the feature.
|
protected LogCaptureFeature.Filter |
instantiateFilter(Supplier<LogCaptureFeature.FilterWith> filterWith,
Supplier<LogCaptureFeature.FilterOn> filterOn) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterTeardown, beforeSetup, initialize, start, stop, testCreated
protected LogCaptureFeature.Filter classFilter
protected LogCaptureFeature.Filter methodFilter
protected volatile LogCaptureFeature.Filter currentFilter
appender
.protected final LogCaptureFeature.Result myResult
protected final org.apache.logging.log4j.core.Appender logAppender
Appender
added to LoggerContext
at beginning of tests.public LogCaptureFeature()
public void beforeRun(FeaturesRunner runner) throws Exception
RunnerFeature
beforeRun
in interface RunnerFeature
Exception
public void configure(FeaturesRunner runner, com.google.inject.Binder binder)
RunnerFeature
configure
in interface RunnerFeature
public void beforeMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test) throws Exception
RunnerFeature
beforeMethodRun
in interface RunnerFeature
Exception
public void afterMethodRun(FeaturesRunner runner, org.junit.runners.model.FrameworkMethod method, Object test)
RunnerFeature
afterMethodRun
in interface RunnerFeature
public void afterRun(FeaturesRunner runner)
RunnerFeature
afterRun
in interface RunnerFeature
protected LogCaptureFeature.Filter instantiateFilter(Supplier<LogCaptureFeature.FilterWith> filterWith, Supplier<LogCaptureFeature.FilterOn> filterOn) throws Exception
Exception
Copyright © 2019 Nuxeo. All rights reserved.