提交 9d752889 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 a01c023e
......@@ -6,14 +6,12 @@
*/
package org.h2.test.server;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
import org.h2.test.unit.SelfDestructor;
import org.h2.util.SortedProperties;
/**
......@@ -42,14 +40,7 @@ public class TestAutoServer extends TestBase {
deleteDb("autoServer");
String url = getURL("autoServer;AUTO_SERVER=TRUE", true);
String user = getUser(), password = getPassword();
Connection conn = getConnection(url, user, password);
conn.close();
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});
Process proc = Runtime.getRuntime().exec(procDef);
Connection connServer = getConnection(url + ";OPEN_NEW=TRUE", user, password);
int i = SLOW ? Integer.MAX_VALUE : 30;
for (; i > 0; i--) {
......@@ -60,7 +51,7 @@ public class TestAutoServer extends TestBase {
if (server != null) {
String u2 = url.substring(url.indexOf(";"));
u2 = "jdbc:h2:tcp://" + server + "/" + key + u2;
conn = DriverManager.getConnection(u2, user, password);
Connection conn = DriverManager.getConnection(u2, user, password);
conn.close();
break;
}
......@@ -69,17 +60,17 @@ public class TestAutoServer extends TestBase {
fail();
}
conn = getConnection(url);
Connection conn = getConnection(url + ";OPEN_NEW=TRUE");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS HALT FOR \"" + getClass().getName() + ".halt\"");
try {
stat.execute("CALL HALT(11)");
stat.execute("SHUTDOWN");
} catch (SQLException e) {
assertKnownException(e);
// the connection is closed
}
conn.close();
assertEquals(11, proc.exitValue());
// proc.destroy();
connServer.close();
}
/**
......
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.server;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import org.h2.test.TestBase;
/**
* Tests automatic embedded/server mode.
*/
public class TestAutoServer2 extends TestBase {
/**
* Run just this test.
*
* @param a the connection information or empty
*/
public static void main(String[] a) throws Exception {
if (a.length == 3) {
// PrintStream ps = new PrintStream(new File("test.txt"));
PrintStream ps = new PrintStream(new ByteArrayOutputStream());
System.setErr(ps);
System.setOut(ps);
ps.println(new java.sql.Timestamp(System.currentTimeMillis()).toString());
ps.flush();
try {
ps.println("loading");
ps.flush();
org.h2.Driver.load();
ps.println("connecting url:" + a[0] + " user:" + a[1] + " pwd:" + a[2]);
ps.flush();
Connection conn = DriverManager.getConnection(a[0], a[1], a[2]);
ps.println("waiting");
ps.flush();
Thread.sleep(TestAutoServer.SLOW ? 60000 : 5000);
ps.println("closing");
ps.flush();
conn.close();
ps.println("closed");
ps.flush();
} catch (Throwable t) {
t.printStackTrace(ps);
t.printStackTrace();
}
ps.close();
System.exit(0);
} else {
new TestAutoServer2().init().test();
}
}
public void test() throws Exception {
deleteDb("autoServer");
String url = getURL("autoServer;AUTO_SERVER=TRUE", true);
String user = getUser(), password = getPassword();
main(new String[]{url, user, password});
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论