use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class AuthTest method testAuthDeleteWithClientFilter.
@Test
public void testAuthDeleteWithClientFilter() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
client.register(HttpAuthenticationFeature.basic("name", "password"));
WebTarget r = client.target(getBaseUri()).path("test/filter");
Response response = r.request().delete();
assertEquals(204, response.getStatus());
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class AuthTest method testAuthGetWithClientFilter.
@Test
public void testAuthGetWithClientFilter() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
client.register(HttpAuthenticationFeature.basic("name", "password"));
WebTarget r = client.target(getBaseUri()).path("test/filter");
assertEquals("GET", r.request().get(String.class));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class AuthTest method testAuthPost.
@Test
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + " Allow repeatable write in jersey?")
public void testAuthPost() {
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");
assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class CookieTest method testDisabledCookies.
@Test
public void testDisabledCookies() {
ClientConfig cc = new ClientConfig();
cc.property(ApacheClientProperties.DISABLE_COOKIES, true);
cc.connectorProvider(new ApacheConnectorProvider());
JerseyClient client = JerseyClientBuilder.createClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("NO-COOKIE", r.request().get(String.class));
assertEquals("NO-COOKIE", r.request().get(String.class));
final ApacheConnector connector = (ApacheConnector) client.getConfiguration().getConnector();
if (connector.getCookieStore() != null) {
assertTrue(connector.getCookieStore().getCookies().isEmpty());
} else {
assertNull(connector.getCookieStore());
}
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class DisableContentEncodingTest method testDisabledByRequestConfig.
@Test
public void testDisabledByRequestConfig() {
ClientConfig cc = new ClientConfig(GZipEncoder.class);
final RequestConfig requestConfig = RequestConfig.custom().setContentCompressionEnabled(false).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("", enc);
}
Aggregations