public class DropwizardClientExtension extends Object implements DropwizardExtension
Example:
@Path("/ping")
public static class PingResource {
@GET
public String ping() {
return "pong";
}
}
public static DropwizardClientExtension dropwizard = new DropwizardClientExtension(new PingResource());
@Test
public void shouldPing() throws IOException {
URL url = new URL(dropwizard.baseUri() + "/ping");
String response = new BufferedReader(new InputStreamReader(url.openStream())).readLine();
assertEquals("pong", response);
}
Of course, you'd use your http client, not URL.openStream().
The DropwizardClientExtension takes care of:
| Constructor and Description |
|---|
DropwizardClientExtension(Object... resources) |
| Modifier and Type | Method and Description |
|---|---|
void |
after()
Executed after test method or class.
|
URI |
baseUri() |
void |
before()
Executed before test method or class.
|
Environment |
getEnvironment() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
public DropwizardClientExtension(Object... resources)
public URI baseUri()
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public Environment getEnvironment()
public void before()
throws Throwable
DropwizardExtensionbefore in interface DropwizardExtensionThrowablepublic void after()
DropwizardExtensionafter in interface DropwizardExtensionCopyright © 2011. All rights reserved.