use of okhttp3.Route in project fabric8-maven-plugin by fabric8io.
the class SpringbootConfigmapBoosterIT method assertApplicationEndpoint.
private void assertApplicationEndpoint(String key, String value) throws Exception {
int nTries = 0;
Response readResponse = null;
String responseContent = null;
Route applicationRoute = getApplicationRouteWithName(testsuiteRepositoryArtifactId);
String hostUrl = applicationRoute.getSpec().getHost() + TEST_ENDPOINT;
do {
readResponse = makeHttpRequest(HttpRequestType.GET, "http://" + hostUrl, null);
responseContent = new JSONObject(readResponse.body().string()).getString(key);
nTries++;
TimeUnit.SECONDS.sleep(10);
} while (nTries < 3 && readResponse.code() != HttpStatus.SC_OK);
if (!responseContent.equals(value))
throw new AssertionError(String.format("Actual : %s, Expected : %s", responseContent, value));
}
use of okhttp3.Route in project fabric8-maven-plugin by fabric8io.
the class VertxHealthchecksBoosterIT method testHealthChecks.
private void testHealthChecks(Route applicationRoute) throws Exception {
String hostUrl = "http://" + applicationRoute.getSpec().getHost();
// Check service state
assert isApplicationUpAndRunning(hostUrl);
// Stop the service
assert makeHttpRequest(HttpRequestType.GET, hostUrl + "/api/stop", null).code() == HttpStatus.SC_OK;
// Check service state after shutdown
Response serviceStatus = makeHttpRequest(HttpRequestType.GET, hostUrl + "/api/health/liveness", null);
assert serviceStatus.code() != HttpStatus.SC_OK;
assert new JSONObject(serviceStatus.body().string()).getString("outcome").equals("DOWN");
// Wait for recovery
assertApplicationRecovery(hostUrl + "/api/greeting", 120);
}
use of okhttp3.Route in project fabric8-maven-plugin by fabric8io.
the class SpringbootCrudBoosterIT method executeCRUDAssertions.
private void executeCRUDAssertions(Route applicationRoute) throws Exception {
String hostUrl = "http://" + applicationRoute.getSpec().getHost() + TEST_ENDPOINT;
JSONObject jsonRequest = new JSONObject();
String testFruitName = "Pineapple";
// limiting test scope, a basic write followed by read is sufficient.
// (C) Create
jsonRequest.put("name", testFruitName);
Response createResponse = makeHttpRequest(HttpRequestType.POST, hostUrl, jsonRequest.toString());
assert createResponse.code() == HttpStatus.SC_CREATED;
Integer fruitId = new JSONObject(createResponse.body().string()).getInt("id");
hostUrl += ("/" + fruitId.toString());
// (R) Read
Response readResponse = makeHttpRequest(HttpRequestType.GET, hostUrl, null);
String fruitName = new JSONObject(readResponse.body().string()).getString("name");
assert readResponse.code() == HttpStatus.SC_OK;
assert fruitName.equals(testFruitName);
}
use of okhttp3.Route in project fabric8-maven-plugin by fabric8io.
the class VertxConfigmapBoosterIT method assertApplicationEndpoint.
private boolean assertApplicationEndpoint(String key, String value) throws Exception {
Route applicationRoute = getApplicationRouteWithName(testsuiteRepositoryArtifactId);
String hostUrl = applicationRoute.getSpec().getHost() + TEST_ENDPOINT;
Response response = makeHttpRequest(HttpRequestType.GET, "http://" + hostUrl, null);
return new JSONObject(response.body().string()).getString(key).equals(value);
}
use of okhttp3.Route in project spring-cloud-netflix by spring-cloud.
the class RibbonCommandContextTest method givenRibbonCommandContextIsSetup.
private void givenRibbonCommandContextIsSetup() {
LinkedMultiValueMap headers = new LinkedMultiValueMap();
LinkedMultiValueMap params = new LinkedMultiValueMap();
RibbonRequestCustomizer requestCustomizer = new RibbonRequestCustomizer<Request.Builder>() {
@Override
public boolean accepts(Class builderClass) {
return builderClass == Request.Builder.class;
}
@Override
public void customize(Request.Builder builder) {
builder.addHeader("from-customizer", "foo");
}
};
ribbonCommandContext = new RibbonCommandContext("serviceId", HttpMethod.POST.toString(), "/my/route", true, headers, params, new ByteArrayInputStream(TEST_CONTENT), Lists.newArrayList(requestCustomizer));
}
Aggregations