提交 2869f880 authored 作者: Thomas Mueller's avatar Thomas Mueller

The API of the tools changed a bit.

上级 4a6e0d2d
...@@ -137,13 +137,17 @@ ShutdownHandler { ...@@ -137,13 +137,17 @@ ShutdownHandler {
tcpStart = true; tcpStart = true;
pgStart = true; pgStart = true;
} }
SQLException startException = null;
boolean webRunning = false;
if (webStart) { if (webStart) {
try { try {
web = Server.createWebServer(args); web = Server.createWebServer(args);
web.setShutdownHandler(this); web.setShutdownHandler(this);
web.start(); web.start();
webRunning = true;
} catch (SQLException e) { } catch (SQLException e) {
printProblem(e, web); printProblem(e, web);
startException = e;
} }
} }
if (tcpStart) { if (tcpStart) {
...@@ -152,6 +156,9 @@ ShutdownHandler { ...@@ -152,6 +156,9 @@ ShutdownHandler {
tcp.start(); tcp.start();
} catch (SQLException e) { } catch (SQLException e) {
printProblem(e, tcp); printProblem(e, tcp);
if (startException == null) {
startException = e;
}
} }
} }
if (pgStart) { if (pgStart) {
...@@ -160,10 +167,13 @@ ShutdownHandler { ...@@ -160,10 +167,13 @@ ShutdownHandler {
pg.start(); pg.start();
} catch (SQLException e) { } catch (SQLException e) {
printProblem(e, pg); printProblem(e, pg);
if (startException == null) {
startException = e;
}
} }
} }
//## AWT begin ## //## AWT begin ##
if (toolStart && !GraphicsEnvironment.isHeadless()) { if (toolStart && webRunning && !GraphicsEnvironment.isHeadless()) {
if (isWindows) { if (isWindows) {
font = new Font("Dialog", Font.PLAIN, 11); font = new Font("Dialog", Font.PLAIN, 11);
} else { } else {
...@@ -187,8 +197,8 @@ ShutdownHandler { ...@@ -187,8 +197,8 @@ ShutdownHandler {
if (browserStart) { if (browserStart) {
StartBrowser.openURL(web.getURL()); StartBrowser.openURL(web.getURL());
} }
if (!web.isRunning(true)) { if (startException != null) {
throw new SQLException("The web server is not running"); throw startException;
} }
} }
......
...@@ -93,18 +93,18 @@ public class TestTools extends TestBase { ...@@ -93,18 +93,18 @@ public class TestTools extends TestBase {
String result; String result;
Connection conn; Connection conn;
result = runServer(new String[]{"-?"}, 1); result = runServer(new String[]{"-?"}, 0);
assertTrue(result.indexOf("Starts H2 Servers") >= 0); assertTrue(result.indexOf("Starts the H2 Console") >= 0);
assertTrue(result.indexOf("Unknown option") < 0); assertTrue(result.indexOf("Unknown option") < 0);
result = runServer(new String[]{"-xy"}, 1); result = runServer(new String[]{"-xy"}, 1);
assertTrue(result.indexOf("Starts H2 Servers") >= 0); assertTrue(result.indexOf("Starts the H2 Console") >= 0);
assertTrue(result.indexOf("Unsupported option") >= 0); assertTrue(result.indexOf("Unsupported option") >= 0);
result = runServer(new String[]{"-tcp", "-tcpPort", "9001", "-tcpPassword", "abc"}, 0); result = runServer(new String[]{"-tcp", "-tcpPort", "9001", "-tcpPassword", "abc"}, 0);
assertTrue(result.indexOf("tcp://") >= 0); assertTrue(result.indexOf("tcp://") >= 0);
assertTrue(result.indexOf(":9001") >= 0); assertTrue(result.indexOf(":9001") >= 0);
assertTrue(result.indexOf("only local") >= 0); assertTrue(result.indexOf("only local") >= 0);
assertTrue(result.indexOf("Starts H2 Servers") < 0); assertTrue(result.indexOf("Starts the H2 Console") < 0);
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9001/mem:", "sa", "sa"); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9001/mem:", "sa", "sa");
conn.close(); conn.close();
result = runServer(new String[]{"-tcpShutdown", "tcp://localhost:9001", "-tcpPassword", "abc", "-tcpShutdownForce"}, 0); result = runServer(new String[]{"-tcpShutdown", "tcp://localhost:9001", "-tcpPassword", "abc", "-tcpShutdownForce"}, 0);
...@@ -114,7 +114,7 @@ public class TestTools extends TestBase { ...@@ -114,7 +114,7 @@ public class TestTools extends TestBase {
assertTrue(result.indexOf("ssl://") >= 0); assertTrue(result.indexOf("ssl://") >= 0);
assertTrue(result.indexOf(":9001") >= 0); assertTrue(result.indexOf(":9001") >= 0);
assertTrue(result.indexOf("others can") >= 0); assertTrue(result.indexOf("others can") >= 0);
assertTrue(result.indexOf("Starts H2 Servers") < 0); assertTrue(result.indexOf("Starts the H2 Console") < 0);
conn = DriverManager.getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa"); conn = DriverManager.getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa");
conn.close(); conn.close();
...@@ -130,7 +130,6 @@ public class TestTools extends TestBase { ...@@ -130,7 +130,6 @@ public class TestTools extends TestBase {
result = runServer(new String[]{ result = runServer(new String[]{
"-web", "-webPort", "9002", "-webAllowOthers", "-webSSL", "-web", "-webPort", "9002", "-webAllowOthers", "-webSSL",
"-pg", "-pgAllowOthers", "-pgPort", "9003", "-pg", "-pgAllowOthers", "-pgPort", "9003",
"-ftp", "-ftpPort", "9004", "-ftpDir", ".", "-ftpRead", "guest", "-ftpWrite", "sa", "-ftpWritePassword", "sa", "-ftpTask",
"-tcp", "-tcpAllowOthers", "-tcpPort", "9006", "-tcpPassword", "abc"}, 0); "-tcp", "-tcpAllowOthers", "-tcpPort", "9006", "-tcpPassword", "abc"}, 0);
Server stop = server; Server stop = server;
assertTrue(result.indexOf("https://") >= 0); assertTrue(result.indexOf("https://") >= 0);
...@@ -139,8 +138,6 @@ public class TestTools extends TestBase { ...@@ -139,8 +138,6 @@ public class TestTools extends TestBase {
assertTrue(result.indexOf(":9003") >= 0); assertTrue(result.indexOf(":9003") >= 0);
assertTrue(result.indexOf("others can") >= 0); assertTrue(result.indexOf("others can") >= 0);
assertTrue(result.indexOf("only local") < 0); assertTrue(result.indexOf("only local") < 0);
assertTrue(result.indexOf("ftp://") >= 0);
assertTrue(result.indexOf(":9004") >= 0);
assertTrue(result.indexOf("tcp://") >= 0); assertTrue(result.indexOf("tcp://") >= 0);
assertTrue(result.indexOf(":9006") >= 0); assertTrue(result.indexOf(":9006") >= 0);
...@@ -168,6 +165,7 @@ public class TestTools extends TestBase { ...@@ -168,6 +165,7 @@ public class TestTools extends TestBase {
server.run(args); server.run(args);
} catch (SQLException e) { } catch (SQLException e) {
result = 1; result = 1;
e.printStackTrace(ps);
} }
assertEquals(exitCode, result); assertEquals(exitCode, result);
ps.flush(); ps.flush();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论