Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ad1a436f
提交
ad1a436f
authored
6月 04, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
junit compatibility
上级
f2c6461d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
77 个修改的文件
包含
1898 行增加
和
1896 行删除
+1898
-1896
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+81
-79
TestAutoRecompile.java
h2/src/test/org/h2/test/db/TestAutoRecompile.java
+5
-5
TestBigResult.java
h2/src/test/org/h2/test/db/TestBigResult.java
+15
-15
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+56
-56
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+4
-4
TestCsv.java
h2/src/test/org/h2/test/db/TestCsv.java
+79
-79
TestEncryptedDb.java
h2/src/test/org/h2/test/db/TestEncryptedDb.java
+5
-5
TestExclusive.java
h2/src/test/org/h2/test/db/TestExclusive.java
+2
-2
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+26
-26
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+55
-55
TestIndex.java
h2/src/test/org/h2/test/db/TestIndex.java
+20
-20
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+57
-57
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+24
-24
TestLogFile.java
h2/src/test/org/h2/test/db/TestLogFile.java
+3
-3
TestMultiConn.java
h2/src/test/org/h2/test/db/TestMultiConn.java
+7
-7
TestMultiDimension.java
h2/src/test/org/h2/test/db/TestMultiDimension.java
+11
-11
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+3
-3
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+38
-38
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+18
-18
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+7
-7
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+8
-8
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+1
-1
TestSQLInjection.java
h2/src/test/org/h2/test/db/TestSQLInjection.java
+16
-16
TestScript.java
h2/src/test/org/h2/test/db/TestScript.java
+1
-1
TestScriptSimple.java
h2/src/test/org/h2/test/db/TestScriptSimple.java
+1
-1
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+7
-7
TestSessionsLocks.java
h2/src/test/org/h2/test/db/TestSessionsLocks.java
+18
-18
TestTempTables.java
h2/src/test/org/h2/test/db/TestTempTables.java
+4
-4
TestTransaction.java
h2/src/test/org/h2/test/db/TestTransaction.java
+12
-12
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+11
-11
TestTwoPhaseCommit.java
h2/src/test/org/h2/test/db/TestTwoPhaseCommit.java
+5
-5
TestView.java
h2/src/test/org/h2/test/db/TestView.java
+2
-2
TestBatchUpdates.java
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
+2
-2
TestCallableStatement.java
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
+6
-6
TestCancel.java
h2/src/test/org/h2/test/jdbc/TestCancel.java
+10
-10
TestDatabaseEventListener.java
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
+3
-3
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+266
-266
TestNativeSQL.java
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
+8
-8
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+161
-161
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+333
-333
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+72
-72
TestTransactionIsolation.java
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
+18
-18
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+134
-134
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+8
-8
TestConnectionPool.java
h2/src/test/org/h2/test/jdbcx/TestConnectionPool.java
+1
-1
TestDataSource.java
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
+1
-1
TestXA.java
h2/src/test/org/h2/test/jdbcx/TestXA.java
+1
-1
TestMvcc1.java
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
+22
-22
TestMvcc3.java
h2/src/test/org/h2/test/mvcc/TestMvcc3.java
+4
-4
TestNestedLoop.java
h2/src/test/org/h2/test/server/TestNestedLoop.java
+6
-6
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+25
-25
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+22
-22
TestKill.java
h2/src/test/org/h2/test/synth/TestKill.java
+5
-5
TestSimpleIndex.java
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
+3
-3
TestTimer.java
h2/src/test/org/h2/test/synth/TestTimer.java
+1
-1
TestMultiOrder.java
h2/src/test/org/h2/test/synth/thread/TestMultiOrder.java
+3
-3
TestBitField.java
h2/src/test/org/h2/test/unit/TestBitField.java
+3
-3
TestCompress.java
h2/src/test/org/h2/test/unit/TestCompress.java
+2
-2
TestDataPage.java
h2/src/test/org/h2/test/unit/TestDataPage.java
+2
-2
TestFile.java
h2/src/test/org/h2/test/unit/TestFile.java
+3
-3
TestFileLock.java
h2/src/test/org/h2/test/unit/TestFileLock.java
+1
-1
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+33
-33
TestFtp.java
h2/src/test/org/h2/test/unit/TestFtp.java
+2
-2
TestIntArray.java
h2/src/test/org/h2/test/unit/TestIntArray.java
+5
-5
TestOverflow.java
h2/src/test/org/h2/test/unit/TestOverflow.java
+1
-1
TestReader.java
h2/src/test/org/h2/test/unit/TestReader.java
+1
-1
TestSampleApps.java
h2/src/test/org/h2/test/unit/TestSampleApps.java
+2
-2
TestScriptReader.java
h2/src/test/org/h2/test/unit/TestScriptReader.java
+11
-11
TestSecurity.java
h2/src/test/org/h2/test/unit/TestSecurity.java
+2
-2
TestServlet.java
h2/src/test/org/h2/test/unit/TestServlet.java
+4
-4
TestShell.java
h2/src/test/org/h2/test/unit/TestShell.java
+1
-1
TestStreams.java
h2/src/test/org/h2/test/unit/TestStreams.java
+1
-1
TestStringCache.java
h2/src/test/org/h2/test/unit/TestStringCache.java
+2
-2
TestStringUtils.java
h2/src/test/org/h2/test/unit/TestStringUtils.java
+22
-22
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+70
-70
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+8
-8
TestValueHashMap.java
h2/src/test/org/h2/test/unit/TestValueHashMap.java
+5
-5
没有找到文件。
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestAutoRecompile.java
浏览文件 @
ad1a436f
...
...
@@ -24,12 +24,12 @@ public class TestAutoRecompile extends TestBase {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST"
);
check
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
1
);
stat
.
execute
(
"ALTER TABLE TEST ADD COLUMN NAME VARCHAR(255)"
);
check
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
2
);
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, X INT, Y INT)"
);
check
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
3
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
3
);
// TODO test auto-recompile with insert..select, views and so on
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(1, 2, 3)"
);
...
...
@@ -38,13 +38,13 @@ public class TestAutoRecompile extends TestBase {
prep
.
execute
();
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
prep
.
execute
();
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestBigResult.java
浏览文件 @
ad1a436f
...
...
@@ -45,11 +45,11 @@ public class TestBigResult extends TestBase {
"WHERE SQL_STMT='commit' OR SQL_STMT='rollback')"
);
int
count
=
0
,
last
=
1
;
while
(
rs
.
next
())
{
check
(
last
,
rs
.
getInt
(
1
));
assertEquals
(
last
,
rs
.
getInt
(
1
));
last
+=
2
;
count
++;
}
check
(
len
/
2
,
count
);
assertEquals
(
len
/
2
,
count
);
conn
.
close
();
}
...
...
@@ -96,15 +96,15 @@ public class TestBigResult extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 85"
);
for
(
int
i
=
85
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 95"
);
for
(
int
i
=
95
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 105"
);
for
(
int
i
=
105
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
conn
.
close
();
}
...
...
@@ -133,22 +133,22 @@ public class TestBigResult extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
rs
.
next
();
check
(
i
,
rs
.
getInt
(
1
));
check
(
"Name "
+
i
,
rs
.
getString
(
2
));
check
(
"First Name "
+
i
,
rs
.
getString
(
3
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
"Name "
+
i
,
rs
.
getString
(
2
));
assertEquals
(
"First Name "
+
i
,
rs
.
getString
(
3
));
assertEquals
(
i
*
10
,
rs
.
getInt
(
4
));
assertEquals
(
i
*
i
,
rs
.
getInt
(
5
));
}
stat
.
setMaxRows
(
len
+
1
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID >= 1000 ORDER BY ID"
);
for
(
int
i
=
1000
;
i
<
len
;
i
++)
{
rs
.
next
();
check
(
i
,
rs
.
getInt
(
1
));
check
(
"Name "
+
i
,
rs
.
getString
(
2
));
check
(
"First Name "
+
i
,
rs
.
getString
(
3
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
"Name "
+
i
,
rs
.
getString
(
2
));
assertEquals
(
"First Name "
+
i
,
rs
.
getString
(
3
));
assertEquals
(
i
*
10
,
rs
.
getInt
(
4
));
assertEquals
(
i
*
i
,
rs
.
getInt
(
5
));
}
stat
.
execute
(
"SET MAX_MEMORY_ROWS 2"
);
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
ad1a436f
...
...
@@ -61,14 +61,14 @@ public class TestCluster extends TestBase {
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9191/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
// test regular cluster connection
...
...
@@ -130,8 +130,8 @@ public class TestCluster extends TestBase {
prep
.
setInt
(
1
,
i
);
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
check
(
rs
.
getString
(
2
),
"Data"
+
i
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
2
),
"Data"
+
i
);
assert
False
(
rs
.
next
());
}
}
...
...
h2/src/test/org/h2/test/db/TestCsv.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestEncryptedDb.java
浏览文件 @
ad1a436f
...
...
@@ -33,22 +33,22 @@ public class TestEncryptedDb extends TestBase {
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
conn
=
getConnection
(
"exclusive;CIPHER=AES"
,
"sa"
,
"1234 1234"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
=
getConnection
(
"exclusive;CIPHER=AES"
,
"sa"
,
"123 123"
);
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
check
(
rs
.
next
());
check
(
1
,
rs
.
getInt
(
1
));
check
False
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestExclusive.java
浏览文件 @
ad1a436f
...
...
@@ -27,7 +27,7 @@ public class TestExclusive extends TestBase {
conn2
.
close
();
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"set exclusive false"
);
...
...
@@ -57,7 +57,7 @@ public class TestExclusive extends TestBase {
break
;
}
}
check
(
state
[
0
],
2
);
assertEquals
(
state
[
0
],
2
);
stat
.
execute
(
"set exclusive true"
);
conn
.
close
();
...
...
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
ad1a436f
...
...
@@ -97,29 +97,29 @@ public class TestFullText extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hallo Welt')"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"CALL "
+
prefix
+
"REINDEX()"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(4, 'Hello World')"
);
...
...
@@ -127,38 +127,38 @@ public class TestFullText extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0) ORDER BY QUERY"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=3"
);
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=3"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=4"
);
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=4"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=5"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=5"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 1, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
check
False
(
rs
.
next
());
assertTrue
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 2) ORDER BY QUERY"
);
rs
.
next
();
check
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
assertTrue
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
rs
.
next
();
check
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
check
False
(
rs
.
next
());
assertTrue
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 2, 1) ORDER BY QUERY"
);
rs
.
next
();
check
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
assertTrue
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
rs
.
next
();
check
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
check
False
(
rs
.
next
());
assertTrue
(
rs
.
getString
(
1
).
startsWith
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"="
));
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('1', 0, 0)"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assert
False
(
rs
.
next
());
conn
.
close
();
conn
=
getConnection
(
"fullText"
);
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
ad1a436f
...
...
@@ -50,18 +50,18 @@ public class TestFunctions extends TestBase {
out
.
close
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT LENGTH(FILE_READ('"
+
baseDir
+
"/test.txt')) LEN"
);
rs
.
next
();
check
(
f
.
length
(),
rs
.
getInt
(
1
));
assertEquals
(
f
.
length
(),
rs
.
getInt
(
1
));
rs
=
stat
.
executeQuery
(
"SELECT FILE_READ('"
+
baseDir
+
"/test.txt') PROP"
);
rs
.
next
();
Properties
p2
=
new
Properties
();
p2
.
load
(
rs
.
getBinaryStream
(
1
));
check
(
prop
.
size
(),
p2
.
size
());
assertEquals
(
prop
.
size
(),
p2
.
size
());
rs
=
stat
.
executeQuery
(
"SELECT FILE_READ('"
+
baseDir
+
"/test.txt', NULL) PROP"
);
rs
.
next
();
String
ps
=
rs
.
getString
(
1
);
FileReader
r
=
new
FileReader
(
f
);
String
ps2
=
IOUtils
.
readStringAndClose
(
r
,
-
1
);
check
(
ps
,
ps2
);
assertEquals
(
ps
,
ps2
);
f
.
delete
();
conn
.
close
();
}
...
...
@@ -99,7 +99,7 @@ public class TestFunctions extends TestBase {
stat
.
execute
(
"CREATE AGGREGATE IF NOT EXISTS MEDIAN FOR \""
+
MedianString
.
class
.
getName
()
+
"\""
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)"
);
rs
.
next
();
check
(
"5"
,
rs
.
getString
(
1
));
assertEquals
(
"5"
,
rs
.
getString
(
1
));
conn
.
close
();
if
(
config
.
memory
)
{
...
...
@@ -111,8 +111,8 @@ public class TestFunctions extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)"
);
DatabaseMetaData
meta
=
conn
.
getMetaData
();
rs
=
meta
.
getProcedures
(
null
,
null
,
"MEDIAN"
);
check
(
rs
.
next
());
check
False
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SCRIPT"
);
boolean
found
=
false
;
while
(
rs
.
next
())
{
...
...
@@ -121,7 +121,7 @@ public class TestFunctions extends TestBase {
found
=
true
;
}
}
check
(
found
);
assertTrue
(
found
);
stat
.
execute
(
"DROP AGGREGATE MEDIAN"
);
stat
.
execute
(
"DROP AGGREGATE IF EXISTS MEDIAN"
);
conn
.
close
();
...
...
@@ -140,102 +140,102 @@ public class TestFunctions extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(1, 'Hello')"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(2, 'World')"
);
stat
.
execute
(
"CREATE ALIAS SELECT_F FOR \""
+
getClass
().
getName
()
+
".select\""
);
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"World"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"World"
);
assertEquals
(
rs
.
getString
(
1
),
"World"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
"Hello"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
"Hello"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
rs
.
next
();
check
(
"((1, Hello))"
,
rs
.
getString
(
1
));
assertEquals
(
"((1, Hello))"
,
rs
.
getString
(
1
));
rs
.
next
();
check
(
"((2, World))"
,
rs
.
getString
(
1
));
check
False
(
rs
.
next
());
assertEquals
(
"((2, World))"
,
rs
.
getString
(
1
));
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
rs
.
next
();
check
(
"((1, Hello), (2, World))"
,
rs
.
getString
(
1
));
check
False
(
rs
.
next
());
assertEquals
(
"((1, Hello), (2, World))"
,
rs
.
getString
(
1
));
assert
False
(
rs
.
next
());
try
{
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('ERROR')"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
"42001"
,
e
.
getSQLState
());
assertEquals
(
"42001"
,
e
.
getSQLState
());
}
stat
.
execute
(
"CREATE ALIAS SIMPLE FOR \""
+
getClass
().
getName
()
+
".simpleResultSet\""
);
rs
=
stat
.
executeQuery
(
"CALL SIMPLE(2, 1,1,1,1,1,1,1)"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
0
);
check
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"World"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM SIMPLE(1, 1,1,1,1,1,1,1)"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
0
);
check
(
rs
.
getString
(
2
),
"Hello"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS ARRAY FOR \""
+
getClass
().
getName
()
+
".getArray\""
);
rs
=
stat
.
executeQuery
(
"CALL ARRAY()"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
0
);
check
(
rs
.
getString
(
2
),
"Hello"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS ROOT FOR \""
+
getClass
().
getName
()
+
".root\""
);
rs
=
stat
.
executeQuery
(
"CALL ROOT(9)"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
3
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS MAX_ID FOR \""
+
getClass
().
getName
()
+
".selectMaxId\""
);
rs
=
stat
.
executeQuery
(
"CALL MAX_ID()"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM MAX_ID()"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"CALL CASE WHEN -9 < 0 THEN 0 ELSE ROOT(-9) END"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
0
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
0
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS blob2stream FOR \""
+
getClass
().
getName
()
+
".blob2stream\""
);
stat
.
execute
(
"CREATE ALIAS stream2stream FOR \""
+
getClass
().
getName
()
+
".stream2stream\""
);
...
...
@@ -254,10 +254,10 @@ public class TestFunctions extends TestBase {
stat
.
execute
(
"CREATE ALIAS NULL_RESULT FOR \""
+
getClass
().
getName
()
+
".nullResultSet\""
);
rs
=
stat
.
executeQuery
(
"CALL NULL_RESULT()"
);
check
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
null
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
null
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -266,7 +266,7 @@ public class TestFunctions extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"CALL "
+
sql
);
rs
.
next
();
String
s
=
rs
.
getString
(
1
);
check
(
value
,
s
);
assertEquals
(
value
,
s
);
}
public
static
BufferedInputStream
blob2stream
(
Blob
value
)
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestIndex.java
浏览文件 @
ad1a436f
...
...
@@ -99,11 +99,11 @@ public class TestIndex extends TestBase {
String
s1
=
rs
.
next
()
?
rs
.
getString
(
1
)
:
null
;
rs
=
stat
.
executeQuery
(
sql
.
replace
(
'A'
,
'B'
));
String
s2
=
rs
.
next
()
?
rs
.
getString
(
1
)
:
null
;
check
(
s1
,
s2
);
assertEquals
(
s1
,
s2
);
}
else
{
int
count1
=
stat
.
getUpdateCount
();
int
count2
=
stat
.
executeUpdate
(
sql
.
replace
(
'A'
,
'B'
));
check
(
count1
,
count2
);
assertEquals
(
count1
,
count2
);
}
}
stat
.
execute
(
"drop table testA, testB"
);
...
...
@@ -129,20 +129,20 @@ public class TestIndex extends TestBase {
stat
.
execute
(
"CREATE INDEX IDX_ND ON TEST(ID DESC)"
);
rs
=
conn
.
getMetaData
().
getIndexInfo
(
null
,
null
,
"TEST"
,
false
,
false
);
rs
.
next
();
check
(
rs
.
getString
(
"ASC_OR_DESC"
),
"D"
);
check
(
rs
.
getInt
(
"SORT_TYPE"
),
SortOrder
.
DESCENDING
);
assertEquals
(
rs
.
getString
(
"ASC_OR_DESC"
),
"D"
);
assertEquals
(
rs
.
getInt
(
"SORT_TYPE"
),
SortOrder
.
DESCENDING
);
stat
.
execute
(
"INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1, 30)"
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
11
);
assertEquals
(
rs
.
getInt
(
1
),
11
);
reconnect
();
rs
=
conn
.
getMetaData
().
getIndexInfo
(
null
,
null
,
"TEST"
,
false
,
false
);
rs
.
next
();
check
(
rs
.
getString
(
"ASC_OR_DESC"
),
"D"
);
check
(
rs
.
getInt
(
"SORT_TYPE"
),
SortOrder
.
DESCENDING
);
assertEquals
(
rs
.
getString
(
"ASC_OR_DESC"
),
"D"
);
assertEquals
(
rs
.
getInt
(
"SORT_TYPE"
),
SortOrder
.
DESCENDING
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
11
);
assertEquals
(
rs
.
getInt
(
1
),
11
);
stat
.
execute
(
"DROP TABLE TEST"
);
conn
.
close
();
}
...
...
@@ -166,7 +166,7 @@ public class TestIndex extends TestBase {
while
(
rs
.
next
())
{
int
id
=
rs
.
getInt
(
"ID"
);
String
name
=
rs
.
getString
(
"NAME"
);
check
(
""
+
id
,
name
.
trim
());
assertEquals
(
""
+
id
,
name
.
trim
());
}
if
(!
config
.
memory
)
{
reconnect
();
...
...
@@ -174,7 +174,7 @@ public class TestIndex extends TestBase {
while
(
rs
.
next
())
{
int
id
=
rs
.
getInt
(
"ID"
);
String
name
=
rs
.
getString
(
"NAME"
);
check
(
""
+
id
,
name
.
trim
());
assertEquals
(
""
+
id
,
name
.
trim
());
}
}
stat
.
execute
(
"DROP TABLE TEST"
);
...
...
@@ -247,8 +247,8 @@ public class TestIndex extends TestBase {
prep
.
setInt
(
1
,
a
);
prep
.
setInt
(
2
,
a
);
prep
.
execute
();
check
(
1
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
a
));
check
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A=-1-"
+
a
));
assertEquals
(
1
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
a
));
assertEquals
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A=-1-"
+
a
));
}
reconnect
();
...
...
@@ -256,12 +256,12 @@ public class TestIndex extends TestBase {
prep
=
conn
.
prepareStatement
(
"DELETE FROM TEST WHERE A=?"
);
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
if
(
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
a
)
!=
1
)
{
check
(
1
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
a
));
assertEquals
(
1
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
a
));
}
prep
.
setInt
(
1
,
a
);
check
(
1
,
prep
.
executeUpdate
());
assertEquals
(
1
,
prep
.
executeUpdate
());
}
check
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
assertEquals
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
}
void
testMultiColumnIndex
()
throws
Exception
{
...
...
@@ -280,12 +280,12 @@ public class TestIndex extends TestBase {
prep
=
conn
.
prepareStatement
(
"DELETE FROM TEST WHERE A=?"
);
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
log
(
stat
,
"SELECT * FROM TEST"
);
check
(
2
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
(
len
-
a
-
1
)));
check
((
len
-
a
)
*
2
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
assertEquals
(
2
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST WHERE A="
+
(
len
-
a
-
1
)));
assertEquals
((
len
-
a
)
*
2
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
prep
.
setInt
(
1
,
len
-
a
-
1
);
prep
.
execute
();
}
check
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
assertEquals
(
0
,
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
}
void
testMultiColumnHashIndex
()
throws
Exception
{
...
...
@@ -324,8 +324,8 @@ public class TestIndex extends TestBase {
reconnect
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE DATA <> 'i('||a||','||b||')u('||a||','||b||')'"
);
check
False
(
rs
.
next
());
check
(
len
*
(
len
/
2
),
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
assert
False
(
rs
.
next
());
assertEquals
(
len
*
(
len
/
2
),
getValue
(
stat
,
"SELECT COUNT(*) FROM TEST"
));
stat
.
execute
(
"DROP TABLE TEST"
);
}
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
ad1a436f
...
...
@@ -86,10 +86,10 @@ public class TestLinkedTable extends TestBase {
stat2
.
execute
(
"CREATE LINKED TABLE two('org.h2.Driver', 'jdbc:h2:mem:one', 'sa', 'sa', 'A');"
);
ResultSet
rs
=
stat2
.
executeQuery
(
"SELECT * FROM one"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getInt
(
1
),
2
);
rs
=
stat2
.
executeQuery
(
"SELECT * FROM two"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
conn
.
close
();
conn2
.
close
();
}
...
...
@@ -137,7 +137,7 @@ public class TestLinkedTable extends TestBase {
stat2
.
executeUpdate
(
"UPDATE TEST_LINK_U SET ID=ID+1"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat2
.
executeUpdate
(
"UPDATE TEST_LINK_DI SET ID=ID+1"
);
stat2
.
executeUpdate
(
"UPDATE TEST_LINK_U SET NAME=NAME || ID"
);
...
...
@@ -145,30 +145,30 @@ public class TestLinkedTable extends TestBase {
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_DI ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
check
(
rs
.
getString
(
2
),
"World3"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assert
False
(
rs
.
next
());
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_U ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
check
(
rs
.
getString
(
2
),
"World3"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
check
(
rs
.
getString
(
2
),
"World3"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assert
False
(
rs
.
next
());
conn
.
close
();
conn2
.
close
();
...
...
@@ -227,7 +227,7 @@ public class TestLinkedTable extends TestBase {
stat
.
execute
(
"SELECT * FROM TEST_TEMP"
);
error
(
"temp table must not be persistent"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
.
close
();
...
...
@@ -240,8 +240,8 @@ public class TestLinkedTable extends TestBase {
testRow
(
stat
,
"LINK_TEST"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
check
(
10
,
meta
.
getPrecision
(
1
));
check
(
200
,
meta
.
getPrecision
(
2
));
assertEquals
(
10
,
meta
.
getPrecision
(
1
));
assertEquals
(
200
,
meta
.
getPrecision
(
2
));
conn
.
close
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
baseDir
+
"/linked2"
,
"sa2"
,
"def"
);
...
...
@@ -252,41 +252,41 @@ public class TestLinkedTable extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
4
);
assertEquals
(
rs
.
getInt
(
1
),
4
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST WHERE NAME='Link Test'"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
int
uc
=
stat
.
executeUpdate
(
"DELETE FROM LINK_TEST WHERE ID=3"
);
check
(
uc
,
1
);
assertEquals
(
uc
,
1
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
rs
.
getInt
(
1
),
3
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='LINK_TEST'"
);
rs
.
next
();
check
(
rs
.
getString
(
"TABLE_TYPE"
),
"TABLE LINK"
);
assertEquals
(
rs
.
getString
(
"TABLE_TYPE"
),
"TABLE LINK"
);
rs
.
next
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST WHERE ID=0"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XT"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getInt
(
"ID"
)
==
0
&&
!
rs
.
wasNull
());
check
(
rs
.
getBigDecimal
(
"XD"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getTimestamp
(
"XTS"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getBytes
(
"XBY"
)
==
null
&&
rs
.
wasNull
());
check
(!
rs
.
getBoolean
(
"XBO"
)
&&
rs
.
wasNull
());
check
(
rs
.
getShort
(
"XSM"
)
==
0
&&
rs
.
wasNull
());
check
(
rs
.
getLong
(
"XBI"
)
==
0
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XBL"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XDA"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XTI"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XCL"
)
==
null
&&
rs
.
wasNull
());
check
(
rs
.
getString
(
"XDO"
)
==
null
&&
rs
.
wasNull
());
check
False
(
rs
.
next
());
assertTrue
(
rs
.
getString
(
"NAME"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XT"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getInt
(
"ID"
)
==
0
&&
!
rs
.
wasNull
());
assertTrue
(
rs
.
getBigDecimal
(
"XD"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getTimestamp
(
"XTS"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getBytes
(
"XBY"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(!
rs
.
getBoolean
(
"XBO"
)
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getShort
(
"XSM"
)
==
0
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getLong
(
"XBI"
)
==
0
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XBL"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XDA"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XTI"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XCL"
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getString
(
"XDO"
)
==
null
&&
rs
.
wasNull
());
assert
False
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE LINK_TEST"
);
...
...
@@ -294,8 +294,8 @@ public class TestLinkedTable extends TestBase {
+
"/linked1', 'sa1', 'abc', '(SELECT COUNT(*) FROM TEST)')"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
3
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
3
);
assert
False
(
rs
.
next
());
conn
.
close
();
...
...
@@ -306,23 +306,23 @@ public class TestLinkedTable extends TestBase {
void
testRow
(
Statement
stat
,
String
name
)
throws
Exception
{
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
name
+
" WHERE ID=1"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
),
"Hello"
);
check
(
rs
.
getByte
(
"XT"
),
-
1
);
assertEquals
(
rs
.
getString
(
"NAME"
),
"Hello"
);
assertEquals
(
rs
.
getByte
(
"XT"
),
-
1
);
BigDecimal
bd
=
rs
.
getBigDecimal
(
"XD"
);
check
(
bd
.
equals
(
new
BigDecimal
(
"10.30"
)));
assertTrue
(
bd
.
equals
(
new
BigDecimal
(
"10.30"
)));
Timestamp
ts
=
rs
.
getTimestamp
(
"XTS"
);
String
s
=
ts
.
toString
();
check
(
s
,
"2001-02-03 11:22:33.4455"
);
check
(
ts
.
equals
(
Timestamp
.
valueOf
(
"2001-02-03 11:22:33.4455"
)));
check
(
rs
.
getBytes
(
"XBY"
),
new
byte
[]
{
(
byte
)
255
,
(
byte
)
1
,
(
byte
)
2
});
check
(
rs
.
getBoolean
(
"XBO"
));
check
(
rs
.
getShort
(
"XSM"
),
3000
);
check
(
rs
.
getLong
(
"XBI"
),
1234567890123456789L
);
check
(
rs
.
getString
(
"XBL"
),
"1122aa"
);
check
(
rs
.
getString
(
"XDA"
),
"0002-01-01"
);
check
(
rs
.
getString
(
"XTI"
),
"00:00:00"
);
check
(
rs
.
getString
(
"XCL"
),
"J\u00fcrg"
);
check
(
rs
.
getString
(
"XDO"
),
"2.25"
);
assertEquals
(
s
,
"2001-02-03 11:22:33.4455"
);
assertTrue
(
ts
.
equals
(
Timestamp
.
valueOf
(
"2001-02-03 11:22:33.4455"
)));
assertEquals
(
rs
.
getBytes
(
"XBY"
),
new
byte
[]
{
(
byte
)
255
,
(
byte
)
1
,
(
byte
)
2
});
assertTrue
(
rs
.
getBoolean
(
"XBO"
));
assertEquals
(
rs
.
getShort
(
"XSM"
),
3000
);
assertEquals
(
rs
.
getLong
(
"XBI"
),
1234567890123456789L
);
assertEquals
(
rs
.
getString
(
"XBL"
),
"1122aa"
);
assertEquals
(
rs
.
getString
(
"XDA"
),
"0002-01-01"
);
assertEquals
(
rs
.
getString
(
"XTI"
),
"00:00:00"
);
assertEquals
(
rs
.
getString
(
"XCL"
),
"J\u00fcrg"
);
assertEquals
(
rs
.
getString
(
"XDO"
),
"2.25"
);
}
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
ad1a436f
...
...
@@ -174,7 +174,7 @@ public class TestLob extends TestBase {
}
}
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
.
rollback
();
conn
.
close
();
...
...
@@ -257,7 +257,7 @@ public class TestLob extends TestBase {
while
(
rs
.
next
())
{
String
d1
=
rs
.
getString
(
"DATA"
).
trim
();
String
d2
=
rs
.
getString
(
"DATA2"
).
trim
();
check
(
d1
,
d2
);
assertEquals
(
d1
,
d2
);
}
}
...
...
@@ -278,9 +278,9 @@ public class TestLob extends TestBase {
conn
.
createStatement
().
execute
(
"SHUTDOWN IMMEDIATELY"
);
conn
=
reconnect
(
null
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
check
(
rs
.
next
());
assertTrue
(
rs
.
next
());
rs
.
getInt
(
1
);
check
(
rs
.
getString
(
2
).
length
(),
10000
);
assertEquals
(
rs
.
getString
(
2
).
length
(),
10000
);
conn
.
close
();
}
...
...
@@ -405,8 +405,8 @@ public class TestLob extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select value from information_schema.settings where NAME='COMPRESS_LOB'"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
compress
?
"LZF"
:
"NO"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
),
compress
?
"LZF"
:
"NO"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"create table test(text clob)"
);
stat
.
execute
(
"create table test2(text clob)"
);
StringBuffer
buff
=
new
StringBuffer
();
...
...
@@ -418,15 +418,15 @@ public class TestLob extends TestBase {
stat
.
execute
(
"insert into test2 select * from test"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
spaces
);
assertEquals
(
rs
.
getString
(
1
),
spaces
);
stat
.
execute
(
"drop table test"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
spaces
);
assertEquals
(
rs
.
getString
(
1
),
spaces
);
stat
.
execute
(
"alter table test2 add column id int before text"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
check
(
rs
.
getString
(
"text"
),
spaces
);
assertEquals
(
rs
.
getString
(
"text"
),
spaces
);
conn
.
close
();
}
...
...
@@ -460,11 +460,11 @@ public class TestLob extends TestBase {
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
while
(
rs
.
next
())
{
if
(
i
==
0
)
{
check
(
xml
+
rs
.
getInt
(
1
),
rs
.
getString
(
2
));
assertEquals
(
xml
+
rs
.
getInt
(
1
),
rs
.
getString
(
2
));
}
else
{
Reader
r
=
rs
.
getCharacterStream
(
2
);
String
result
=
IOUtils
.
readStringAndClose
(
r
,
-
1
);
check
(
xml
+
rs
.
getInt
(
1
),
result
);
assertEquals
(
xml
+
rs
.
getInt
(
1
),
result
);
}
}
}
...
...
@@ -501,8 +501,8 @@ public class TestLob extends TestBase {
Blob
b
=
rs
.
getBlob
(
"B"
);
Clob
c
=
rs
.
getClob
(
"C"
);
int
l
=
i
;
check
(
b
.
length
(),
l
);
check
(
c
.
length
(),
l
);
assertEquals
(
b
.
length
(),
l
);
assertEquals
(
c
.
length
(),
l
);
checkStream
(
b
.
getBinaryStream
(),
getRandomStream
(
l
,
i
),
-
1
);
checkReader
(
c
.
getCharacterStream
(),
getRandomReader
(
l
,
i
),
-
1
);
}
...
...
@@ -523,8 +523,8 @@ public class TestLob extends TestBase {
Blob
b
=
rs
.
getBlob
(
"B"
);
Clob
c
=
rs
.
getClob
(
"C"
);
int
l
=
i
;
check
(
b
.
length
(),
l
);
check
(
c
.
length
(),
l
);
assertEquals
(
b
.
length
(),
l
);
assertEquals
(
c
.
length
(),
l
);
checkStream
(
b
.
getBinaryStream
(),
getRandomStream
(
l
,
-
i
),
-
1
);
checkReader
(
c
.
getCharacterStream
(),
getRandomReader
(
l
,
-
i
),
-
1
);
}
...
...
@@ -549,7 +549,7 @@ public class TestLob extends TestBase {
conn
=
reconnect
(
conn
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
check
(
"Bohlen"
,
rs
.
getString
(
"C"
));
assertEquals
(
"Bohlen"
,
rs
.
getString
(
"C"
));
checkReader
(
new
CharArrayReader
(
"Bohlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
rs
.
next
();
checkReader
(
new
CharArrayReader
(
"B\u00f6hlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
...
...
@@ -557,15 +557,15 @@ public class TestLob extends TestBase {
checkReader
(
getRandomReader
(
501
,
1
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
Clob
clob
=
rs
.
getClob
(
"C"
);
checkReader
(
getRandomReader
(
501
,
1
),
clob
.
getCharacterStream
(),
-
1
);
check
(
clob
.
length
(),
501
);
assertEquals
(
clob
.
length
(),
501
);
rs
.
next
();
checkReader
(
getRandomReader
(
401
,
2
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
checkReader
(
getRandomReader
(
1500
,
2
),
rs
.
getCharacterStream
(
"C"
),
401
);
clob
=
rs
.
getClob
(
"C"
);
checkReader
(
getRandomReader
(
1501
,
2
),
clob
.
getCharacterStream
(),
401
);
checkReader
(
getRandomReader
(
401
,
2
),
clob
.
getCharacterStream
(),
401
);
check
(
clob
.
length
(),
401
);
check
False
(
rs
.
next
());
assertEquals
(
clob
.
length
(),
401
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -757,9 +757,9 @@ public class TestLob extends TestBase {
TestLobObject
a
=
(
TestLobObject
)
oa
;
Object
ob
=
rs
.
getObject
(
"DATA"
);
TestLobObject
b
=
(
TestLobObject
)
ob
;
check
(
a
.
data
,
"abc"
);
check
(
b
.
data
,
"abc"
);
check
False
(
rs
.
next
());
assertEquals
(
a
.
data
,
"abc"
);
assertEquals
(
b
.
data
,
"abc"
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -774,7 +774,7 @@ public class TestLob extends TestBase {
int
ca
=
a
.
read
();
a
.
read
(
new
byte
[
0
]);
int
cb
=
b
.
read
();
check
(
ca
,
cb
);
assertEquals
(
ca
,
cb
);
if
(
ca
==
-
1
)
{
break
;
}
...
...
@@ -791,7 +791,7 @@ public class TestLob extends TestBase {
for
(
int
i
=
0
;
len
<
0
||
i
<
len
;
i
++)
{
int
ca
=
a
.
read
();
int
cb
=
b
.
read
();
check
(
ca
,
cb
);
assertEquals
(
ca
,
cb
);
if
(
ca
==
-
1
)
{
break
;
}
...
...
h2/src/test/org/h2/test/db/TestLogFile.java
浏览文件 @
ad1a436f
...
...
@@ -30,7 +30,7 @@ public class TestLogFile extends TestBase {
}
long
length
=
0
;
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"logfile"
,
false
);
check
Smaller
(
files
.
size
(),
maxFiles
+
2
);
assert
Smaller
(
files
.
size
(),
maxFiles
+
2
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
String
fileName
=
(
String
)
files
.
get
(
i
);
long
len
=
new
File
(
fileName
).
length
();
...
...
@@ -57,7 +57,7 @@ public class TestLogFile extends TestBase {
insert
();
long
l2
=
reconnect
(
maxFiles
);
trace
(
"length:"
+
length
+
" l2:"
+
l2
);
check
(
l2
<=
length
*
2
);
assertTrue
(
l2
<=
length
*
2
);
}
conn
.
close
();
}
finally
{
...
...
@@ -71,7 +71,7 @@ public class TestLogFile extends TestBase {
String
name
=
files
[
j
];
if
(
name
.
startsWith
(
"logfile"
)
&&
name
.
endsWith
(
".log.db"
))
{
long
length
=
new
File
(
name
).
length
();
check
Smaller
(
length
,
MAX_LOG_SIZE
*
1024
*
1024
*
2
);
assert
Smaller
(
length
,
MAX_LOG_SIZE
*
1024
*
1024
*
2
);
}
}
}
...
...
h2/src/test/org/h2/test/db/TestMultiConn.java
浏览文件 @
ad1a436f
...
...
@@ -104,10 +104,10 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
t1
.
join
(
1000
);
ResultSet
rs
=
s1
.
executeQuery
(
"SELECT * FROM TEST1 ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
5
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
5
);
assert
False
(
rs
.
next
());
conn1
.
close
();
conn2
.
close
();
conn3
.
close
();
...
...
@@ -194,12 +194,12 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
ResultSet
rs
;
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM MULTI_A ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
),
"0-insert-A"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
"NAME"
),
"0-insert-A"
);
assert
False
(
rs
.
next
());
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM MULTI_B ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
),
"1-insert-D"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
"NAME"
),
"1-insert-D"
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestMultiDimension.java
浏览文件 @
ad1a436f
...
...
@@ -26,9 +26,9 @@ public class TestMultiDimension extends TestBase {
int
x
=
rand
.
nextInt
(
1000
),
y
=
rand
.
nextInt
(
1000
),
z
=
rand
.
nextInt
(
1000
);
MultiDimension
tool
=
MultiDimension
.
getInstance
();
long
xyz
=
tool
.
interleave
(
new
int
[]
{
x
,
y
,
z
});
check
(
x
,
tool
.
deinterleave
(
xyz
,
3
,
0
));
check
(
y
,
tool
.
deinterleave
(
xyz
,
3
,
1
));
check
(
z
,
tool
.
deinterleave
(
xyz
,
3
,
2
));
assertEquals
(
x
,
tool
.
deinterleave
(
xyz
,
3
,
0
));
assertEquals
(
y
,
tool
.
deinterleave
(
xyz
,
3
,
1
));
assertEquals
(
z
,
tool
.
deinterleave
(
xyz
,
3
,
2
));
}
deleteDb
(
"multiDimension"
);
...
...
@@ -95,11 +95,11 @@ public class TestMultiDimension extends TestBase {
ResultSet
rs2
=
prepRegular
.
executeQuery
();
timeRegular
+=
System
.
currentTimeMillis
()
-
time
;
while
(
rs1
.
next
())
{
check
(
rs2
.
next
());
check
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
check
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
assertTrue
(
rs2
.
next
());
assertEquals
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
assertEquals
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
}
check
False
(
rs2
.
next
());
assert
False
(
rs2
.
next
());
}
trace
(
"multi: "
+
timeMulti
+
" regular: "
+
timeRegular
);
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
...
...
@@ -120,11 +120,11 @@ public class TestMultiDimension extends TestBase {
ResultSet
rs2
=
prep2
.
executeQuery
();
time2
=
System
.
currentTimeMillis
()
-
time2
;
while
(
rs1
.
next
())
{
check
(
rs2
.
next
());
check
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
check
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
assertTrue
(
rs2
.
next
());
assertEquals
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
assertEquals
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
}
check
False
(
rs2
.
next
());
assert
False
(
rs2
.
next
());
// it just has to work, no need to compare the performance
// trace("t1="+time1+" t2="+time2+" size="+size);
}
...
...
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
ad1a436f
...
...
@@ -56,8 +56,8 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
check
(
rs
.
getString
(
1
).
length
(),
10000
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
1
).
length
(),
10000
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -131,7 +131,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from employee"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
len
);
assertEquals
(
rs
.
getInt
(
1
),
len
);
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
ad1a436f
...
...
@@ -78,7 +78,7 @@ public class TestOptimizations extends TestBase {
rs
.
next
();
if
(!
config
.
mvcc
)
{
String
plan
=
rs
.
getString
(
1
);
check
(
plan
.
indexOf
(
"direct"
)
>
0
);
assertTrue
(
plan
.
indexOf
(
"direct"
)
>
0
);
}
rs
=
stat
.
executeQuery
(
"select min(x), max(x) from test"
);
rs
.
next
();
...
...
@@ -90,8 +90,8 @@ public class TestOptimizations extends TestBase {
if
(
rs
.
wasNull
())
{
max
=
-
1
;
}
check
(
minExpected
,
min
);
check
(
maxExpected
,
max
);
assertEquals
(
minExpected
,
min
);
assertEquals
(
maxExpected
,
max
);
}
conn
.
close
();
}
...
...
@@ -108,7 +108,7 @@ public class TestOptimizations extends TestBase {
rs
=
stat
.
executeQuery
(
"EXPLAIN SELECT id FROM Logs WHERE id < 100 and type=2 AND id<100"
);
rs
.
next
();
String
plan
=
rs
.
getString
(
1
);
check
(
plan
.
indexOf
(
"TYPE_INDEX"
)
>
0
);
assertTrue
(
plan
.
indexOf
(
"TYPE_INDEX"
)
>
0
);
conn
.
close
();
}
...
...
@@ -133,38 +133,38 @@ public class TestOptimizations extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT TYPE, COUNT(*) FROM TEST GROUP BY TYPE ORDER BY TYPE"
);
for
(
int
i
=
0
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
check
(
groupCount
[
i
],
rs
.
getInt
(
2
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
groupCount
[
i
],
rs
.
getInt
(
2
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE"
);
for
(
int
i
=
0
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
stat
.
execute
(
"ANALYZE"
);
rs
=
stat
.
executeQuery
(
"SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
check
(
rs
.
next
());
check
(
i
,
rs
.
getInt
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 5 OFFSET 2"
);
for
(
int
i
=
2
;
i
<
7
;
i
++)
{
check
(
rs
.
next
());
check
(
i
,
rs
.
getInt
(
1
));
assertTrue
(
rs
.
next
());
assertEquals
(
i
,
rs
.
getInt
(
1
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 0 OFFSET 0 SAMPLE_SIZE 3"
);
// must have at least one row
check
(
rs
.
next
());
assertTrue
(
rs
.
next
());
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
rs
.
getInt
(
1
);
if
(
i
>
0
&&
!
rs
.
next
())
{
break
;
}
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -179,7 +179,7 @@ public class TestOptimizations extends TestBase {
rs
=
prep
.
executeQuery
();
rs
.
next
();
String
b
=
rs
.
getString
(
1
);
check
False
(
a
.
equals
(
b
));
assert
False
(
a
.
equals
(
b
));
conn
.
close
();
}
...
...
@@ -226,15 +226,15 @@ public class TestOptimizations extends TestBase {
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select * from test where id = (select id from test2)"
);
ResultSet
rs1
=
prep
.
executeQuery
();
rs1
.
next
();
check
(
rs1
.
getInt
(
1
),
1
);
assertEquals
(
rs1
.
getInt
(
1
),
1
);
rs1
.
next
();
check
(
rs1
.
getInt
(
1
),
1
);
check
False
(
rs1
.
next
());
assertEquals
(
rs1
.
getInt
(
1
),
1
);
assert
False
(
rs1
.
next
());
stat
.
execute
(
"update test2 set id = 2"
);
ResultSet
rs2
=
prep
.
executeQuery
();
rs2
.
next
();
check
(
rs2
.
getInt
(
1
),
2
);
assertEquals
(
rs2
.
getInt
(
1
),
2
);
conn
.
close
();
}
...
...
@@ -303,9 +303,9 @@ public class TestOptimizations extends TestBase {
Integer
minDb
=
(
Integer
)
rs
.
getObject
(
1
);
Integer
maxDb
=
(
Integer
)
rs
.
getObject
(
2
);
int
countDb
=
rs
.
getInt
(
3
);
check
(
minDb
,
min
);
check
(
maxDb
,
max
);
check
(
countDb
,
count
);
assertEquals
(
minDb
,
min
);
assertEquals
(
maxDb
,
max
);
assertEquals
(
countDb
,
count
);
break
;
}
default
:
...
...
@@ -328,41 +328,41 @@ public class TestOptimizations extends TestBase {
prep
.
setInt
(
1
,
1
);
rs
=
prep
.
executeQuery
();
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assert
False
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(?, ?) order by id"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
2
,
2
);
rs
=
prep
.
executeQuery
();
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"World"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assert
False
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=?)"
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"World"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assert
False
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
ad1a436f
...
...
@@ -80,17 +80,17 @@ public class TestPowerOff extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
+
i
+
" ORDER BY ID"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
check
(
rs
.
getInt
(
1
),
j
);
check
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
rs
.
getInt
(
1
),
j
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
}
if
(
i
==
1
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
check
(
rs
.
getInt
(
1
),
j
+
10
);
check
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
rs
.
getInt
(
1
),
j
+
10
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
}
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
}
conn
.
close
();
}
...
...
@@ -147,8 +147,8 @@ public class TestPowerOff extends TestBase {
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
check
(
rs
.
next
());
check
False
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -167,7 +167,7 @@ public class TestPowerOff extends TestBase {
stat
.
execute
(
"CHECKPOINT"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
boolean
deleted
=
false
;
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
dir
,
dbName
,
false
);
...
...
@@ -178,7 +178,7 @@ public class TestPowerOff extends TestBase {
deleted
=
true
;
}
}
check
(
deleted
);
assertTrue
(
deleted
);
conn
=
getConnection
(
url
);
conn
.
close
();
}
...
...
@@ -201,7 +201,7 @@ public class TestPowerOff extends TestBase {
stat
.
execute
(
"CHECKPOINT"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
((
JdbcConnection
)
conn
).
setPowerOffCount
(
0
);
...
...
@@ -209,7 +209,7 @@ public class TestPowerOff extends TestBase {
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
conn
.
close
();
}
...
...
@@ -307,18 +307,18 @@ public class TestPowerOff extends TestBase {
if
(!
rs
.
next
())
{
state
=
1
;
}
else
{
check
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
String
name1
=
rs
.
getString
(
2
);
check
(
rs
.
next
());
check
(
rs
.
getInt
(
1
),
2
);
assertTrue
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
String
name2
=
rs
.
getString
(
2
);
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
if
(
"Hello"
.
equals
(
name1
))
{
check
(
name2
,
"World"
);
assertEquals
(
name2
,
"World"
);
state
=
2
;
}
else
{
check
(
name1
,
"Hallo"
);
check
(
name2
,
"Welt"
);
assertEquals
(
name1
,
"Hallo"
);
assertEquals
(
name2
,
"Welt"
);
state
=
3
;
}
}
...
...
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
ad1a436f
...
...
@@ -35,9 +35,9 @@ public class TestReadOnly extends TestBase {
private
void
testReadOnlyFiles
(
boolean
setReadOnly
)
throws
Exception
{
File
f
=
File
.
createTempFile
(
"test"
,
"temp"
);
check
(
f
.
canWrite
());
assertTrue
(
f
.
canWrite
());
f
.
setReadOnly
();
check
(!
f
.
canWrite
());
assertTrue
(!
f
.
canWrite
());
f
.
delete
();
f
=
File
.
createTempFile
(
"test"
,
"temp"
);
...
...
@@ -45,7 +45,7 @@ public class TestReadOnly extends TestBase {
r
.
write
(
1
);
f
.
setReadOnly
();
r
.
close
();
check
(!
f
.
canWrite
());
assertTrue
(!
f
.
canWrite
());
f
.
delete
();
deleteDb
(
"readonly"
);
...
...
@@ -54,7 +54,7 @@ public class TestReadOnly extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'World')"
);
check
(!
conn
.
isReadOnly
());
assertTrue
(!
conn
.
isReadOnly
());
conn
.
close
();
if
(
setReadOnly
)
{
...
...
@@ -63,14 +63,14 @@ public class TestReadOnly extends TestBase {
}
else
{
conn
=
getConnection
(
"readonly;ACCESS_MODE_DATA=r"
);
}
check
(
conn
.
isReadOnly
());
assertTrue
(
conn
.
isReadOnly
());
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SELECT * FROM TEST"
);
try
{
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
.
close
();
...
...
@@ -85,7 +85,7 @@ public class TestReadOnly extends TestBase {
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"SET DB_CLOSE_DELAY=0"
);
conn
.
close
();
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
ad1a436f
...
...
@@ -55,7 +55,7 @@ public class TestRights extends TestBase {
stat2
.
execute
(
"SELECT * FROM TEST"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat2
.
execute
(
"CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT)"
);
stat2
.
execute
(
"INSERT INTO MY_TEST VALUES(1)"
);
...
...
@@ -84,13 +84,13 @@ public class TestRights extends TestBase {
stat
.
execute
(
"alter user test1 admin false"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
stat
.
execute
(
"drop user test1"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"drop schema b"
);
stat
.
execute
(
"alter user test1 admin false"
);
...
...
@@ -173,19 +173,19 @@ public class TestRights extends TestBase {
conn
=
getConnection
(
"rights"
,
"Test"
,
"abc"
);
error
(
"mixed case user name"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
"abc"
);
error
(
"wrong password"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
null
);
error
(
"wrong password"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
conn
=
getConnection
(
"rights"
,
"TEST"
,
"def"
);
stat
=
conn
.
createStatement
();
...
...
@@ -242,7 +242,7 @@ public class TestRights extends TestBase {
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
type
);
assertEquals
(
rs
.
getString
(
1
),
type
);
executeSuccess
(
"DROP TABLE TEST"
);
}
...
...
@@ -251,7 +251,7 @@ public class TestRights extends TestBase {
stat
.
execute
(
sql
);
error
(
"not admin"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
}
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
ad1a436f
...
...
@@ -69,7 +69,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat2
.
execute
(
sql
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
}
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
...
...
h2/src/test/org/h2/test/db/TestSQLInjection.java
浏览文件 @
ad1a436f
...
...
@@ -30,12 +30,12 @@ public class TestSQLInjection extends TestBase {
stat
.
execute
(
"CREATE SCHEMA CONST"
);
stat
.
execute
(
"CREATE CONSTANT CONST.ACTIVE VALUE 'Active'"
);
stat
.
execute
(
"INSERT INTO USERS VALUES('James', '123456', CONST.ACTIVE)"
);
check
(
checkPasswordInsecure
(
"123456"
));
check
False
(
checkPasswordInsecure
(
"abcdef"
));
check
(
checkPasswordInsecure
(
"' OR ''='"
));
check
(
checkPasswordSecure
(
"123456"
));
check
False
(
checkPasswordSecure
(
"abcdef"
));
check
False
(
checkPasswordSecure
(
"' OR ''='"
));
assertTrue
(
checkPasswordInsecure
(
"123456"
));
assert
False
(
checkPasswordInsecure
(
"abcdef"
));
assertTrue
(
checkPasswordInsecure
(
"' OR ''='"
));
assertTrue
(
checkPasswordSecure
(
"123456"
));
assert
False
(
checkPasswordSecure
(
"abcdef"
));
assert
False
(
checkPasswordSecure
(
"' OR ''='"
));
stat
.
execute
(
"CALL 123"
);
stat
.
execute
(
"CALL 'Hello'"
);
stat
.
execute
(
"CALL $$Hello World$$"
);
...
...
@@ -45,25 +45,25 @@ public class TestSQLInjection extends TestBase {
stat
.
execute
(
"CALL 'Hello'"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
try
{
stat
.
execute
(
"CALL $$Hello World$$"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"SET ALLOW_LITERALS NONE"
);
try
{
check
(
checkPasswordInsecure
(
"123456"
));
assertTrue
(
checkPasswordInsecure
(
"123456"
));
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
check
(
checkPasswordSecure
(
"123456"
));
check
False
(
checkPasswordSecure
(
"' OR ''='"
));
assertTrue
(
checkPasswordSecure
(
"123456"
));
assert
False
(
checkPasswordSecure
(
"' OR ''='"
));
conn
.
close
();
if
(
config
.
memory
)
{
...
...
@@ -73,13 +73,13 @@ public class TestSQLInjection extends TestBase {
reconnect
(
"sqlInjection"
);
try
{
check
(
checkPasswordInsecure
(
"123456"
));
assertTrue
(
checkPasswordInsecure
(
"123456"
));
error
(
"Should fail now"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
check
(
checkPasswordSecure
(
"123456"
));
check
False
(
checkPasswordSecure
(
"' OR ''='"
));
assertTrue
(
checkPasswordSecure
(
"123456"
));
assert
False
(
checkPasswordSecure
(
"' OR ''='"
));
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestScript.java
浏览文件 @
ad1a436f
...
...
@@ -316,7 +316,7 @@ public class TestScript extends TestBase {
}
private
void
writeResult
(
String
s
,
SQLException
e
)
throws
Exception
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
s
=
(
"> "
+
s
).
trim
();
String
compare
=
readLine
();
if
(
compare
!=
null
&&
compare
.
startsWith
(
">"
))
{
...
...
h2/src/test/org/h2/test/db/TestScriptSimple.java
浏览文件 @
ad1a436f
...
...
@@ -50,7 +50,7 @@ public class TestScriptSimple extends TestBase {
while
(
rs
.
next
())
{
String
expected
=
reader
.
readStatement
().
trim
();
String
got
=
"> "
+
rs
.
getString
(
1
);
check
(
expected
,
got
);
assertEquals
(
expected
,
got
);
}
}
else
{
conn
.
createStatement
().
execute
(
sql
);
...
...
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
ad1a436f
...
...
@@ -65,12 +65,12 @@ public class TestSequence extends TestBase {
stat
.
execute
(
"call next value for test_Sequence3"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from information_schema.sequences order by sequence_name"
);
rs
.
next
();
check
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE"
);
check
(
rs
.
getString
(
"CACHE"
),
"32"
);
assertEquals
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE"
);
assertEquals
(
rs
.
getString
(
"CACHE"
),
"32"
);
rs
.
next
();
check
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE3"
);
check
(
rs
.
getString
(
"CACHE"
),
"3"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE3"
);
assertEquals
(
rs
.
getString
(
"CACHE"
),
"3"
);
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
@@ -88,11 +88,11 @@ public class TestSequence extends TestBase {
long
last
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
long
v1
=
getNext
(
stat
);
check
(
v1
>
last
);
assertTrue
(
v1
>
last
);
last
=
v1
;
for
(
int
j
=
0
;
j
<
100
;
j
++)
{
long
v2
=
getNext
(
stat2
);
check
(
v2
>
last
);
assertTrue
(
v2
>
last
);
last
=
v2
;
}
}
...
...
h2/src/test/org/h2/test/db/TestSessionsLocks.java
浏览文件 @
ad1a436f
...
...
@@ -29,7 +29,7 @@ public class TestSessionsLocks extends TestBase {
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from information_schema.locks order by session_id"
);
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
Connection
conn2
=
getConnection
(
"sessionsLocks"
);
Statement
stat2
=
conn2
.
createStatement
();
stat2
.
execute
(
"create table test(id int primary key, name varchar)"
);
...
...
@@ -37,30 +37,30 @@ public class TestSessionsLocks extends TestBase {
stat2
.
execute
(
"insert into test values(1, 'Hello')"
);
rs
=
stat
.
executeQuery
(
"select * from information_schema.locks order by session_id"
);
rs
.
next
();
check
(
"PUBLIC"
,
rs
.
getString
(
"TABLE_SCHEMA"
));
check
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
));
assertEquals
(
"PUBLIC"
,
rs
.
getString
(
"TABLE_SCHEMA"
));
assertEquals
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
));
rs
.
getString
(
"SESSION_ID"
);
if
(
config
.
mvcc
)
{
check
(
"READ"
,
rs
.
getString
(
"LOCK_TYPE"
));
assertEquals
(
"READ"
,
rs
.
getString
(
"LOCK_TYPE"
));
}
else
{
check
(
"WRITE"
,
rs
.
getString
(
"LOCK_TYPE"
));
assertEquals
(
"WRITE"
,
rs
.
getString
(
"LOCK_TYPE"
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn2
.
commit
();
conn2
.
setTransactionIsolation
(
Connection
.
TRANSACTION_SERIALIZABLE
);
stat2
.
execute
(
"SELECT * FROM TEST"
);
rs
=
stat
.
executeQuery
(
"select * from information_schema.locks order by session_id"
);
if
(!
config
.
mvcc
)
{
rs
.
next
();
check
(
"PUBLIC"
,
rs
.
getString
(
"TABLE_SCHEMA"
));
check
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
));
assertEquals
(
"PUBLIC"
,
rs
.
getString
(
"TABLE_SCHEMA"
));
assertEquals
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
));
rs
.
getString
(
"SESSION_ID"
);
check
(
"READ"
,
rs
.
getString
(
"LOCK_TYPE"
));
assertEquals
(
"READ"
,
rs
.
getString
(
"LOCK_TYPE"
));
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn2
.
commit
();
rs
=
stat
.
executeQuery
(
"select * from information_schema.locks order by session_id"
);
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn
.
close
();
conn2
.
close
();
}
...
...
@@ -77,16 +77,16 @@ public class TestSessionsLocks extends TestBase {
rs
.
getTimestamp
(
"SESSION_START"
);
rs
.
getString
(
"STATEMENT"
);
rs
.
getTimestamp
(
"STATEMENT_START"
);
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
Connection
conn2
=
getConnection
(
"sessionsLocks"
);
final
Statement
stat2
=
conn2
.
createStatement
();
rs
=
stat
.
executeQuery
(
"select * from information_schema.sessions order by SESSION_START, ID"
);
check
(
rs
.
next
());
check
(
sessionId
,
rs
.
getInt
(
"ID"
));
check
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
sessionId
,
rs
.
getInt
(
"ID"
));
assertTrue
(
rs
.
next
());
int
otherId
=
rs
.
getInt
(
"ID"
);
check
(
otherId
!=
sessionId
);
check
False
(
rs
.
next
());
assertTrue
(
otherId
!=
sessionId
);
assert
False
(
rs
.
next
());
stat2
.
execute
(
"set throttle 1"
);
final
boolean
[]
done
=
new
boolean
[
1
];
Runnable
runnable
=
new
Runnable
()
{
...
...
@@ -111,7 +111,7 @@ public class TestSessionsLocks extends TestBase {
break
;
}
}
check
(
done
[
0
]);
assertTrue
(
done
[
0
]);
break
;
}
}
...
...
h2/src/test/org/h2/test/db/TestTempTables.java
浏览文件 @
ad1a436f
...
...
@@ -48,22 +48,22 @@ public class TestTempTables extends TestBase {
s1
.
execute
(
"create local temporary table test_temp(id int) on commit delete rows"
);
s1
.
execute
(
"insert into test_temp values(1)"
);
rs
=
s1
.
executeQuery
(
"select * from test_temp"
);
check
ResultRowCount
(
rs
,
1
);
assert
ResultRowCount
(
rs
,
1
);
c1
.
commit
();
rs
=
s1
.
executeQuery
(
"select * from test_temp"
);
check
ResultRowCount
(
rs
,
0
);
assert
ResultRowCount
(
rs
,
0
);
s1
.
execute
(
"drop table test_temp"
);
s1
.
execute
(
"create local temporary table test_temp(id int) on commit drop"
);
s1
.
execute
(
"insert into test_temp values(1)"
);
rs
=
s1
.
executeQuery
(
"select * from test_temp"
);
check
ResultRowCount
(
rs
,
1
);
assert
ResultRowCount
(
rs
,
1
);
c1
.
commit
();
try
{
rs
=
s1
.
executeQuery
(
"select * from test_temp"
);
error
(
"test_temp should have been dropped automatically"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
c1
.
close
();
...
...
h2/src/test/org/h2/test/db/TestTransaction.java
浏览文件 @
ad1a436f
...
...
@@ -39,14 +39,14 @@ public class TestTransaction extends TestBase {
stat
.
execute
(
"insert into test values(1)"
);
stat
.
execute
(
"set @x = 1"
);
conn
.
commit
();
check
SingleValue
(
stat
,
"select id from test"
,
1
);
check
SingleValue
(
stat
,
"call @x"
,
1
);
assert
SingleValue
(
stat
,
"select id from test"
,
1
);
assert
SingleValue
(
stat
,
"call @x"
,
1
);
stat
.
execute
(
"update test set id=2"
);
stat
.
execute
(
"set @x = 2"
);
conn
.
rollback
();
check
SingleValue
(
stat
,
"select id from test"
,
1
);
check
SingleValue
(
stat
,
"call @x"
,
2
);
assert
SingleValue
(
stat
,
"select id from test"
,
1
);
assert
SingleValue
(
stat
,
"call @x"
,
2
);
conn
.
close
();
}
...
...
@@ -68,7 +68,7 @@ public class TestTransaction extends TestBase {
s2
.
executeUpdate
(
"insert into B values('two', 1)"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
c2
.
commit
();
c1
.
rollback
();
...
...
@@ -140,22 +140,22 @@ public class TestTransaction extends TestBase {
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM "
+
tableName
);
rs
.
next
();
check
(
count
,
rs
.
getInt
(
1
));
assertEquals
(
count
,
rs
.
getInt
(
1
));
}
public
void
testIsolation
()
throws
Exception
{
Connection
conn
=
getConnection
(
"transaction"
);
trace
(
"default TransactionIsolation="
+
conn
.
getTransactionIsolation
());
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_COMMITTED
);
check
(
conn
.
getTransactionIsolation
()
==
Connection
.
TRANSACTION_READ_COMMITTED
);
assertTrue
(
conn
.
getTransactionIsolation
()
==
Connection
.
TRANSACTION_READ_COMMITTED
);
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_SERIALIZABLE
);
check
(
conn
.
getTransactionIsolation
()
==
Connection
.
TRANSACTION_SERIALIZABLE
);
assertTrue
(
conn
.
getTransactionIsolation
()
==
Connection
.
TRANSACTION_SERIALIZABLE
);
Statement
stat
=
conn
.
createStatement
();
check
(
conn
.
getAutoCommit
());
assertTrue
(
conn
.
getAutoCommit
());
conn
.
setAutoCommit
(
false
);
check
False
(
conn
.
getAutoCommit
());
assert
False
(
conn
.
getAutoCommit
());
conn
.
setAutoCommit
(
true
);
check
(
conn
.
getAutoCommit
());
assertTrue
(
conn
.
getAutoCommit
());
test
(
stat
,
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
conn
.
commit
();
test
(
stat
,
"INSERT INTO TEST VALUES(0)"
);
...
...
@@ -221,7 +221,7 @@ public class TestTransaction extends TestBase {
rs1
.
next
();
error
(
"next worked on a closed result set"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
// this is already closed, so but closing again should no do any harm
rs1
.
close
();
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
ad1a436f
...
...
@@ -53,13 +53,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"create sequence seq"
);
stat
.
execute
(
"create table test(id int primary key)"
);
check
SingleValue
(
stat
,
"call seq.nextval"
,
1
);
assert
SingleValue
(
stat
,
"call seq.nextval"
,
1
);
conn
.
setAutoCommit
(
false
);
stat
.
execute
(
"create trigger test_upd before insert on test call \""
+
Test
.
class
.
getName
()
+
"\""
);
stat
.
execute
(
"insert into test values(1)"
);
check
SingleValue
(
stat
,
"call seq.nextval"
,
3
);
assert
SingleValue
(
stat
,
"call seq.nextval"
,
3
);
stat
.
execute
(
"alter table test add column name varchar"
);
check
SingleValue
(
stat
,
"call seq.nextval"
,
4
);
assert
SingleValue
(
stat
,
"call seq.nextval"
,
4
);
stat
.
execute
(
"drop sequence seq"
);
stat
.
execute
(
"drop table test"
);
conn
.
close
();
...
...
@@ -73,7 +73,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
.
execute
(
"alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade"
);
stat
.
execute
(
"insert into test select x, x/2 from system_range(0, 100)"
);
stat
.
execute
(
"delete from test"
);
check
SingleValue
(
stat
,
"select count(*) from test"
,
0
);
assert
SingleValue
(
stat
,
"select count(*) from test"
,
0
);
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
...
...
@@ -113,13 +113,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
check
(
rs
.
getString
(
2
),
"Hello-updated"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
2
),
"Hello-updated"
);
assert
False
(
rs
.
next
());
stat
.
execute
(
"UPDATE TEST SET NAME=NAME||'-upd'"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
check
(
rs
.
getString
(
2
),
"Hello-updated-upd-updated2"
);
check
False
(
rs
.
next
());
assertEquals
(
rs
.
getString
(
2
),
"Hello-updated-upd-updated2"
);
assert
False
(
rs
.
next
());
mustNotCallTrigger
=
true
;
stat
.
execute
(
"DROP TRIGGER IF EXISTS INS_BEFORE"
);
...
...
@@ -128,7 +128,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
.
execute
(
"DROP TRIGGER INS_BEFORE"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"DROP TRIGGER INS_AFTER"
);
stat
.
execute
(
"DROP TRIGGER UPD_BEFORE"
);
...
...
@@ -182,7 +182,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
throw
new
Error
(
"Commit must not work here"
);
}
catch
(
SQLException
e
)
{
try
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
catch
(
Exception
e2
)
{
throw
new
Error
(
"Unexpected: "
+
e
.
toString
());
}
...
...
@@ -192,7 +192,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
throw
new
Error
(
"CREATE TABLE WORKED, but implicitly commits"
);
}
catch
(
SQLException
e
)
{
try
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
catch
(
Exception
e2
)
{
throw
new
Error
(
"Unexpected: "
+
e
.
toString
());
}
...
...
h2/src/test/org/h2/test/db/TestTwoPhaseCommit.java
浏览文件 @
ad1a436f
...
...
@@ -39,14 +39,14 @@ public class TestTwoPhaseCommit extends TestBase {
stat
.
execute
(
"SET WRITE_DELAY 0"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
if
(!
rolledBack
)
{
rs
.
next
();
check
(
rs
.
getInt
(
1
),
2
);
check
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
}
check
False
(
rs
.
next
());
assert
False
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
ad1a436f
...
...
@@ -27,8 +27,8 @@ public class TestView extends TestBase {
s
.
execute
(
"create view t"
+
(
i
+
1
)
+
" as select * from t"
+
i
);
s
.
execute
(
"select * from t"
+
(
i
+
1
));
ResultSet
rs
=
s
.
executeQuery
(
"select count(*) from t"
+
(
i
+
1
)
+
" where id=2"
);
check
(
rs
.
next
());
check
(
rs
.
getInt
(
1
),
1
);
assertTrue
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
1
);
}
conn
.
close
();
conn
=
getConnection
(
"view"
);
...
...
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
浏览文件 @
ad1a436f
...
...
@@ -63,7 +63,7 @@ public class TestBatchUpdates extends TestBase {
for
(
int
i
=
0
;
i
<
updateCounts
.
length
;
i
++)
{
total
+=
updateCounts
[
i
];
}
check
(
4
,
total
);
assertEquals
(
4
,
total
);
conn
.
close
();
}
...
...
@@ -194,7 +194,7 @@ public class TestBatchUpdates extends TestBase {
retValue
[
i
++]
=
rs
.
getInt
(
1
);
for
(
int
j
=
0
;
j
<
updateCount
.
length
;
j
++)
{
trace
(
"UpdateCount:"
+
updateCount
[
j
]);
check
(
updateCount
[
j
],
retValue
[
j
]);
assertEquals
(
updateCount
[
j
],
retValue
[
j
]);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCallableStatement.java
浏览文件 @
ad1a436f
...
...
@@ -37,15 +37,15 @@ public class TestCallableStatement extends TestBase {
call
=
conn
.
prepareCall
(
"SELECT * FROM TEST"
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
);
rs
=
call
.
executeQuery
();
rs
.
next
();
check
(
1
,
rs
.
getInt
(
1
));
check
(
"Hello"
,
rs
.
getString
(
2
));
check
False
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assert
False
(
rs
.
next
());
call
=
conn
.
prepareCall
(
"SELECT * FROM TEST"
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
rs
=
call
.
executeQuery
();
rs
.
next
();
check
(
1
,
rs
.
getInt
(
1
));
check
(
"Hello"
,
rs
.
getString
(
2
));
check
False
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assert
False
(
rs
.
next
());
}
}
h2/src/test/org/h2/test/jdbc/TestCancel.java
浏览文件 @
ad1a436f
...
...
@@ -74,7 +74,7 @@ public class TestCancel extends TestBase {
stat
.
execute
(
"select count(*) from system_range(1, 1000000), system_range(1, 1000000)"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
stat
.
execute
(
"set query_timeout 0"
);
stat
.
execute
(
"select count(*) from system_range(1, 1000), system_range(1, 1000)"
);
...
...
@@ -100,23 +100,23 @@ public class TestCancel extends TestBase {
deleteDb
(
"cancel"
);
Connection
conn
=
getConnection
(
"cancel"
);
Statement
stat
=
conn
.
createStatement
();
check
(
0
,
stat
.
getQueryTimeout
());
assertEquals
(
0
,
stat
.
getQueryTimeout
());
stat
.
setQueryTimeout
(
1
);
check
(
1
,
stat
.
getQueryTimeout
());
assertEquals
(
1
,
stat
.
getQueryTimeout
());
Statement
s2
=
conn
.
createStatement
();
check
(
1
,
s2
.
getQueryTimeout
());
assertEquals
(
1
,
s2
.
getQueryTimeout
());
ResultSet
rs
=
s2
.
executeQuery
(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME = 'QUERY_TIMEOUT'"
);
rs
.
next
();
check
(
1000
,
rs
.
getInt
(
1
));
assertEquals
(
1000
,
rs
.
getInt
(
1
));
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
stat
.
setQueryTimeout
(
0
);
stat
.
execute
(
"SET QUERY_TIMEOUT 1100"
);
check
(
2
,
stat
.
getQueryTimeout
());
assertEquals
(
2
,
stat
.
getQueryTimeout
());
conn
.
close
();
}
...
...
@@ -129,7 +129,7 @@ public class TestCancel extends TestBase {
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
conn
.
close
();
}
...
...
@@ -145,7 +145,7 @@ public class TestCancel extends TestBase {
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
conn
.
close
();
}
finally
{
...
...
@@ -186,7 +186,7 @@ public class TestCancel extends TestBase {
query
.
executeQuery
(
"SELECT VISIT(ID), (SELECT SUM(X) FROM SYSTEM_RANGE(1, 10000) WHERE X<>ID) FROM TEST ORDER BY ID"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
// ignore cancelled statements
}
cancel
.
stopNow
();
...
...
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
浏览文件 @
ad1a436f
...
...
@@ -54,7 +54,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
conn
=
DriverManager
.
getConnection
(
url
,
p
);
conn
.
close
();
if
(
l
.
calledOpened
)
{
check
(!
l
.
calledScan
);
assertTrue
(!
l
.
calledScan
);
}
}
...
...
@@ -67,8 +67,8 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:databaseEventListener"
,
p
);
conn
.
close
();
check
(
l
.
calledOpened
);
check
(
l
.
calledClosingDatabase
);
assertTrue
(
l
.
calledOpened
);
assertTrue
(
l
.
calledClosingDatabase
);
}
public
void
closingDatabase
()
{
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
浏览文件 @
ad1a436f
...
...
@@ -63,7 +63,7 @@ public class TestNativeSQL extends TestBase {
testRandom
();
testQuotes
();
conn
.
close
();
check
(
conn
.
isClosed
());
assertTrue
(
conn
.
isClosed
());
}
private
void
testQuotes
()
throws
Exception
{
...
...
@@ -101,7 +101,7 @@ public class TestNativeSQL extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
sql
);
rs
.
next
();
String
raw
=
buffRaw
.
toString
();
check
(
raw
,
rs
.
getString
(
1
));
assertEquals
(
raw
,
rs
.
getString
(
1
));
}
}
...
...
@@ -117,7 +117,7 @@ public class TestNativeSQL extends TestBase {
try
{
conn
.
nativeSQL
(
sql
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
sql
,
e
);
assertKnown
Exception
(
sql
,
e
);
}
}
String
smallest
=
null
;
...
...
@@ -226,9 +226,9 @@ public class TestNativeSQL extends TestBase {
stat
.
execute
(
"CALL {d '2001-01-01'} // this is a test"
);
error
(
"expected error if setEscapeProcessing=false"
);
}
catch
(
SQLException
e
)
{
checkNotGeneral
Exception
(
e
);
assertKnown
Exception
(
e
);
}
check
False
(
conn
.
isClosed
());
assert
False
(
conn
.
isClosed
());
}
void
test
(
Connection
conn
,
String
original
,
String
expected
)
throws
Exception
{
...
...
@@ -237,10 +237,10 @@ public class TestNativeSQL extends TestBase {
try
{
String
result
=
conn
.
nativeSQL
(
original
);
trace
(
"result: <"
+
result
+
">"
);
check
(
expected
,
result
);
assertEquals
(
expected
,
result
);
}
catch
(
SQLException
e
)
{
check
(
expected
,
null
);
checkNotGeneral
Exception
(
e
);
assertEquals
(
expected
,
null
);
assertKnown
Exception
(
e
);
trace
(
"got exception, good"
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbcx/TestConnectionPool.java
浏览文件 @
ad1a436f
...
...
@@ -60,7 +60,7 @@ public class TestConnectionPool extends TestBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
].
join
();
}
check
(
0
,
man
.
getActiveConnections
());
assertEquals
(
0
,
man
.
getActiveConnections
());
man
.
dispose
();
}
...
...
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
浏览文件 @
ad1a436f
...
...
@@ -69,7 +69,7 @@ public class TestDataSource extends TestBase {
XAResource
res
=
xaConn
.
getXAResource
();
Connection
conn
=
xaConn
.
getConnection
();
Xid
[]
list
=
res
.
recover
(
XAResource
.
TMSTARTRSCAN
);
check
(
list
.
length
,
0
);
assertEquals
(
list
.
length
,
0
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SELECT * FROM DUAL"
);
conn
.
close
();
...
...
h2/src/test/org/h2/test/jdbcx/TestXA.java
浏览文件 @
ad1a436f
...
...
@@ -63,7 +63,7 @@ public class TestXA extends TestBase {
xa
.
getXAResource
().
start
(
xid
,
XAResource
.
TMNOFLAGS
);
Connection
c
=
xa
.
getConnection
();
check
(!
c
.
getAutoCommit
());
assertTrue
(!
c
.
getAutoCommit
());
c
.
close
();
}
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/mvcc/TestMvcc3.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/server/TestNestedLoop.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestKill.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestTimer.java
浏览文件 @
ad1a436f
...
...
@@ -71,7 +71,7 @@ public class TestTimer extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
int
c
=
rs
.
getInt
(
1
);
check
(
c
,
count
);
assertEquals
(
c
,
count
);
long
time
=
System
.
currentTimeMillis
();
if
(
time
>
start
+
5000
)
{
println
(
"rows: "
+
count
);
...
...
h2/src/test/org/h2/test/synth/thread/TestMultiOrder.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestBitField.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestCompress.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestDataPage.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestFile.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestFileLock.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestIntArray.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestOverflow.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestReader.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestSampleApps.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestScriptReader.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestSecurity.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestServlet.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestShell.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestStreams.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestStringCache.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestStringUtils.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestValueHashMap.java
浏览文件 @
ad1a436f
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论