Search in sources :

Example 11 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project athenz by yahoo.

the class MSDClientTimeoutTest method testMSDClientReadTimeoutForJerseyContainer.

@Test
public void testMSDClientReadTimeoutForJerseyContainer() throws Exception {
    MSDClientMock.setClientBuilder(new JerseyClientBuilder());
    server = new JettyServer(port);
    server.start();
    String baseUri = "http://localhost:" + port;
    final SSLContext dummyContext = createDummySslContext();
    MSDClientMock msdClient = new MSDClientMock(baseUri, dummyContext);
    try {
        msdClient.getTransportPolicyRules(null, null);
        fail("read timeout not set");
    } catch (MSDClientException expected) {
        assertEquals(expected.code, ResourceException.BAD_REQUEST);
        assertEquals(expected.getMessage(), "ResourceException (400): java.net.SocketTimeoutException: Read timed out");
    }
    msdClient.close();
    MSDClientMock.setClientBuilder(null);
}
Also used : SSLContext(javax.net.ssl.SSLContext) JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder) Test(org.testng.annotations.Test)

Aggregations

JerseyClientBuilder (org.glassfish.jersey.client.JerseyClientBuilder)11 Test (org.testng.annotations.Test)4 JerseyClient (org.glassfish.jersey.client.JerseyClient)3 Test (org.junit.Test)3 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)2 SecureRandom (java.security.SecureRandom)2 SSLContext (javax.net.ssl.SSLContext)2 Response (javax.ws.rs.core.Response)2 Statement (org.junit.runners.model.Statement)2 X509Certificate (java.security.cert.X509Certificate)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1