提交 8d88e36a authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 5176e546
...@@ -6,12 +6,14 @@ ...@@ -6,12 +6,14 @@
*/ */
package org.h2.test.server; package org.h2.test.server;
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;
import java.sql.Statement; import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.unit.SelfDestructor;
import org.h2.util.SortedProperties; import org.h2.util.SortedProperties;
/** /**
...@@ -42,7 +44,10 @@ public class TestAutoServer extends TestBase { ...@@ -42,7 +44,10 @@ public class TestAutoServer extends TestBase {
String user = getUser(), password = getPassword(); String user = getUser(), password = getPassword();
Connection conn = getConnection(url, user, password); Connection conn = getConnection(url, user, password);
conn.close(); conn.close();
String[] procDef = new String[] { "java", "-cp", "bin", TestAutoServer2.class.getName(), url, user, password }; String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct,
"-cp", "bin" + File.pathSeparator + ".",
TestAutoServer2.class.getName(), url, user, password };
// TestAutoServer2.main(new String[]{url, user, password}); // TestAutoServer2.main(new String[]{url, user, password});
Process proc = Runtime.getRuntime().exec(procDef); Process proc = Runtime.getRuntime().exec(procDef);
......
...@@ -24,6 +24,7 @@ import org.h2.test.unit.SelfDestructor; ...@@ -24,6 +24,7 @@ import org.h2.test.unit.SelfDestructor;
import org.h2.tools.Backup; import org.h2.tools.Backup;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.StringUtils;
/** /**
* Tests database recovery by destroying a process that writes to the database. * Tests database recovery by destroying a process that writes to the database.
...@@ -239,16 +240,17 @@ public abstract class TestHalt extends TestBase { ...@@ -239,16 +240,17 @@ 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 classPath = ""; String[] procDef = new String[] { "java", selfDestruct,
String[] command = {"java", selfDestruct, classPath, getClass().getName(), "" + operations, "" + flags, "" + value}; "-cp", "bin" + File.pathSeparator + ".",
traceOperation("start: " + command); getClass().getName(), "" + operations, "" + flags, "" + value};
Process p = Runtime.getRuntime().exec(command); traceOperation("start: " + StringUtils.arrayCombine(procDef, ' '));
Process p = Runtime.getRuntime().exec(procDef);
InputStream in = p.getInputStream(); InputStream in = p.getInputStream();
OutputCatcher catcher = new OutputCatcher(in); OutputCatcher catcher = new OutputCatcher(in);
catcher.start(); catcher.start();
String s = catcher.readLine(5 * 60 * 1000); String s = catcher.readLine(5 * 60 * 1000);
if (s == null) { if (s == null) {
throw new IOException("No reply from process, command: " + command); throw new IOException("No reply from process, command: " + StringUtils.arrayCombine(procDef, ' '));
} else if (s.startsWith("READY")) { } else if (s.startsWith("READY")) {
traceOperation("got reply: " + s); traceOperation("got reply: " + s);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
package org.h2.test.synth; package org.h2.test.synth;
import java.io.File;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -38,7 +39,10 @@ public class TestKill extends TestBase { ...@@ -38,7 +39,10 @@ public class TestKill extends TestBase {
String user = getUser(); String user = getUser();
String password = getPassword(); String password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, "-cp", "bin", "org.h2.test.synth.TestKillProcess", url, user, String[] procDef = new String[] {
"java", selfDestruct,
"-cp", "bin" + File.pathSeparator + ".",
"org.h2.test.synth.TestKillProcess", url, user,
password, baseDir, "" + accounts }; password, baseDir, "" + accounts };
for (int i = 0;; i++) { for (int i = 0;; i++) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
package org.h2.test.synth; package org.h2.test.synth;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -34,7 +35,9 @@ public class TestKillRestart extends TestBase { ...@@ -34,7 +35,9 @@ public class TestKillRestart extends TestBase {
// "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0;STORAGE=TEXT", true); // "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0;STORAGE=TEXT", true);
String user = getUser(), password = getPassword(); String user = getUser(), password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, "-cp", "bin", getClass().getName(), "-url", url, "-user", user, String[] procDef = new String[] { "java", selfDestruct,
"-cp", "bin" + File.pathSeparator + ".",
getClass().getName(), "-url", url, "-user", user,
"-password", password }; "-password", password };
int len = getSize(2, 15); int len = getSize(2, 15);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
package org.h2.test.synth; package org.h2.test.synth;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -44,7 +45,9 @@ public class TestKillRestartMulti extends TestBase { ...@@ -44,7 +45,9 @@ public class TestKillRestartMulti extends TestBase {
user = getUser(); user = getUser();
password = getPassword(); password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, "-cp", "bin", getClass().getName(), "-url", url, "-user", user, String[] procDef = new String[] { "java", selfDestruct,
"-cp", "bin" + File.pathSeparator + ".",
getClass().getName(), "-url", url, "-user", user,
"-password", password }; "-password", password };
deleteDb("killRestartMulti"); deleteDb("killRestartMulti");
int len = getSize(3, 10); int len = getSize(3, 10);
......
...@@ -29,12 +29,11 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -29,12 +29,11 @@ public class TestExit extends TestBase implements DatabaseEventListener {
if (config.codeCoverage || config.networked) { if (config.codeCoverage || config.networked) {
return; return;
} }
String classPath = "bin" + File.pathSeparator + ".";
deleteDb("exit"); deleteDb("exit");
String[] procDef;
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
procDef = new String[] { "java", selfDestruct, "-cp", classPath, getClass().getName(), "" + OPEN_WITH_CLOSE_ON_EXIT }; String[] procDef = new String[] { "java", selfDestruct,
"-cp", "bin" + File.pathSeparator + ".",
getClass().getName(), "" + OPEN_WITH_CLOSE_ON_EXIT };
Process proc = Runtime.getRuntime().exec(procDef); Process proc = Runtime.getRuntime().exec(procDef);
while (true) { while (true) {
int ch = proc.getErrorStream().read(); int ch = proc.getErrorStream().read();
...@@ -55,7 +54,9 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -55,7 +54,9 @@ public class TestExit extends TestBase implements DatabaseEventListener {
if (!getClosedFile().exists()) { if (!getClosedFile().exists()) {
fail("did not close database"); fail("did not close database");
} }
procDef = new String[] { "java", "-cp", classPath, getClass().getName(), "" + OPEN_WITHOUT_CLOSE_ON_EXIT }; procDef = new String[] { "java",
"-cp", "bin" + File.pathSeparator + ".", getClass().getName(),
"" + OPEN_WITHOUT_CLOSE_ON_EXIT };
proc = Runtime.getRuntime().exec(procDef); proc = Runtime.getRuntime().exec(procDef);
proc.waitFor(); proc.waitFor();
Thread.sleep(100); Thread.sleep(100);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论