提交 5b089ae3 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use current JVM in all tests

上级 f3bc4ccf
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.test; package org.h2.test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -1317,6 +1318,16 @@ public abstract class TestBase { ...@@ -1317,6 +1318,16 @@ public abstract class TestBase {
return System.getProperty("java.class.path"); return System.getProperty("java.class.path");
} }
/**
* Get the path to a java executable of the current process
*
* @return the path to java
*/
public static String getJVM() {
return System.getProperty("java.home") + File.separatorChar + "bin"
+ File.separator + "java";
}
/** /**
* Use up almost all memory. * Use up almost all memory.
* *
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
package org.h2.test; package org.h2.test;
import java.io.File;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -191,16 +190,6 @@ public abstract class TestDb extends TestBase { ...@@ -191,16 +190,6 @@ public abstract class TestDb extends TestBase {
// } // }
} }
/**
* Get the path to a java executable of the current process
*
* @return the path to java
*/
private static String getJVM() {
return System.getProperty("java.home") + File.separatorChar + "bin"
+ File.separator + "java";
}
/** /**
* Build a child process. * Build a child process.
* *
......
...@@ -15,6 +15,8 @@ import java.io.OutputStream; ...@@ -15,6 +15,8 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.h2.test.TestBase;
import org.h2.test.utils.SelfDestructor; import org.h2.test.utils.SelfDestructor;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Task; import org.h2.util.Task;
...@@ -48,7 +50,7 @@ public class TaskProcess { ...@@ -48,7 +50,7 @@ public class TaskProcess {
try { try {
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
list.add("java"); list.add(TestBase.getJVM());
list.add(selfDestruct); list.add(selfDestruct);
list.add("-cp"); list.add("-cp");
list.add("bin" + File.pathSeparator + "."); list.add("bin" + File.pathSeparator + ".");
......
...@@ -37,7 +37,7 @@ public class TestRecoverKillLoop extends TestBase { ...@@ -37,7 +37,7 @@ public class TestRecoverKillLoop extends TestBase {
Random random = new Random(1); Random random = new Random(1);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String[] procDef = { String[] procDef = {
"java", "-cp", getClassPath(), getJVM(), "-cp", getClassPath(),
"-Dtest.dir=data/db", "-Dtest.dir=data/db",
TestRecover.class.getName() TestRecover.class.getName()
}; };
......
...@@ -226,7 +226,7 @@ public abstract class TestHalt extends TestBase { ...@@ -226,7 +226,7 @@ public abstract class TestHalt extends TestBase {
// String classPath = "-cp // String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar"; // .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { "java", selfDestruct, String[] procDef = { getJVM(), selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "" + operations, "" + flags, "" + testValue}; getClass().getName(), "" + operations, "" + flags, "" + testValue};
traceOperation("start: " + StringUtils.arrayCombine(procDef, ' ')); traceOperation("start: " + StringUtils.arrayCombine(procDef, ' '));
......
...@@ -50,7 +50,7 @@ public class TestKill extends TestDb { ...@@ -50,7 +50,7 @@ public class TestKill extends TestDb {
String password = getPassword(); String password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { String[] procDef = {
"java", selfDestruct, getJVM(), selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
"org.h2.test.synth.TestKillProcess", url, user, "org.h2.test.synth.TestKillProcess", url, user,
password, getBaseDir(), "" + ACCOUNTS }; password, getBaseDir(), "" + ACCOUNTS };
......
...@@ -16,7 +16,6 @@ import java.sql.Statement; ...@@ -16,7 +16,6 @@ import java.sql.Statement;
import java.util.Random; import java.util.Random;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.h2.test.TestBase;
import org.h2.test.TestDb; import org.h2.test.TestDb;
import org.h2.test.utils.SelfDestructor; import org.h2.test.utils.SelfDestructor;
...@@ -40,7 +39,7 @@ public class TestKillRestart extends TestDb { ...@@ -40,7 +39,7 @@ public class TestKillRestart extends TestDb {
// "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0", true); // "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0", true);
String user = getUser(), password = getPassword(); String user = getUser(), password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { "java", selfDestruct, String[] procDef = { getJVM(), selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "-url", url, "-user", user, getClass().getName(), "-url", url, "-user", user,
"-password", password }; "-password", password };
......
...@@ -83,7 +83,7 @@ public class TestKillRestartMulti extends TestDb { ...@@ -83,7 +83,7 @@ public class TestKillRestartMulti extends TestDb {
// Inherit error so that the stacktraces reported from SelfDestructor // Inherit error so that the stacktraces reported from SelfDestructor
// show up in our log. // show up in our log.
ProcessBuilder pb = new ProcessBuilder().redirectError(Redirect.INHERIT) ProcessBuilder pb = new ProcessBuilder().redirectError(Redirect.INHERIT)
.command("java", selfDestruct, "-cp", getClassPath(), .command(getJVM(), selfDestruct, "-cp", getClassPath(),
"-ea", "-ea",
getClass().getName(), "-url", url, "-user", user, getClass().getName(), "-url", url, "-user", user,
"-password", password); "-password", password);
......
...@@ -37,7 +37,7 @@ public class TestExit extends TestDb { ...@@ -37,7 +37,7 @@ public class TestExit extends TestDb {
deleteDb("exit"); deleteDb("exit");
String url = getURL(OPEN_WITH_CLOSE_ON_EXIT); String url = getURL(OPEN_WITH_CLOSE_ON_EXIT);
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { "java", selfDestruct, "-cp", getClassPath(), String[] procDef = { getJVM(), selfDestruct, "-cp", getClassPath(),
getClass().getName(), url }; getClass().getName(), url };
Process proc = Runtime.getRuntime().exec(procDef); Process proc = Runtime.getRuntime().exec(procDef);
while (true) { while (true) {
...@@ -60,7 +60,7 @@ public class TestExit extends TestDb { ...@@ -60,7 +60,7 @@ public class TestExit extends TestDb {
fail("did not close database"); fail("did not close database");
} }
url = getURL(OPEN_WITHOUT_CLOSE_ON_EXIT); url = getURL(OPEN_WITHOUT_CLOSE_ON_EXIT);
procDef = new String[] { "java", "-cp", getClassPath(), procDef = new String[] { getJVM(), "-cp", getClassPath(),
getClass().getName(), url }; getClass().getName(), url };
proc = Runtime.getRuntime().exec(procDef); proc = Runtime.getRuntime().exec(procDef);
proc.waitFor(); proc.waitFor();
......
...@@ -74,7 +74,7 @@ public class TestFileLockProcess extends TestDb { ...@@ -74,7 +74,7 @@ public class TestFileLockProcess extends TestDb {
url = getURL(url, true); url = getURL(url, true);
Connection conn = getConnection(url); Connection conn = getConnection(url);
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { "java", selfDestruct, String[] procDef = { getJVM(), selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), url }; getClass().getName(), url };
ArrayList<Process> processes = new ArrayList<>(count); ArrayList<Process> processes = new ArrayList<>(count);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论