play.libs.ws.WSResponse.getBody()

Here are the examples of the java api play.libs.ws.WSResponse.getBody() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

17 Source : StatusService.java
with MIT License
from Azure

private StatusResultServiceModel PingService(String serviceName, String serviceURL) {
    StatusResultServiceModel result = new StatusResultServiceModel(false, serviceName + " check failed");
    try {
        WSResponse response = this.wsRequestBuilder.prepareRequest(serviceURL + "/status").get().toCompletableFuture().get();
        if (response.getStatus() != HttpStatus.SC_OK) {
            result.setMessage("Status code: " + response.getStatus() + ", Response: " + response.getBody());
        } else {
            ObjectMapper mapper = new ObjectMapper();
            StatusServiceModel data = mapper.readValue(response.getBody(), StatusServiceModel.clreplaced);
            result.setStatusResultServiceModel(data.getStatus());
        }
    } catch (Exception e) {
        log.error(e.getMessage());
    }
    return result;
}

15 Source : PlayFrameworkTest.java
with Apache License 2.0
from vladmihalcea

@Test
public void testSavePost() throws Exception {
    // Tests using a scoped WSClient to talk to the server through a port.
    try (WSClient ws = WSTestClient.newClient(this.testServer.getRunningHttpPort().getAsInt())) {
        CompletionStage<WSResponse> stage = ws.url("/").get();
        WSResponse response = stage.toCompletableFuture().get();
        String body = response.getBody();
        replacedertThat(body, containsString("Save Post"));
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

15 Source : IntegrationTest.java
with Creative Commons Zero v1.0 Universal
from playframework

@Test
public void testInServerThroughUrl() throws Exception {
    // Tests using a scoped WSClient to talk to the server through a port.
    try (WSClient ws = WSTestClient.newClient(this.testServer.getRunningHttpPort().getAsInt())) {
        CompletionStage<WSResponse> stage = ws.url("/").get();
        WSResponse response = stage.toCompletableFuture().get();
        String body = response.getBody();
        replacedertThat(body, containsString("Add Person"));
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}