use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class ConstrainedToTest method testClientWithProviderClasses.
@Test
public void testClientWithProviderClasses() {
Client client = ClientBuilder.newClient(new ClientConfig(ClientFilterConstrainedToServer.class, ClientFilterConstrainedToClient.class, ClientFilter.class));
_testFilters(client);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class ConstrainedToTest method testClientWithProviderInstances.
@Test
public void testClientWithProviderInstances() {
Client client = ClientBuilder.newClient(new ClientConfig(new ClientFilterConstrainedToServer(), new ClientFilterConstrainedToClient(), new ClientFilter()));
_testFilters(client);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class JsonEntityFilteringClientTest method testInvalidConfiguration.
@Test
public void testInvalidConfiguration() throws Exception {
final ClientConfig config = new ClientConfig().property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, "invalid_value");
configureClient(config);
final OneFilteringOnClassEntity entity = ClientBuilder.newClient(config).target(getBaseUri()).request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), OneFilteringOnClassEntity.class);
_testEmptyEntity(entity);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class UnderlyingCookieStoreAccessTest method testCookieStoreInstanceAccess.
@Test
public void testCookieStoreInstanceAccess() {
final Client client = ClientBuilder.newClient(new ClientConfig().connectorProvider(new ApacheConnectorProvider()));
final CookieStore csOnClient = ApacheConnectorProvider.getCookieStore(client);
// important: the web target instance in this test must be only created AFTER the client has been pre-initialized
// (see org.glassfish.jersey.client.Initializable.preInitialize method). This is here achieved by calling the
// connector provider's static getCookieStore method above.
final WebTarget target = client.target("http://localhost/");
final CookieStore csOnTarget = ApacheConnectorProvider.getCookieStore(target);
assertNotNull("CookieStore instance set on JerseyClient should not be null.", csOnClient);
assertNotNull("CookieStore instance set on JerseyWebTarget should not be null.", csOnTarget);
assertSame("CookieStore instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" + "(provided the target instance has not been further configured).", csOnClient, csOnTarget);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class RetryHandlerTest method testRetryGet.
@Test
public void testRetryGet() throws IOException {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
cc.property(ApacheClientProperties.RETRY_HANDLER, (HttpRequestRetryHandler) (exception, executionCount, context) -> true);
cc.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT_MS);
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("GET", r.request().get(String.class));
}
Aggregations