Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
80bfedba
提交
80bfedba
authored
10月 14, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved code coverage
上级
fc1cac79
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
80 行增加
和
19 行删除
+80
-19
DbContents.java
h2/src/main/org/h2/bnf/context/DbContents.java
+13
-14
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+26
-0
TestBnf.java
h2/src/test/org/h2/test/unit/TestBnf.java
+41
-5
没有找到文件。
h2/src/main/org/h2/bnf/context/DbContents.java
浏览文件 @
80bfedba
...
@@ -201,22 +201,21 @@ public class DbContents {
...
@@ -201,22 +201,21 @@ public class DbContents {
ArrayList
<
String
>
schemaList
=
New
.
arrayList
();
ArrayList
<
String
>
schemaList
=
New
.
arrayList
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
String
schema
=
rs
.
getString
(
findColumn
(
rs
,
"TABLE_SCHEM"
,
1
));
String
schema
=
rs
.
getString
(
findColumn
(
rs
,
"TABLE_SCHEM"
,
1
));
String
[]
ignoreNames
=
null
;
if
(
isOracle
)
{
if
(
isOracle
)
{
for
(
String
ignore
:
new
String
[]
{
ignoreNames
=
new
String
[]
{
"CTXSYS"
,
"DIP"
,
"DBSNMP"
,
"CTXSYS"
,
"DIP"
,
"DBSNMP"
,
"DMSYS"
,
"EXFSYS"
,
"FLOWS_020100"
,
"FLOWS_FILES"
,
"MDDATA"
,
"MDSYS"
,
"DMSYS"
,
"EXFSYS"
,
"FLOWS_020100"
,
"FLOWS_FILES"
,
"MGMT_VIEW"
,
"OLAPSYS"
,
"ORDSYS"
,
"ORDPLUGINS"
,
"OUTLN"
,
"SI_INFORMTN_SCHEMA"
,
"SYS"
,
"SYSMAN"
,
"MDDATA"
,
"MDSYS"
,
"MGMT_VIEW"
,
"OLAPSYS"
,
"ORDSYS"
,
"SYSTEM"
,
"TSMSYS"
,
"WMSYS"
,
"XDB"
"ORDPLUGINS"
,
"OUTLN"
,
"SI_INFORMTN_SCHEMA"
,
"SYS"
,
})
{
"SYSMAN"
,
"SYSTEM"
,
"TSMSYS"
,
"WMSYS"
,
"XDB"
};
if
(
ignore
.
equals
(
schema
))
{
schema
=
null
;
break
;
}
}
}
else
if
(
isMSSQLServer
)
{
}
else
if
(
isMSSQLServer
)
{
for
(
String
ignore
:
new
String
[]
{
ignoreNames
=
new
String
[]
{
"sys"
,
"db_accessadmin"
,
"sys"
,
"db_accessadmin"
,
"db_backupoperator"
,
"db_datareader"
,
"db_datawriter"
,
"db_ddladmin"
,
"db_backupoperator"
,
"db_datareader"
,
"db_datawriter"
,
"db_denydatareader"
,
"db_denydatawriter"
,
"db_owner"
,
"db_securityadmin"
"db_ddladmin"
,
"db_denydatareader"
,
})
{
"db_denydatawriter"
,
"db_owner"
,
"db_securityadmin"
};
}
if
(
ignoreNames
!=
null
)
{
for
(
String
ignore
:
ignoreNames
)
{
if
(
ignore
.
equals
(
schema
))
{
if
(
ignore
.
equals
(
schema
))
{
schema
=
null
;
schema
=
null
;
break
;
break
;
...
...
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
80bfedba
...
@@ -50,6 +50,7 @@ public class TestWeb extends TestBase {
...
@@ -50,6 +50,7 @@ public class TestWeb extends TestBase {
testStartWebServerWithConnection
();
testStartWebServerWithConnection
();
testServer
();
testServer
();
testWebApp
();
testWebApp
();
testIfExists
();
}
}
private
static
void
testWrongParameters
()
{
private
static
void
testWrongParameters
()
{
...
@@ -199,6 +200,31 @@ public class TestWeb extends TestBase {
...
@@ -199,6 +200,31 @@ public class TestWeb extends TestBase {
server
.
stop
();
server
.
stop
();
}
}
private
void
testIfExists
()
throws
Exception
{
Connection
conn
=
getConnection
(
"jdbc:h2:mem:webExists"
,
getUser
(),
getPassword
());
Server
server
=
new
Server
();
server
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
server
.
runTool
(
"-ifExists"
,
"-web"
,
"-webPort"
,
"8182"
,
"-properties"
,
"null"
,
"-tcp"
,
"-tcpPort"
,
"9101"
);
try
{
String
url
=
"http://localhost:8182"
;
WebClient
client
;
String
result
;
client
=
new
WebClient
();
result
=
client
.
get
(
url
);
client
.
readSessionId
(
result
);
result
=
client
.
get
(
url
,
"login.jsp"
);
result
=
client
.
get
(
url
,
"test.do?driver=org.h2.Driver&url=jdbc:h2:mem:webExists"
+
"&user="
+
getUser
()
+
"&password="
+
getPassword
()
+
"&name=_test_"
);
assertTrue
(
result
.
indexOf
(
"Exception"
)
<
0
);
result
=
client
.
get
(
url
,
"test.do?driver=org.h2.Driver&url=jdbc:h2:mem:web"
+
"&user="
+
getUser
()
+
"&password="
+
getPassword
()
+
"&name=_test_"
);
assertContains
(
result
,
"Exception"
);
}
finally
{
server
.
shutdown
();
conn
.
close
();
}
}
private
void
testWebApp
()
throws
Exception
{
private
void
testWebApp
()
throws
Exception
{
Server
server
=
new
Server
();
Server
server
=
new
Server
();
server
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
server
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
...
...
h2/src/test/org/h2/test/unit/TestBnf.java
浏览文件 @
80bfedba
...
@@ -35,16 +35,22 @@ public class TestBnf extends TestBase {
...
@@ -35,16 +35,22 @@ public class TestBnf extends TestBase {
@Override
@Override
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"
TestB
nf"
);
deleteDb
(
"
b
nf"
);
Connection
conn
=
getConnection
(
"
TestB
nf"
);
Connection
conn
=
getConnection
(
"
b
nf"
);
try
{
try
{
testProcedures
(
conn
);
testProcedures
(
conn
,
false
);
}
finally
{
conn
.
close
();
}
conn
=
getConnection
(
"bnf;mode=mysql"
);
try
{
testProcedures
(
conn
,
true
);
}
finally
{
}
finally
{
conn
.
close
();
conn
.
close
();
}
}
}
}
private
void
testProcedures
(
Connection
conn
)
throws
Exception
{
private
void
testProcedures
(
Connection
conn
,
boolean
isMySQLMode
)
throws
Exception
{
// Register a procedure and check if it is present in DbContents
// Register a procedure and check if it is present in DbContents
conn
.
createStatement
().
execute
(
"DROP ALIAS IF EXISTS CUSTOM_PRINT"
);
conn
.
createStatement
().
execute
(
"DROP ALIAS IF EXISTS CUSTOM_PRINT"
);
conn
.
createStatement
().
execute
(
"CREATE ALIAS CUSTOM_PRINT AS $$ void print(String s) { System.out.println(s); } $$"
);
conn
.
createStatement
().
execute
(
"CREATE ALIAS CUSTOM_PRINT AS $$ void print(String s) { System.out.println(s); } $$"
);
...
@@ -52,13 +58,42 @@ public class TestBnf extends TestBase {
...
@@ -52,13 +58,42 @@ public class TestBnf extends TestBase {
conn
.
createStatement
().
execute
(
"CREATE TABLE TABLE_WITH_STRING_FIELD (STRING_FIELD VARCHAR(50), INT_FIELD integer)"
);
conn
.
createStatement
().
execute
(
"CREATE TABLE TABLE_WITH_STRING_FIELD (STRING_FIELD VARCHAR(50), INT_FIELD integer)"
);
DbContents
dbContents
=
new
DbContents
();
DbContents
dbContents
=
new
DbContents
();
dbContents
.
readContents
(
conn
.
getMetaData
());
dbContents
.
readContents
(
conn
.
getMetaData
());
assertTrue
(
dbContents
.
isH2
());
assertFalse
(
dbContents
.
isDerby
());
assertFalse
(
dbContents
.
isFirebird
());
assertEquals
(
null
,
dbContents
.
quoteIdentifier
(
null
));
if
(
isMySQLMode
)
{
assertTrue
(
dbContents
.
isH2ModeMySQL
());
assertEquals
(
"TEST"
,
dbContents
.
quoteIdentifier
(
"TEST"
));
assertEquals
(
"TEST"
,
dbContents
.
quoteIdentifier
(
"Test"
));
assertEquals
(
"TEST"
,
dbContents
.
quoteIdentifier
(
"test"
));
}
else
{
assertFalse
(
dbContents
.
isH2ModeMySQL
());
assertEquals
(
"TEST"
,
dbContents
.
quoteIdentifier
(
"TEST"
));
assertEquals
(
"\"Test\""
,
dbContents
.
quoteIdentifier
(
"Test"
));
assertEquals
(
"\"test\""
,
dbContents
.
quoteIdentifier
(
"test"
));
}
assertFalse
(
dbContents
.
isMSSQLServer
());
assertFalse
(
dbContents
.
isMySQL
());
assertFalse
(
dbContents
.
isOracle
());
assertFalse
(
dbContents
.
isPostgreSQL
());
assertFalse
(
dbContents
.
isSQLite
());
DbSchema
defaultSchema
=
dbContents
.
getDefaultSchema
();
DbSchema
defaultSchema
=
dbContents
.
getDefaultSchema
();
DbProcedure
[]
procedures
=
defaultSchema
.
getProcedures
();
DbProcedure
[]
procedures
=
defaultSchema
.
getProcedures
();
Set
<
String
>
procedureName
=
new
HashSet
<
String
>(
procedures
.
length
);
Set
<
String
>
procedureName
=
new
HashSet
<
String
>(
procedures
.
length
);
for
(
DbProcedure
procedure
:
procedures
)
{
for
(
DbProcedure
procedure
:
procedures
)
{
assertTrue
(
defaultSchema
==
procedure
.
getSchema
());
procedureName
.
add
(
procedure
.
getName
());
procedureName
.
add
(
procedure
.
getName
());
}
}
assertTrue
(
procedureName
.
contains
(
"CUSTOM_PRINT"
));
if
(
isMySQLMode
)
{
assertTrue
(
procedureName
.
contains
(
"custom_print"
));
}
else
{
assertTrue
(
procedureName
.
contains
(
"CUSTOM_PRINT"
));
}
if
(
isMySQLMode
)
{
return
;
}
// Test completion
// Test completion
Bnf
bnf
=
Bnf
.
getInstance
(
null
);
Bnf
bnf
=
Bnf
.
getInstance
(
null
);
...
@@ -69,6 +104,7 @@ public class TestBnf extends TestBase {
...
@@ -69,6 +104,7 @@ public class TestBnf extends TestBase {
// Test partial
// Test partial
Map
<
String
,
String
>
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PR"
);
Map
<
String
,
String
>
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PR"
);
assertTrue
(
tokens
.
values
().
contains
(
"INT"
));
assertTrue
(
tokens
.
values
().
contains
(
"INT"
));
// Test parameters
// Test parameters
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PRINT("
);
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PRINT("
);
assertTrue
(
tokens
.
values
().
contains
(
"STRING_FIELD"
));
assertTrue
(
tokens
.
values
().
contains
(
"STRING_FIELD"
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论