use of org.glassfish.jersey.test.JerseyTest in project dropwizard by dropwizard.
the class ResourceTestRule method apply.
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration);
try {
test = new JerseyTest() {
@Override
protected TestContainerFactory getTestContainerFactory() {
return configuration.testContainerFactory;
}
@Override
protected DeploymentContext configureDeployment() {
return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)).initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()).initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()).build();
}
@Override
protected void configureClient(ClientConfig clientConfig) {
final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(configuration.mapper);
configuration.clientConfigurator.accept(clientConfig);
clientConfig.register(jsonProvider);
}
};
test.setUp();
base.evaluate();
} finally {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.remove(configuration.getId());
test.tearDown();
}
}
};
}
use of org.glassfish.jersey.test.JerseyTest in project dropwizard by dropwizard.
the class DropwizardResourceConfigBenchmark method setUp.
@Setup
public void setUp() throws Exception {
dropwizardResourceConfig.register(DistributionResource.class);
dropwizardResourceConfig.register(AssetResource.class);
dropwizardResourceConfig.register(ClustersResource.class);
final JerseyTest jerseyTest = new JerseyTest() {
@Override
protected Application configure() {
return dropwizardResourceConfig;
}
};
jerseyTest.setUp();
jerseyTest.tearDown();
}
use of org.glassfish.jersey.test.JerseyTest in project dropwizard by dropwizard.
the class Resource method before.
public void before() throws Throwable {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration);
test = new JerseyTest(configuration.testContainerFactory) {
@Override
protected URI getBaseUri() {
forceSet(TestProperties.CONTAINER_PORT, "0");
return super.getBaseUri();
}
@Override
protected DeploymentContext configureDeployment() {
return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)).initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()).initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()).build();
}
@Override
protected void configureClient(ClientConfig clientConfig) {
final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(configuration.mapper);
configuration.clientConfigurator.accept(clientConfig);
clientConfig.register(jsonProvider);
}
};
test.setUp();
}
Aggregations