Search in sources :

Example 6 with ReadStreamPart

use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.

the class TestDownloadSchema method testDownloadFileAndDeleted.

private void testDownloadFileAndDeleted() throws Exception {
    RestTemplate restTemplate = RestTemplateBuilder.create();
    ReadStreamPart readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/deleteAfterFinished?content=hello", ReadStreamPart.class);
    String hello = readStreamPart.saveAsString().get();
    TestMgr.check(hello, "hello");
    boolean exists = restTemplate.getForObject("servicecomb://springmvc/download/assertLastFileDeleted", boolean.class);
    TestMgr.check(exists, false);
}
Also used : ReadStreamPart(org.apache.servicecomb.foundation.vertx.http.ReadStreamPart) RestTemplate(org.springframework.web.client.RestTemplate)

Example 7 with ReadStreamPart

use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.

the class TestDownloadSchema method testDownloadFileWithNull.

private void testDownloadFileWithNull() throws Exception {
    RestTemplate restTemplate = RestTemplateBuilder.create();
    ReadStreamPart readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/partIsNull?content=test", ReadStreamPart.class);
    String result = readStreamPart.saveAsString().get();
    TestMgr.check(result, "test");
    readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/partIsNull?content=", ReadStreamPart.class);
    result = readStreamPart.saveAsString().get();
    TestMgr.check(result, "");
}
Also used : ReadStreamPart(org.apache.servicecomb.foundation.vertx.http.ReadStreamPart) RestTemplate(org.springframework.web.client.RestTemplate)

Example 8 with ReadStreamPart

use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.

the class RestClientSender method processResponse.

protected Future<Buffer> processResponse(HttpClientResponse httpClientResponse) {
    transportContext.setHttpClientResponse(httpClientResponse);
    if (HttpStatus.isSuccess(httpClientResponse.statusCode()) && transportContext.isDownloadFile()) {
        ReadStreamPart streamPart = new ReadStreamPart(transportContext.getVertxContext(), httpClientResponse);
        future.complete(createResponse(httpClientResponse, streamPart));
    }
    return httpClientResponse.body();
}
Also used : ReadStreamPart(org.apache.servicecomb.foundation.vertx.http.ReadStreamPart)

Example 9 with ReadStreamPart

use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.

the class TestDownloadSchema method testDownloadFileWithNull.

private void testDownloadFileWithNull() throws Exception {
    RestTemplate restTemplate = RestTemplateBuilder.create();
    ReadStreamPart readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/partIsNull?content=test", ReadStreamPart.class);
    String result = readStreamPart.saveAsString().get();
    TestMgr.check(result, "test");
    readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/partIsNull?content=", ReadStreamPart.class);
    result = readStreamPart.saveAsString().get();
    TestMgr.check(result, "");
}
Also used : ReadStreamPart(org.apache.servicecomb.foundation.vertx.http.ReadStreamPart) RestTemplate(org.springframework.web.client.RestTemplate)

Example 10 with ReadStreamPart

use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.

the class TestDownloadSchema method testDownloadFileNotDeleted.

private void testDownloadFileNotDeleted() throws Exception {
    RestTemplate restTemplate = RestTemplateBuilder.create();
    ReadStreamPart readStreamPart = restTemplate.getForObject("servicecomb://springmvc/download/notDeleteAfterFinished?content=hello", ReadStreamPart.class);
    String hello = readStreamPart.saveAsString().get();
    TestMgr.check(hello, "hello");
    boolean exists = restTemplate.getForObject("servicecomb://springmvc/download/assertLastFileDeleted", boolean.class);
    TestMgr.check(exists, true);
}
Also used : ReadStreamPart(org.apache.servicecomb.foundation.vertx.http.ReadStreamPart) RestTemplate(org.springframework.web.client.RestTemplate)

Aggregations

ReadStreamPart (org.apache.servicecomb.foundation.vertx.http.ReadStreamPart)14 RestTemplate (org.springframework.web.client.RestTemplate)6 File (java.io.File)2 HttpEntity (org.springframework.http.HttpEntity)2 HttpHeaders (org.springframework.http.HttpHeaders)2