Search in sources :

Example 16 with HttpResult

use of com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult in project vespa by vespa-engine.

the class StateRestAPITest method retireAndExpectHttp400Response.

private String retireAndExpectHttp400Response(String condition, String responseWait) throws Exception {
    JSONObject json = new JSONObject().put("state", new JSONObject().put("current", new JSONObject().put("state", "retired").put("reason", "No reason"))).put("condition", condition).put("response-wait", responseWait);
    HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
    assertEquals(result.toString(true), 400, result.getHttpReturnCode());
    assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
    StringBuilder print = new StringBuilder();
    result.printContent(print);
    return print.toString();
}
Also used : HttpRequest(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest) JSONObject(org.codehaus.jettison.json.JSONObject) HttpResult(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult)

Aggregations

HttpResult (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult)16 HttpRequest (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest)13 Test (org.junit.Test)7 JSONObject (org.codehaus.jettison.json.JSONObject)3 StringWriter (java.io.StringWriter)2 Distribution (com.yahoo.vdslib.distribution.Distribution)1 StatusHandler (com.yahoo.vespa.clustercontroller.core.status.StatusHandler)1 StatusPageResponse (com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)1 StatusPageServer (com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageServer)1 AsyncOperationImpl (com.yahoo.vespa.clustercontroller.utils.communication.async.AsyncOperationImpl)1 SyncHttpClient (com.yahoo.vespa.clustercontroller.utils.communication.http.SyncHttpClient)1 PrintWriter (java.io.PrintWriter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Header (org.apache.http.Header)1 HttpEntity (org.apache.http.HttpEntity)1 HttpHost (org.apache.http.HttpHost)1 HttpResponse (org.apache.http.HttpResponse)1 HttpDelete (org.apache.http.client.methods.HttpDelete)1