You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by wu...@apache.org on 2018/06/08 12:54:27 UTC

[incubator-servicecomb-java-chassis] 05/05: [SCB-484] bug fix: download test case did not delete downloaded file

This is an automated email from the ASF dual-hosted git repository.

wujimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 7db0781e3c971870e44de1218ffb0734454644f7
Author: wujimin <wu...@huawei.com>
AuthorDate: Tue Jun 5 12:53:53 2018 +0800

    [SCB-484] bug fix: download test case did not delete downloaded file
---
 .../src/main/java/org/apache/servicecomb/demo/TestMgr.java        | 8 ++++++++
 .../apache/servicecomb/demo/springmvc/client/TestDownload.java    | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/TestMgr.java b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/TestMgr.java
index b0086f6..80c5bf0 100644
--- a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/TestMgr.java
+++ b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/TestMgr.java
@@ -66,6 +66,14 @@ public class TestMgr {
     }
   }
 
+  public static void failed(String desc, Throwable e) {
+    Error error = new Error(msg + " | " + desc + ", method is " + getCaller());
+    if (e != null) {
+      error.setStackTrace(error.getStackTrace());
+    }
+    errorList.add(error);
+  }
+
   public static void summary() {
     if (errorList.isEmpty()) {
       LOGGER.info("............. test finished ............");
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDownload.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDownload.java
index c782b68..6b73135 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDownload.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDownload.java
@@ -69,8 +69,9 @@ public class TestDownload {
     future.whenComplete((result, e) -> {
       Object value = result;
       if (File.class.isInstance(value)) {
-        value = readFileToString((File) value);
-        ((File) value).delete();
+        File file = (File) value;
+        value = readFileToString(file);
+        file.delete();
       } else if (byte[].class.isInstance(value)) {
         value = new String((byte[]) value);
       }
@@ -128,6 +129,7 @@ public class TestDownload {
           .allOf(futures.toArray(new CompletableFuture[futures.size()]))
           .get();
     } catch (InterruptedException | ExecutionException e1) {
+      TestMgr.failed("test download failed.", e1);
     }
   }
 }

-- 
To stop receiving notification emails like this one, please contact
wujimin@apache.org.