use of io.cdap.cdap.common.http.DefaultHttpRequestConfig in project cdap by caskdata.
the class SupportBundleServiceMainTest method testSupportBundleService.
@Test
public void testSupportBundleService() throws Exception {
Injector injector = getServiceMainInstance(SupportBundleServiceMain.class).getInjector();
URL url = getRouterBaseURI().resolve("/v3/support/bundle").toURL();
HttpResponse response = HttpRequests.execute(HttpRequest.post(url).build(), new DefaultHttpRequestConfig(false));
Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
SupportBundleService supportBundleService = injector.getInstance(SupportBundleService.class);
SupportBundleConfiguration supportBundleConfiguration = new SupportBundleConfiguration(NamespaceId.DEFAULT.getNamespace(), null, null, ProgramType.WORKFLOW, "DataPipelineWorkflow", 1);
String uuid = supportBundleService.generateSupportBundle(supportBundleConfiguration);
Assert.assertNotNull(uuid);
}
use of io.cdap.cdap.common.http.DefaultHttpRequestConfig in project cdap by caskdata.
the class LogsServiceMainTest method doGet.
private HttpResponse doGet(String path, DiscoveryServiceClient discoveryServiceClient, String serviceName) throws IOException {
Discoverable discoverable = new RandomEndpointStrategy(() -> discoveryServiceClient.discover(serviceName)).pick(10, TimeUnit.SECONDS);
Assert.assertNotNull(discoverable);
URL url = URIScheme.createURI(discoverable, path).toURL();
return HttpRequests.execute(HttpRequest.get(url).build(), new DefaultHttpRequestConfig(false));
}
use of io.cdap.cdap.common.http.DefaultHttpRequestConfig in project cdap by caskdata.
the class SupportBundleServiceMainTest method doPost.
private HttpResponse doPost(String path, DiscoveryServiceClient discoveryServiceClient, String serviceName) throws IOException {
Discoverable discoverable = new RandomEndpointStrategy(() -> discoveryServiceClient.discover(serviceName)).pick(10, TimeUnit.SECONDS);
Assert.assertNotNull(discoverable);
URL url = URIScheme.createURI(discoverable, path).toURL();
return HttpRequests.execute(HttpRequest.post(url).build(), new DefaultHttpRequestConfig(false));
}
use of io.cdap.cdap.common.http.DefaultHttpRequestConfig in project cdap by caskdata.
the class RouterServiceMainWithSecurityDisabledTest method testRouterServiceWithAuthenticationDisabled.
@Test
public void testRouterServiceWithAuthenticationDisabled() throws Exception {
URL url = getRouterBaseURI().resolve("/").toURL();
HttpResponse response = HttpRequests.execute(HttpRequest.get(url).build(), new DefaultHttpRequestConfig(false));
Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
}
use of io.cdap.cdap.common.http.DefaultHttpRequestConfig in project cdap by cdapio.
the class TrafficRelayServerTest method testRelay.
@Test
public void testRelay() throws Exception {
NettyHttpService httpServer = NettyHttpService.builder("test").setHttpHandlers(new TestHandler()).build();
httpServer.start();
try {
TrafficRelayServer relayServer = new TrafficRelayServer(InetAddress.getLoopbackAddress(), httpServer::getBindAddress);
relayServer.startAndWait();
try {
InetSocketAddress relayAddr = relayServer.getBindAddress();
// GET
URL url = new URL(String.format("http://%s:%d/ping", relayAddr.getHostName(), relayAddr.getPort()));
HttpResponse response = HttpRequests.execute(HttpRequest.get(url).build(), new DefaultHttpRequestConfig(false));
Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
// POST
url = new URL(String.format("http://%s:%d/echo", relayAddr.getHostName(), relayAddr.getPort()));
response = HttpRequests.execute(HttpRequest.post(url).withBody("Testing").build(), new DefaultHttpRequestConfig(false));
Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
Assert.assertEquals("Testing", response.getResponseBodyAsString());
} finally {
relayServer.stopAndWait();
}
} finally {
httpServer.stop();
}
}
Aggregations