use of org.glassfish.jersey.client.ClientConfig in project cu-kfs by CU-CommunityApps.
the class PaymentWorksWebServiceCallsServiceImpl method buildXmlOutput.
private Response buildXmlOutput(URI uri) {
Client client = null;
Response response = null;
try {
ClientConfig clientConfig = new ClientConfig();
client = ClientBuilder.newClient(clientConfig);
Invocation request = buildXmlClientRequest(client, uri);
response = request.invoke();
response.bufferEntity();
return response;
} finally {
CURestClientUtils.closeQuietly(client);
}
}
use of org.glassfish.jersey.client.ClientConfig in project kafka-streams-examples by confluentinc.
the class EndToEndTest method getClient.
private Client getClient() {
final ClientConfig clientConfig = new ClientConfig();
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 60000).property(ClientProperties.READ_TIMEOUT, 60000);
return ClientBuilder.newClient(clientConfig);
}
use of org.glassfish.jersey.client.ClientConfig in project crnk-framework by crnk-project.
the class JsonApiResponseFilterTestBase method setup.
@BeforeClass
public static void setup() {
ClientConfig config = new ClientConfig();
config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
httpClient = ClientBuilder.newClient(config);
}
use of org.glassfish.jersey.client.ClientConfig in project ff4j by ff4j.
the class AbstractEmbeddedGrizzlyIntegrationTest method initOnce.
@BeforeClass
public static void initOnce() throws IOException {
// WebContext for testing
webappContext = new WebappContext("Test Context");
ServletRegistration servletRegistration = webappContext.addServlet("jersey-servlet", ServletContainer.class);
servletRegistration.setInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter("javax.ws.rs.Application", SampleFF4jJersey2Application.class.getCanonicalName());
servletRegistration.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
servletRegistration.addMapping("/*");
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(JacksonJsonProvider.class);
clientConfig.register(FF4jJacksonMapper.class);
client = ClientBuilder.newClient(clientConfig);
server = new HttpServer();
NetworkListener listener = new NetworkListener("grizzly2", HOST, PORT);
server.addListener(listener);
webappContext.deploy(server);
}
use of org.glassfish.jersey.client.ClientConfig in project incubator-pulsar by apache.
the class ProxyPublishConsumeTest method testProxyStats.
/**
* It verifies proxy topic-stats and proxy-metrics api
*
* @throws Exception
*/
@Test(timeOut = 10000)
public void testProxyStats() throws Exception {
final String topic = "my-property/use/my-ns/my-topic6";
final String consumerUri = "ws://localhost:" + port + "/ws/consumer/persistent/" + topic + "/my-sub?subscriptionType=Failover";
final String producerUri = "ws://localhost:" + port + "/ws/producer/persistent/" + topic + "/";
final String readerUri = "ws://localhost:" + port + "/ws/reader/persistent/" + topic;
System.out.println(consumerUri + ", " + producerUri);
URI consumeUri = URI.create(consumerUri);
URI produceUri = URI.create(producerUri);
URI readUri = URI.create(readerUri);
WebSocketClient consumeClient1 = new WebSocketClient();
SimpleConsumerSocket consumeSocket1 = new SimpleConsumerSocket();
WebSocketClient produceClient = new WebSocketClient();
SimpleProducerSocket produceSocket = new SimpleProducerSocket();
WebSocketClient readClient = new WebSocketClient();
SimpleConsumerSocket readSocket = new SimpleConsumerSocket();
try {
consumeClient1.start();
ClientUpgradeRequest consumeRequest1 = new ClientUpgradeRequest();
Future<Session> consumerFuture1 = consumeClient1.connect(consumeSocket1, consumeUri, consumeRequest1);
log.info("Connecting to : {}", consumeUri);
readClient.start();
ClientUpgradeRequest readRequest = new ClientUpgradeRequest();
Future<Session> readerFuture = readClient.connect(readSocket, readUri, readRequest);
log.info("Connecting to : {}", readUri);
Assert.assertTrue(consumerFuture1.get().isOpen());
Assert.assertTrue(readerFuture.get().isOpen());
Thread.sleep(500);
ClientUpgradeRequest produceRequest = new ClientUpgradeRequest();
produceClient.start();
Future<Session> producerFuture = produceClient.connect(produceSocket, produceUri, produceRequest);
// let it connect
Assert.assertTrue(producerFuture.get().isOpen());
// sleep so, proxy can deliver few messages to consumers for stats
int retry = 0;
int maxRetry = 400;
while (consumeSocket1.getReceivedMessagesCount() < 2) {
Thread.sleep(10);
if (retry++ > maxRetry) {
final String msg = String.format("Consumer still has not received the message after %s ms", (maxRetry * 10));
log.warn(msg);
break;
}
}
Client client = ClientBuilder.newClient(new ClientConfig().register(LoggingFeature.class));
final String baseUrl = pulsar.getWebServiceAddress().replace(Integer.toString(pulsar.getConfiguration().getWebServicePort()), (Integer.toString(port))) + "/admin/proxy-stats/";
// verify proxy metrics
verifyProxyMetrics(client, baseUrl);
// verify proxy stats
verifyProxyStats(client, baseUrl, topic);
// verify topic stat
verifyTopicStat(client, baseUrl, topic);
} finally {
stopWebSocketClient(consumeClient1, produceClient);
}
}
Aggregations