Created
February 10, 2015 04:05
-
-
Save javaeeeee/04836a068378c4e2fdcf to your computer and use it in GitHub Desktop.
Dropwizard Integration Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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