public abstract class AbstractExternalResourceTestSupport<R>
extends java.lang.Object
implements org.junit.rules.TestRule
Rule
s that detect the presence of some external resource. If the resource is
indeed present, it will be available during the test lifecycle through getResource()
. If it is not, tests
will either fail or be skipped, depending on the value of system property "XD_EXTERNAL_SERVERS_REQUIRED".Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
protected R |
resource |
static java.lang.String |
XD_EXTERNAL_SERVERS_REQUIRED |
Modifier | Constructor and Description |
---|---|
protected |
AbstractExternalResourceTestSupport(java.lang.String resourceDescription) |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
protected abstract void |
cleanupResource()
Perform cleanup of the
resource field, which is guaranteed to be non null. |
R |
getResource() |
protected abstract void |
obtainResource()
Try to obtain and validate a resource.
|
public static final java.lang.String XD_EXTERNAL_SERVERS_REQUIRED
protected R resource
protected final org.slf4j.Logger logger
protected AbstractExternalResourceTestSupport(java.lang.String resourceDescription)
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
public R getResource()
protected abstract void cleanupResource() throws java.lang.Exception
resource
field, which is guaranteed to be non null.java.lang.Exception
- any exception thrown by this method will be logged and swallowedprotected abstract void obtainResource() throws java.lang.Exception
resource
field with a valid
resource and return normally, or throw an exception.java.lang.Exception