Package io.dropwizard.testing.junit
Class ResourceTestRule
- java.lang.Object
-
- io.dropwizard.testing.junit.ResourceTestRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class ResourceTestRule extends Object implements org.junit.rules.TestRule
A JUnitTestRule
for testing Jersey resources.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceTestRule.Builder
AResourceTestRule
builder which enables configuration of a Jersey testing environment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
static ResourceTestRule.Builder
builder()
Creates a new Jersey testing environment builder forResourceTestRule
javax.ws.rs.client.Client
client()
Returns the pre-configuredClient
for this test.Consumer<org.glassfish.jersey.client.ClientConfig>
getClientConfigurator()
org.glassfish.jersey.test.JerseyTest
getJerseyTest()
Returns the underlyingJerseyTest
.com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
javax.validation.Validator
getValidator()
javax.ws.rs.client.WebTarget
target(String path)
Creates a web target to be sent to the resource under testing.
-
-
-
Method Detail
-
builder
public static ResourceTestRule.Builder builder()
Creates a new Jersey testing environment builder forResourceTestRule
- Returns:
- a new
ResourceTestRule.Builder
-
getValidator
public javax.validation.Validator getValidator()
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
getClientConfigurator
public Consumer<org.glassfish.jersey.client.ClientConfig> getClientConfigurator()
-
target
public javax.ws.rs.client.WebTarget target(String path)
Creates a web target to be sent to the resource under testing.- Parameters:
path
- relative path (from tested application base URI) this web target should point to.- Returns:
- the created JAX-RS web target.
-
client
public javax.ws.rs.client.Client client()
Returns the pre-configuredClient
for this test. For sending requests prefertarget(String)
- Returns:
- the
JerseyTest
configuredClient
-
getJerseyTest
public org.glassfish.jersey.test.JerseyTest getJerseyTest()
Returns the underlyingJerseyTest
. For sending requests prefertarget(String)
.- Returns:
- the underlying
JerseyTest
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
-