use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class AuthTest method testAuthDelete.
@Test
public void testAuthDelete() {
ClientConfig config = new ClientConfig();
config.property(JettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, new BasicAuthentication(getBaseUri(), "WallyWorld", "name", "password"));
config.connectorProvider(new JettyConnectorProvider());
Client client = ClientBuilder.newClient(config);
Response response = client.target(getBaseUri()).path(PATH).request().delete();
assertEquals(response.getStatus(), 204);
client.close();
}
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 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.ClientConfig in project jersey by jersey.
the class WebTargetValueSupplierProvider method resolveConfig.
private ClientConfig resolveConfig(final String configClassProperty, final BindingModel binding) {
Class<? extends Configuration> configClass = binding.getConfigClass();
final Object _cc = serverConfig.get().getProperty(configClassProperty);
if (_cc != null) {
Class<?> cc;
if (_cc instanceof String) {
cc = AccessController.doPrivileged(ReflectionHelper.classForNamePA((String) _cc));
} else if (_cc instanceof Class) {
cc = (Class<?>) _cc;
} else {
// will cause a warning
cc = null;
}
if (cc != null && Configuration.class.isAssignableFrom(cc)) {
configClass = cc.asSubclass(Configuration.class);
} else {
Errors.warning(this, LocalizationMessages.ILLEGAL_CLIENT_CONFIG_CLASS_PROPERTY_VALUE(configClassProperty, _cc, configClass.getName()));
}
}
final Configuration cfg = clientConfigProvider.apply(configClass);
return (cfg instanceof ClientConfig) ? (ClientConfig) cfg : new ClientConfig().loadFrom(cfg);
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class EntityFilteringClientTest method testEntityAnnotationsOverConfiguration.
@Test
public void testEntityAnnotationsOverConfiguration() throws Exception {
final ClientConfig config = new ClientConfig().property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, SecondaryDetailedView.Factory.get());
configureClient(config);
final String fields = ClientBuilder.newClient(config).target(getBaseUri()).request().post(Entity.entity(new ManyFilteringsOnClassEntity(), ENTITY_FILTERING, new Annotation[] { PrimaryDetailedView.Factory.get() }), String.class);
assertSameFields(fields, "field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," + "oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities" + ".property");
}
use of org.glassfish.jersey.client.ClientConfig in project dropwizard by dropwizard.
the class ResourceTestRule method apply.
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration);
try {
test = new JerseyTest() {
@Override
protected TestContainerFactory getTestContainerFactory() {
return configuration.testContainerFactory;
}
@Override
protected DeploymentContext configureDeployment() {
return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)).initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()).initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()).build();
}
@Override
protected void configureClient(ClientConfig clientConfig) {
final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(configuration.mapper);
configuration.clientConfigurator.accept(clientConfig);
clientConfig.register(jsonProvider);
}
};
test.setUp();
base.evaluate();
} finally {
DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.remove(configuration.getId());
test.tearDown();
}
}
};
}
Aggregations