Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created February 10, 2015 04:05
Show Gist options
  • Select an option

  • Save javaeeeee/04836a068378c4e2fdcf to your computer and use it in GitHub Desktop.

Select an option

Save javaeeeee/04836a068378c4e2fdcf to your computer and use it in GitHub Desktop.
Dropwizard Integration Test
public class IntegrationTest {
@ClassRule
public static final DropwizardAppRule<DWGettingStartedConfiguration> RULE
= new DropwizardAppRule<>(DWGettingStartedApplication.class,
"config.yml");
@Test
public void testGetGreeting() {
String expected = "Hello world!";
//Obtain client
Client client = ClientBuilder.newClient();
//Build a feature in basic authentication mode
HttpAuthenticationFeature feature
= HttpAuthenticationFeature.basic("javaeeeee", "crimson");
//Register the feature
client.register(feature);
//Get actual resul string
String actual = client
.target("http://localhost:8080/secured_hello")
.request(MediaType.TEXT_PLAIN)
.get(String.class);
//Do an assertion
assertEquals(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment