use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class App1Test method custom404OnViewRenderMissingMustacheTemplate.
@Test
public void custom404OnViewRenderMissingMustacheTemplate() {
final Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client 2");
final String url = String.format("http://localhost:%d/view-with-missing-tpl", RULE.getLocalPort());
final Response response = client.target(url).request().get();
assertThat(response.getStatus()).isEqualTo(404);
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class FormsAppTest method canSubmitFormAndReceiveResponse.
@Test
public void canSubmitFormAndReceiveResponse() {
config.setChunkedEncodingEnabled(false);
final Client client = new JerseyClientBuilder(RULE.getEnvironment()).using(config).build("test client 1");
final MultiPart mp = new FormDataMultiPart().bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("file").fileName("fileName").build(), "CONTENT"));
final String url = String.format("http://localhost:%d/uploadFile", RULE.getLocalPort());
final String response = client.target(url).register(MultiPartFeature.class).request().post(Entity.entity(mp, mp.getMediaType()), String.class);
assertThat(response).isEqualTo("fileName:\nCONTENT");
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class FormsAppTest method failOnNoChunkedEncoding.
/** Test confirms that chunked encoding has to be disabled in order for sending forms to work.
* Maybe someday this requirement will be relaxed and this test can be updated for the new
* behavior. For more info, see issues #1013 and #1094 */
@Test
public void failOnNoChunkedEncoding() {
final Client client = new JerseyClientBuilder(RULE.getEnvironment()).using(config).build("test client 2");
final MultiPart mp = new FormDataMultiPart().bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("file").fileName("fileName").build(), "CONTENT"));
final String url = String.format("http://localhost:%d/uploadFile", RULE.getLocalPort());
final Response response = client.target(url).register(MultiPartFeature.class).request().post(Entity.entity(mp, mp.getMediaType()));
assertThat(response.getStatus()).isEqualTo(400);
assertThat(response.readEntity(ErrorMessage.class)).isEqualTo(new ErrorMessage(400, "HTTP 400 Bad Request"));
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class AbstractRequestLogPatternIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
final JerseyClientConfiguration configuration = new JerseyClientConfiguration();
configuration.setTimeout(Duration.seconds(2));
client = new JerseyClientBuilder(dropwizardAppRule.getEnvironment()).using(configuration).build("test-request-logs");
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class DropwizardSSLConnectionSocketFactoryTest method shouldBeOkIfHostnameVerificationOffAndServerHostnameDoesntMatch.
@Test
public void shouldBeOkIfHostnameVerificationOffAndServerHostnameDoesntMatch() throws Exception {
tlsConfiguration.setVerifyHostname(false);
final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("bad_host_working");
final Response response = client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(3))).request().get();
assertThat(response.getStatus()).isEqualTo(200);
}
Aggregations