You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2019/09/26 09:14:54 UTC

[incubator-iotdb] 01/01: IOTDB-242 fix mvn integration-test failed because the files in the target folder changes

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

hxd pushed a commit to branch fix_242_integration_test_failed
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 1985a59902712ceaa5f2a89ad77e2cf47a9b1a57
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Thu Sep 26 17:14:29 2019 +0800

    IOTDB-242 fix mvn integration-test failed because the files in the target folder changes
---
 .../test/java/org/apache/iotdb/client/AbstractScript.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/client/src/test/java/org/apache/iotdb/client/AbstractScript.java b/client/src/test/java/org/apache/iotdb/client/AbstractScript.java
index a041dfa..c4e058a 100644
--- a/client/src/test/java/org/apache/iotdb/client/AbstractScript.java
+++ b/client/src/test/java/org/apache/iotdb/client/AbstractScript.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
 import java.io.*;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 public abstract class AbstractScript {
 
@@ -50,17 +51,19 @@ public abstract class AbstractScript {
 
   protected String getCliPath() {
     // This is usually always set by the JVM
+
     File userDir = new File(System.getProperty("user.dir"));
     if(!userDir.exists()) {
       throw new RuntimeException("user.dir " + userDir.getAbsolutePath() + " doesn't exist.");
     }
-    File targetDir = new File(userDir, "target");
-    File[] files = targetDir.listFiles(pathname -> pathname.isDirectory() && pathname.getName().startsWith("iotdb-client-"));
-    if(files.length != 1) {
-      throw new RuntimeException(
-              "Exactly one directory starting with 'iotdb-client-' should have been found, but was " + files.length);
+    File target = new File(userDir, "target/classes/META-INF/maven/org.apache.iotdb/iotdb-client/pom.properties");
+    Properties properties = new Properties();
+    try {
+      properties.load(new FileReader(target));
+    } catch (IOException e) {
+      return "target/iotdb-client-";
     }
-    return files[0].getAbsolutePath();
+    return new File(userDir, String.format("target/%s-%s", properties.getProperty("artifactId"), properties.getProperty("version"))).getAbsolutePath();
   }
 
   protected abstract void testOnWindows() throws IOException;