use of org.glassfish.jersey.client.ClientConfig in project openscoring by openscoring.
the class ModelApplication method execute.
public <V extends SimpleResponse> V execute(Operation<V> operation) throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(JacksonJsonProvider.class);
clientConfig.register(ObjectMapperProvider.class);
Client client = ClientBuilder.newClient(clientConfig);
try {
WebTarget target = client.target(getURI());
return operation.perform(target);
} finally {
client.close();
}
}
use of org.glassfish.jersey.client.ClientConfig in project nifi-registry by apache.
the class IntegrationTestBase method createClientFromConfig.
private static Client createClientFromConfig(NiFiRegistryClientConfig registryClientConfig) {
final ClientConfig clientConfig = new ClientConfig();
clientConfig.register(jacksonJaxbJsonProvider());
final ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
final SSLContext sslContext = registryClientConfig.getSslContext();
if (sslContext != null) {
clientBuilder.sslContext(sslContext);
}
final HostnameVerifier hostnameVerifier = registryClientConfig.getHostnameVerifier();
if (hostnameVerifier != null) {
clientBuilder.hostnameVerifier(hostnameVerifier);
}
return clientBuilder.build();
}
use of org.glassfish.jersey.client.ClientConfig in project timbuctoo by HuygensING.
the class IntegrationTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException {
ClientConfig configuration = new ClientConfig();
client = ClientBuilder.newClient(configuration);
}
use of org.glassfish.jersey.client.ClientConfig in project streamline by hortonworks.
the class StormTopologyActionsImpl method init.
@Override
public void init(Map<String, Object> conf) {
this.conf = conf;
if (conf != null) {
if (conf.containsKey(StormTopologyLayoutConstants.STORM_ARTIFACTS_LOCATION_KEY)) {
stormArtifactsLocation = (String) conf.get(StormTopologyLayoutConstants.STORM_ARTIFACTS_LOCATION_KEY);
}
if (conf.containsKey(StormTopologyLayoutConstants.STORM_HOME_DIR)) {
String stormHomeDir = (String) conf.get(StormTopologyLayoutConstants.STORM_HOME_DIR);
if (!stormHomeDir.endsWith(File.separator)) {
stormHomeDir += File.separator;
}
stormCliPath = stormHomeDir + "bin" + File.separator + "storm";
}
this.stormJarLocation = (String) conf.get(StormTopologyLayoutConstants.STORM_JAR_LOCATION_KEY);
catalogRootUrl = (String) conf.get(StormTopologyLayoutConstants.YAML_KEY_CATALOG_ROOT_URL);
Map<String, String> env = System.getenv();
String javaHomeStr = env.get("JAVA_HOME");
if (StringUtils.isNotEmpty(javaHomeStr)) {
if (!javaHomeStr.endsWith(File.separator)) {
javaHomeStr += File.separator;
}
javaJarCommand = javaHomeStr + "bin" + File.separator + "jar";
} else {
javaJarCommand = "jar";
}
String stormApiRootUrl = (String) conf.get(TopologyLayoutConstants.STORM_API_ROOT_URL_KEY);
Subject subject = (Subject) conf.get(TopologyLayoutConstants.SUBJECT_OBJECT);
Client restClient = ClientBuilder.newClient(new ClientConfig());
this.client = new StormRestAPIClient(restClient, stormApiRootUrl, subject);
nimbusSeeds = (String) conf.get(NIMBUS_SEEDS);
nimbusPort = Integer.valueOf((String) conf.get(NIMBUS_PORT));
if (conf.containsKey(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)) {
nimbusThriftMaxBufferSize = (Long) conf.get(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
} else {
nimbusThriftMaxBufferSize = DEFAULT_NIMBUS_THRIFT_MAX_BUFFER_SIZE;
}
setupSecuredStormCluster(conf);
EnvironmentService environmentService = (EnvironmentService) conf.get(TopologyLayoutConstants.ENVIRONMENT_SERVICE_OBJECT);
Number namespaceId = (Number) conf.get(TopologyLayoutConstants.NAMESPACE_ID);
this.serviceConfigurationReader = new AutoCredsServiceConfigurationReader(environmentService, namespaceId.longValue());
}
File f = new File(stormArtifactsLocation);
if (!f.exists() && !f.mkdirs()) {
throw new RuntimeException("Could not create directory " + f.getAbsolutePath());
}
}
use of org.glassfish.jersey.client.ClientConfig in project streamline by hortonworks.
the class RestIntegrationTest method testResourcesWithQueryParams.
/**
* For each QueryParamsResourceTestElement it first try to send all get
* requests and verifies the response. It then loads all resources via post
* and executes get requests to match them with expected results
* @param queryParamsResources
* @throws Exception
*/
public void testResourcesWithQueryParams(List<QueryParamsResourceTestElement> queryParamsResources) throws Exception {
Client client = ClientBuilder.newClient(new ClientConfig());
String response;
for (QueryParamsResourceTestElement qpte : queryParamsResources) {
// all gets first should return no entities
for (int i = 0; i < qpte.getUrls.size(); ++i) {
String getUrl = qpte.getUrls.get(i);
response = client.target(getUrl).request().get(String.class);
Assert.assertEquals(Collections.emptyList(), getEntities(response, qpte.getResults.get(i).getClass()));
}
// post the resources now
for (Object resource : qpte.resourcesToPost) {
response = client.target(qpte.postUrl).request().post(Entity.json(resource), String.class);
}
// send get requests and match the response with expected results
for (int i = 0; i < qpte.getUrls.size(); ++i) {
String getUrl = qpte.getUrls.get(i);
List<Object> expectedResults = qpte.getResults.get(i);
response = client.target(getUrl).request().get(String.class);
Assert.assertEquals(expectedResults, getEntities(response, expectedResults.get(i).getClass()));
}
}
}
Aggregations