DropwizardClientExtension
.@Deprecated 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)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
after()
Deprecated.
|
URI |
baseUri()
Deprecated.
|
protected void |
before()
Deprecated.
|
Environment |
getEnvironment()
Deprecated.
|
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Deprecated.
|
public DropwizardClientRule(Object... resources)
public URI baseUri()
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public Environment getEnvironment()
protected void before() throws Throwable
before
in class org.junit.rules.ExternalResource
Throwable
protected void after()
after
in class org.junit.rules.ExternalResource
Copyright © 2019. All rights reserved.