use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class AuthTest method testAuthDelete.
@Test
public void testAuthDelete() {
CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("name", "password"));
ClientConfig cc = new ClientConfig();
cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri()).path("test");
Response response = r.request().delete();
assertEquals(response.getStatus(), 204);
}
use of org.glassfish.jersey.client.ClientConfig 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.ClientConfig in project jersey by jersey.
the class CookieTest method testCookieResource.
@Test
public void testCookieResource() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("NO-COOKIE", r.request().get(String.class));
assertEquals("value", r.request().get(String.class));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class DisableContentEncodingTest method testEnabledByRequestConfig.
@Test
public void testEnabledByRequestConfig() {
ClientConfig cc = new ClientConfig(GZipEncoder.class);
final RequestConfig requestConfig = RequestConfig.custom().setContentCompressionEnabled(true).build();
cc.property(ApacheClientProperties.REQUEST_CONFIG, requestConfig);
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri());
String enc = r.request().get().readEntity(String.class);
assertEquals("gzip,deflate", enc);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class DisableContentEncodingTest method testDefaultEncodingOverridden.
@Test
public void testDefaultEncodingOverridden() {
ClientConfig cc = new ClientConfig(GZipEncoder.class);
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri());
String enc = r.request().acceptEncoding("gzip").get().readEntity(String.class);
assertEquals("gzip", enc);
}
Aggregations