提交 70e28cbb 编写于 作者: X Xiangdong Huang 提交者: Jialin Qiao

[IOTDB-242] fix mvn integration-test failed because the files in the target folder changes (#428)

* IOTDB-242 fix mvn integration-test failed because the files in the target folder changes (server and client module)
上级 bee5b612
......@@ -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/maven-archiver/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;
......
......@@ -19,10 +19,12 @@
package org.apache.iotdb.db.script;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -105,18 +107,15 @@ public class EnvScriptIT {
if(!userDir.exists()) {
throw new RuntimeException("user.dir " + userDir.getAbsolutePath() + " doesn't exist.");
}
File targetDir = new File(userDir, "target");
File[] files = targetDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && pathname.getName().startsWith("iotdb-server-");
}
});
if(files.length != 1) {
throw new RuntimeException(
"Exactly one directory starting with 'iotdb-server-' should have been found, but was " + files.length);
File target = new File(userDir, "target/maven-archiver/pom.properties");
Properties properties = new Properties();
assertTrue(target.exists());
try {
properties.load(new FileReader(target));
} catch (IOException e) {
return "target/iotdb-server-";
}
return files[0].getAbsolutePath();
return new File(userDir, String.format("target/%s-%s", properties.getProperty("artifactId"), properties.getProperty("version"))).getAbsolutePath();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册