use of com.netflix.client.http.HttpResponse in project ribbon by Netflix.
the class RestClientTest method testDelete.
@Test
public void testDelete() throws Exception {
RestClient client = (RestClient) ClientFactory.getNamedClient("google");
HttpRequest request = HttpRequest.newBuilder().uri(server.getServerURI()).verb(HttpRequest.Verb.DELETE).build();
HttpResponse response = client.execute(request);
assertStatusIsOk(response.getStatus());
request = HttpRequest.newBuilder().uri(server.getServerURI()).verb(HttpRequest.Verb.DELETE).entity("").build();
response = client.execute(request);
assertStatusIsOk(response.getStatus());
}
use of com.netflix.client.http.HttpResponse in project ribbon by Netflix.
the class RestClientTest method testSecureClient.
@Test
public void testSecureClient() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("test2.ribbon.IsSecure", "true");
RestClient client = (RestClient) ClientFactory.getNamedClient("test2");
HttpRequest request = HttpRequest.newBuilder().uri(server.getServerURI()).build();
HttpResponse response = client.executeWithLoadBalancer(request);
assertStatusIsOk(response.getStatus());
}
use of com.netflix.client.http.HttpResponse in project ribbon by Netflix.
the class RestClientTest method testVipAsURI.
@Test
public void testVipAsURI() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("test1.ribbon.DeploymentContextBasedVipAddresses", server.getServerPath("/"));
ConfigurationManager.getConfigInstance().setProperty("test1.ribbon.InitializeNFLoadBalancer", "false");
RestClient client = (RestClient) ClientFactory.getNamedClient("test1");
assertNull(client.getLoadBalancer());
HttpRequest request = HttpRequest.newBuilder().uri(new URI("/")).build();
HttpResponse response = client.executeWithLoadBalancer(request);
assertStatusIsOk(response.getStatus());
assertEquals(server.getServerPath("/"), response.getRequestedURI().toString());
}
use of com.netflix.client.http.HttpResponse in project ribbon by Netflix.
the class SecureGetTest method testSunnyDayNoClientAuth.
@Test
public void testSunnyDayNoClientAuth() throws Exception {
AbstractConfiguration cm = ConfigurationManager.getConfigInstance();
String name = "GetPostSecureTest" + ".testSunnyDayNoClientAuth";
String configPrefix = name + "." + "ribbon";
cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsSecure, "true");
cm.setProperty(configPrefix + "." + CommonClientConfigKey.SecurePort, Integer.toString(PORT2));
cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsHostnameValidationRequired, "false");
cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStore, FILE_TS2.getAbsolutePath());
cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStorePassword, PASSWORD);
RestClient rc = (RestClient) ClientFactory.getNamedClient(name);
testServer2.accept();
URI getUri = new URI(SERVICE_URI2 + "test/");
HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build();
HttpResponse response = rc.execute(request);
assertEquals(200, response.getStatus());
}
use of com.netflix.client.http.HttpResponse in project ribbon by Netflix.
the class SecureGetTest method testSunnyDay.
@Test
public void testSunnyDay() throws Exception {
AbstractConfiguration cm = ConfigurationManager.getConfigInstance();
String name = "GetPostSecureTest" + ".testSunnyDay";
String configPrefix = name + "." + "ribbon";
cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsSecure, "true");
cm.setProperty(configPrefix + "." + CommonClientConfigKey.SecurePort, Integer.toString(PORT1));
cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsHostnameValidationRequired, "false");
cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsClientAuthRequired, "true");
cm.setProperty(configPrefix + "." + CommonClientConfigKey.KeyStore, FILE_KS1.getAbsolutePath());
cm.setProperty(configPrefix + "." + CommonClientConfigKey.KeyStorePassword, PASSWORD);
cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStore, FILE_TS1.getAbsolutePath());
cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStorePassword, PASSWORD);
RestClient rc = (RestClient) ClientFactory.getNamedClient(name);
testServer1.accept();
URI getUri = new URI(SERVICE_URI1 + "test/");
HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build();
HttpResponse response = rc.execute(request);
assertEquals(200, response.getStatus());
}
Aggregations