public class DropwizardClientRule
extends org.junit.rules.ExternalResource
Example:
@Path("/ping")
public static class PingResource {
@GET
public String ping() {
return "pong";
}
}
@ClassRule
public static DropwizardClientRule dropwizard = new DropwizardClientRule(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 DropwizardClientRule takes care of:
| Constructor and Description |
|---|
DropwizardClientRule(Object... resources) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
URI |
baseUri() |
protected void |
before() |
public DropwizardClientRule(Object... resources)
Copyright © 2015. All rights reserved.