提交 6adccf4a authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved error detection when starting a server with invalid arguments, such as…

Improved error detection when starting a server with invalid arguments, such as "-tcpPort=9091" or "-tcpPort 9091" (as one parameter) instead of "-tcpPort", "9091".
上级 f747bd20
......@@ -14,6 +14,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase;
import org.h2.tools.Server;
......@@ -38,6 +40,7 @@ public class TestWeb extends TestBase {
}
public void test() throws Exception {
testWrongParameters();
testTools();
testTransfer();
testAlreadyRunning();
......@@ -46,6 +49,27 @@ public class TestWeb extends TestBase {
testWebApp();
}
private void testWrongParameters() throws Exception {
try {
Server.createPgServer("-pgPort 8182");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e.getErrorCode());
}
try {
Server.createTcpServer("-tcpPort 8182");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e.getErrorCode());
}
try {
Server.createWebServer("-webPort=8182");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e.getErrorCode());
}
}
private void testAlreadyRunning() throws Exception {
Server server = Server.createWebServer("-webPort", "8182", "-properties", "null");
server.start();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论