use of org.glassfish.jersey.client.ClientConfig in project streamline by hortonworks.
the class RestIntegrationTest method testRemoveNamespaceButTopologyRefersThatNamespace.
@Test
public void testRemoveNamespaceButTopologyRefersThatNamespace() {
Client client = ClientBuilder.newClient(new ClientConfig());
Long namespaceId = 999L;
String namespaceName = "nstest";
storeTestNamespace(client, namespaceId, namespaceName);
Long namespaceId2 = 999L;
String namespaceName2 = "nstest";
storeTestNamespace(client, namespaceId2, namespaceName2);
Long topologyId = 1L;
String topologyName = "topotest";
storeTestTopology(client, topologyId, topologyName, namespaceId);
Long topologyId2 = 2L;
String topologyName2 = "topotest2";
storeTestTopology(client, topologyId2, topologyName2, namespaceId2);
String removeNamespaceUrl = rootUrl + "namespaces/" + namespaceId;
Response response = client.target(removeNamespaceUrl).request().delete();
Assert.assertEquals(new BadRequestException().getResponse().getStatus(), response.getStatus());
// cleanup
removeTopology(client, topologyId2);
removeTopology(client, topologyId);
removeNamespace(client, namespaceId2);
removeNamespace(client, namespaceId);
}
use of org.glassfish.jersey.client.ClientConfig in project streamline by hortonworks.
the class AmbariServiceNodeDiscoverer method setupClient.
private void setupClient() {
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder().credentials(username, password).build();
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(feature);
clientConfig.register(JsonToMapProvider.class);
client = ClientBuilder.newClient(clientConfig);
}
use of org.glassfish.jersey.client.ClientConfig in project registry by hortonworks.
the class SchemaRegistryClient method createClientConfig.
protected ClientConfig createClientConfig(Map<String, ?> conf) {
ClientConfig config = new ClientConfig();
config.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
config.property(ClientProperties.READ_TIMEOUT, DEFAULT_READ_TIMEOUT);
config.property(ClientProperties.FOLLOW_REDIRECTS, true);
for (Map.Entry<String, ?> entry : conf.entrySet()) {
config.property(entry.getKey(), entry.getValue());
}
return config;
}
use of org.glassfish.jersey.client.ClientConfig in project cloudbreak by hortonworks.
the class RestClientUtil method createClient.
private static Client createClient(ConfigKey configKey) {
LOGGER.debug("Constructing jax rs client: {}", configKey);
ClientConfig config = new ClientConfig();
config.property(ClientProperties.FOLLOW_REDIRECTS, "false");
config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS);
config.register(MultiPartFeature.class);
ClientBuilder builder = ClientBuilder.newBuilder().withConfig(config);
if (configKey.isDebug()) {
builder = builder.register(new LoggingFilter(java.util.logging.Logger.getLogger(RestClientUtil.class.getName()), true));
}
if (!configKey.isSecure()) {
builder.sslContext(CertificateTrustManager.sslContext());
builder.hostnameVerifier(CertificateTrustManager.hostnameVerifier());
}
Client client = builder.build();
client.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, configKey.isIgnorePreValidation());
SSLContext sslContext = client.getSslContext();
LOGGER.warn("RestClient has been constructed: {}, client: {}, sslContext: {}", configKey, client, sslContext);
return client;
}
use of org.glassfish.jersey.client.ClientConfig in project dropwizard by dropwizard.
the class JerseyClientBuilder method buildConfig.
private Configuration buildConfig(final String name, final ExecutorService threadPool, final ObjectMapper objectMapper, final Validator validator) {
final ClientConfig config = new ClientConfig();
for (Object singleton : this.singletons) {
config.register(singleton);
}
for (Class<?> provider : this.providers) {
config.register(provider);
}
config.register(new JacksonFeature(objectMapper));
config.register(new HibernateValidationBinder(validator));
for (Map.Entry<String, Object> property : this.properties.entrySet()) {
config.property(property.getKey(), property.getValue());
}
config.register(new DropwizardExecutorProvider(threadPool));
if (connectorProvider == null) {
final ConfiguredCloseableHttpClient apacheHttpClient = apacheHttpClientBuilder.buildWithDefaultRequestConfiguration(name);
config.connectorProvider((client, runtimeConfig) -> createDropwizardApacheConnector(apacheHttpClient));
} else {
config.connectorProvider(connectorProvider);
}
return config;
}
Aggregations