use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.
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);
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.
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);
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.
the class RestClientInvocation method handleResponse.
protected void handleResponse(HttpClientResponse httpClientResponse) {
this.clientResponse = httpClientResponse;
if (HttpStatus.isSuccess(clientResponse.statusCode()) && restOperationMeta.isDownloadFile()) {
ReadStreamPart part = new ReadStreamPart(httpClientWithContext.context(), httpClientResponse);
invocation.getHandlerContext().put(RestConst.READ_STREAM_PART, part);
processResponseBody(null);
return;
}
httpClientResponse.exceptionHandler(e -> {
invocation.getTraceIdLogger().error(LOGGER, "Failed to receive response, local:{}, remote:{}, message={}.", getLocalAddress(), httpClientResponse.netSocket().remoteAddress(), ExceptionUtils.getExceptionMessageWithoutTrace(e));
fail(e);
});
clientResponse.bodyHandler(this::processResponseBody);
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.
the class TestCodeFirstJaxrs method testDeleteAfterFinished.
private void testDeleteAfterFinished() throws Exception {
ReadStreamPart part = downloadInf.testDeleteAfterFinished("hello", "hello content");
TestMgr.check(part.saveAsString().get(), "hello content");
File systemTempFile = new File(System.getProperty("java.io.tmpdir"));
File file = new File(systemTempFile, "hello");
TestMgr.check(file.exists(), false);
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project java-chassis by ServiceComb.
the class TestDownload method templateExchange.
private ReadStreamPart templateExchange(String methodPath, String type) {
HttpHeaders headers = new HttpHeaders();
headers.add("accept", type);
HttpEntity<?> entity = new HttpEntity<>(headers);
ResponseEntity<ReadStreamPart> response = consumers.getSCBRestTemplate().exchange("/" + methodPath + "?content={content}", HttpMethod.GET, entity, ReadStreamPart.class, content);
return response.getBody();
}
Aggregations