Search in sources :

Example 46 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.

the class DropwizardSSLConnectionSocketFactoryTest method shouldRejectNonSupportedProtocols.

@Test
public void shouldRejectNonSupportedProtocols() throws Exception {
    tlsConfiguration.setSupportedProtocols(Collections.singletonList("TLSv1.2"));
    final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("reject_non_supported");
    assertThatThrownBy(() -> client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(4))).request().get()).isInstanceOf(ProcessingException.class).hasRootCauseInstanceOf(SSLException.class);
}
Also used : Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Example 47 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project textdb by TextDB.

the class QueryPlanResourceTest method checkSampleEndpoint.

/**
 * Tests the query plan execution endpoint.
 */
@Test
public void checkSampleEndpoint() throws Exception {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
    client.property(ClientProperties.CONNECT_TIMEOUT, 5000);
    client.property(ClientProperties.READ_TIMEOUT, 5000);
    Response response = client.target(String.format(queryPlanEndpoint, RULE.getLocalPort())).request().post(Entity.entity(new ObjectMapper().writeValueAsString(getLogicalPlan1()), MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) Test(org.junit.Test)

Example 48 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project textdb by TextDB.

the class SystemResourceTest method getDictionaryPath.

// TODO: Figure out how to upload a dictionary in test case
@Test
@Ignore
public void getDictionaryPath() throws Exception {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
    client.property(ClientProperties.CONNECT_TIMEOUT, 5000);
    client.property(ClientProperties.READ_TIMEOUT, 5000);
    client.register(MultiPartFeature.class);
    Response response = client.target(String.format("http://localhost:%d/api/resources/dictionary/?name=dictname", RULE.getLocalPort())).request().get();
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 49 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project verify-hub by alphagov.

the class HubMetadataIntegrationTests method setUp.

@BeforeClass
public static void setUp() throws Exception {
    JerseyClientConfiguration jerseyClientConfiguration = new JerseyClientConfiguration();
    jerseyClientConfiguration.setConnectionTimeout(Duration.seconds(10));
    jerseyClientConfiguration.setTimeout(Duration.seconds(10));
    client = new JerseyClientBuilder(samlProxyAppRule.getEnvironment()).using(jerseyClientConfiguration).build(HubMetadataIntegrationTests.class.getName());
    DateTimeFreezer.freezeTime();
}
Also used : JerseyClientConfiguration(io.dropwizard.client.JerseyClientConfiguration) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) BeforeClass(org.junit.BeforeClass)

Example 50 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project verify-hub by alphagov.

the class DenialOfServiceAttacksIntegrationTests method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    JerseyClientConfiguration jerseyClientConfiguration = JerseyClientConfigurationBuilder.aJerseyClientConfiguration().withTimeout(Duration.seconds(10)).build();
    client = new JerseyClientBuilder(samlProxyAppRule.getEnvironment()).using(jerseyClientConfiguration).build(SamlMessageReceiverApiResourceTest.class.getSimpleName());
}
Also used : JerseyClientConfiguration(io.dropwizard.client.JerseyClientConfiguration) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) BeforeClass(org.junit.BeforeClass)

Aggregations

JerseyClientBuilder (io.dropwizard.client.JerseyClientBuilder)67 JerseyClientConfiguration (io.dropwizard.client.JerseyClientConfiguration)46 BeforeClass (org.junit.BeforeClass)45 Client (javax.ws.rs.client.Client)21 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)14 ClientResponse (org.glassfish.jersey.client.ClientResponse)7 File (java.io.File)4 ProcessingException (javax.ws.rs.ProcessingException)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 MultiPart (org.glassfish.jersey.media.multipart.MultiPart)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FormDataBodyPart (org.glassfish.jersey.media.multipart.FormDataBodyPart)2 FormDataMultiPart (org.glassfish.jersey.media.multipart.FormDataMultiPart)2 Ignore (org.junit.Ignore)2 RequestAndResponse (httpstub.RequestAndResponse)1 ErrorMessage (io.dropwizard.jersey.errors.ErrorMessage)1 NoopHostnameVerifier (org.apache.http.conn.ssl.NoopHostnameVerifier)1 FileDataBodyPart (org.glassfish.jersey.media.multipart.file.FileDataBodyPart)1 Before (org.junit.Before)1