Created
January 17, 2015 14:58
Revisions
-
joschi created this gist
Jan 17, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ package io.dropwizard.client; import io.dropwizard.Application; import io.dropwizard.Configuration; import io.dropwizard.setup.Environment; import io.dropwizard.testing.junit.DropwizardAppRule; import org.junit.Rule; import org.junit.Test; import javax.ws.rs.client.Client; import static org.junit.Assert.fail; public class Issue832 { @Rule public final DropwizardAppRule<TestConfiguration> RULE = new DropwizardAppRule<TestConfiguration>(TestApplication.class, null); @Test public void testSingleClient() { Client c = buildClient(RULE, "test-client"); c.close(); } @Test public void testMultipleClientsWithDistinctNames() { Client c1 = buildClient(RULE, "test-client"); Client c2 = buildClient(RULE, "test-client2"); c1.close(); c2.close(); } @Test(expected = IllegalArgumentException.class) public void testMultipleClientsWithSameName() { // This should fail because names need to be distinct buildClient(RULE, "test-client"); buildClient(RULE, "test-client"); fail(); } public static Client buildClient(DropwizardAppRule<TestConfiguration> appRule, String name) { return new JerseyClientBuilder(appRule.getEnvironment()) .using(appRule.getConfiguration().getJerseyClientConfiguration()) .build(name); } public static class TestConfiguration extends Configuration { private JerseyClientConfiguration jerseyClientConfiguration = new JerseyClientConfiguration(); public JerseyClientConfiguration getJerseyClientConfiguration() { return jerseyClientConfiguration; } } public static class TestApplication extends Application<TestConfiguration> { @Override public void run(TestConfiguration configuration, Environment environment) throws Exception { } } }