提交 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; ...@@ -14,6 +14,8 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.Server; import org.h2.tools.Server;
...@@ -38,6 +40,7 @@ public class TestWeb extends TestBase { ...@@ -38,6 +40,7 @@ public class TestWeb extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testWrongParameters();
testTools(); testTools();
testTransfer(); testTransfer();
testAlreadyRunning(); testAlreadyRunning();
...@@ -46,6 +49,27 @@ public class TestWeb extends TestBase { ...@@ -46,6 +49,27 @@ public class TestWeb extends TestBase {
testWebApp(); 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 { private void testAlreadyRunning() throws Exception {
Server server = Server.createWebServer("-webPort", "8182", "-properties", "null"); Server server = Server.createWebServer("-webPort", "8182", "-properties", "null");
server.start(); server.start();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论