Package com.atlassian.confluence
Class ConfigureJohnson
java.lang.Object
org.junit.rules.ExternalResource
com.atlassian.confluence.ConfigureJohnson
- All Implemented Interfaces:
org.junit.rules.TestRule
public class ConfigureJohnson
extends org.junit.rules.ExternalResource
A
TestRule
that configures the Johnson framework before the test and tears it down
afterwards. You would typically configure it to run before and after your test class, as follows:
@ClassRule public static final TestRule johnsonRule = ConfigureJohnson.withDefaultConfiguration();
Or if you want to run it before and after each test method, do this:
@Rule public final TestRule johnsonRule = ConfigureJohnson.withDefaultConfiguration();
- Since:
- 6.6.0
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
protected void
before()
static @NonNull org.junit.rules.TestRule
withConfiguration
(@NonNull String location) Creates an instance of this rule in which Johnson uses the given configuration file.static @NonNull org.junit.rules.TestRule
withContext
(@NonNull javax.servlet.ServletContext context) Creates an instance of this rule in which Johnson uses the given context.static @NonNull org.junit.rules.TestRule
Creates an instance of this rule in which Johnson uses the default configuration file, namely"johnson-config.xml"
.Methods inherited from class org.junit.rules.ExternalResource
apply
-
Method Details
-
withDefaultConfiguration
public static @NonNull org.junit.rules.TestRule withDefaultConfiguration()Creates an instance of this rule in which Johnson uses the default configuration file, namely"johnson-config.xml"
.- Returns:
- see above
- See Also:
-
Johnson.initialize(String)
-
withConfiguration
Creates an instance of this rule in which Johnson uses the given configuration file. Only one of context or configuration file location must be given.- Parameters:
location
- the location of the Johnson configuration- Returns:
- see above
- See Also:
-
Johnson.initialize(String)
-
withContext
public static @NonNull org.junit.rules.TestRule withContext(@NonNull javax.servlet.ServletContext context) Creates an instance of this rule in which Johnson uses the given context. Only one of context or configuration file location must be given.- Parameters:
context
-- Returns:
- see above
- See Also:
-
Johnson.initialize(javax.servlet.ServletContext)
-
before
- Overrides:
before
in classorg.junit.rules.ExternalResource
- Throws:
Throwable
-
after
protected void after()- Overrides:
after
in classorg.junit.rules.ExternalResource
-