use of org.glassfish.jersey.client.JerseyClient in project dropwizard by dropwizard.
the class Http2CIntegrationTest method testHttp11.
@Test
public void testHttp11() {
final String hostname = "127.0.0.1";
final int port = appRule.getLocalPort();
final JerseyClient http11Client = new JerseyClientBuilder().build();
final Response response = http11Client.target("http://" + hostname + ":" + port + "/api/test").request().get();
assertThat(response.getHeaderString(HttpHeaders.CONTENT_TYPE)).isEqualTo(MediaType.APPLICATION_JSON);
assertThat(response.readEntity(String.class)).isEqualTo(FakeApplication.HELLO_WORLD);
http11Client.close();
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class CookieTest method testCookies.
@Test
public void testCookies() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new JettyConnectorProvider());
JerseyClient client = JerseyClientBuilder.createClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("NO-COOKIE", r.request().get(String.class));
assertEquals("value", r.request().get(String.class));
final JettyConnector connector = (JettyConnector) client.getConfiguration().getConnector();
assertNotNull(connector.getCookieStore().getCookies());
assertEquals(1, connector.getCookieStore().getCookies().size());
assertEquals("value", connector.getCookieStore().getCookies().get(0).getValue());
client.close();
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class ClientPreInitTest method testReusingPreinitializedConfig2.
@Test
public void testReusingPreinitializedConfig2() {
Client client = ClientBuilder.newClient();
client.register(TestReader.class);
client.register(MyResponseFilter.class);
assertFalse(TestReader.initialized);
((JerseyClient) client).preInitialize();
assertTrue(TestReader.initialized);
final WebTarget target = client.target(super.getBaseUri()).path("resource");
final WebTarget childTarget = target.path("child");
final Response response = childTarget.request().get();
checkResponse(response, "child:<null>");
final Response resourceResponse = target.request().get();
checkResponse(resourceResponse, "resource:<null>");
}
use of org.glassfish.jersey.client.JerseyClient in project jersey by jersey.
the class CookieTest method testCookies.
@Test
public void testCookies() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
JerseyClient client = JerseyClientBuilder.createClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("NO-COOKIE", r.request().get(String.class));
assertEquals("value", r.request().get(String.class));
final ApacheConnector connector = (ApacheConnector) client.getConfiguration().getConnector();
assertNotNull(connector.getCookieStore().getCookies());
assertEquals(1, connector.getCookieStore().getCookies().size());
assertEquals("value", connector.getCookieStore().getCookies().get(0).getValue());
}
use of org.glassfish.jersey.client.JerseyClient in project dropwizard by dropwizard.
the class Http2IntegrationTest method testHttp11.
@Test
public void testHttp11() throws Exception {
final String hostname = "localhost";
final int port = appRule.getLocalPort();
final JerseyClient http11Client = new JerseyClientBuilder().sslContext(sslContextFactory.getSslContext()).build();
final Response response = http11Client.target("https://" + hostname + ":" + port + "/api/test").request().get();
assertThat(response.getHeaderString(HttpHeaders.CONTENT_TYPE)).isEqualTo(MediaType.APPLICATION_JSON);
assertThat(response.readEntity(String.class)).isEqualTo(FakeApplication.HELLO_WORLD);
http11Client.close();
}
Aggregations