s1.stop();
}
private void testConsole() throws Exception {
String old = System.getProperty(SysProperties.H2_BROWSER);
Console c = new Console();
c.setOut(new PrintStream(new ByteArrayOutputStream()));
try {
// start including browser
lastUrl = "-";
System.setProperty(SysProperties.H2_BROWSER, "call:" + TestTools.class.getName() + ".openBrowser");
c.runTool("-web", "-webPort", "9002", "-tool", "-browser", "-tcp", "-tcpPort", "9003", "-pg", "-pgPort", "9004");
assertContains(lastUrl, ":9002");
c.shutdown();
// check if starting the browser works
c.runTool("-web", "-webPort", "9002", "-tool");
lastUrl = "-";
c.actionPerformed(new ActionEvent(this, 0, "console"));
assertContains(lastUrl, ":9002");
lastUrl = "-";
// double-click prevention is 100 ms
Thread.sleep(200);
MouseEvent me = new MouseEvent(new Button(), 0, 0, 0, 0, 0, 0, false, MouseEvent.BUTTON1);
c.mouseClicked(me);
assertContains(lastUrl, ":9002");
lastUrl = "-";
// no delay - ignore because it looks like a double click
c.mouseClicked(me);
assertEquals("-", lastUrl);
// open the window
c.actionPerformed(new ActionEvent(this, 0, "status"));
c.actionPerformed(new ActionEvent(this, 0, "exit"));
// check if the service was stopped
c.runTool("-webPort", "9002");
c.shutdown();
// trying to use the same port for two services should fail,
// but also stop the first service
createClassProxy(c.getClass());
assertThrows(ErrorCode.EXCEPTION_OPENING_PORT_2, c).
runTool("-web", "-webPort", "9002", "-tcp", "-tcpPort", "9002");
c.runTool("-web", "-webPort", "9002");
c.shutdown();
} finally {
if (old != null) {
System.setProperty(SysProperties.H2_BROWSER, old);
} else {