Unverified 提交 08742763 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #747 from katzyn/TestWeb

Fix issue #740
......@@ -706,8 +706,27 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param conn the database connection (the database must be open)
*/
public static void startWebServer(Connection conn) throws SQLException {
startWebServer(conn, false);
}
/**
* Start a web server and a browser that uses the given connection. The
* current transaction is preserved. This is specially useful to manually
* inspect the database when debugging. This method return as soon as the
* user has disconnected.
*
* @param conn the database connection (the database must be open)
* @param ignoreProperties if {@code true} properties from
* {@code .h2.server.properties} will be ignored
*/
public static void startWebServer(Connection conn, boolean ignoreProperties) throws SQLException {
WebServer webServer = new WebServer();
Server web = new Server(webServer, new String[] { "-webPort", "0" });
String[] args;
if (ignoreProperties)
args = new String[] { "-webPort", "0", "-properties", "null"};
else
args = new String[] { "-webPort", "0" };
Server web = new Server(webServer, args);
web.start();
Server server = new Server();
server.web = web;
......
......@@ -11,6 +11,7 @@ import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
import java.security.Principal;
import java.sql.Connection;
import java.sql.SQLException;
......@@ -556,7 +557,7 @@ public class TestWeb extends TestBase {
Task t = new Task() {
@Override
public void call() throws Exception {
Server.startWebServer(conn);
Server.startWebServer(conn, true);
}
};
t.execute();
......@@ -572,7 +573,7 @@ public class TestWeb extends TestBase {
url = client.getBaseUrl(url);
try {
client.get(url, "logout.do");
} catch (Exception e) {
} catch (ConnectException e) {
// the server stops on logout
}
t.get();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论