Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
69aee033
提交
69aee033
authored
8月 14, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix parameter order for assertEquals(expected, actual)
上级
6cf69f57
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
42 个修改的文件
包含
672 行增加
和
657 行删除
+672
-657
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+68
-15
TestAutoRecompile.java
h2/src/test/org/h2/test/db/TestAutoRecompile.java
+3
-3
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+34
-35
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+1
-1
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+4
-4
TestExclusive.java
h2/src/test/org/h2/test/db/TestExclusive.java
+1
-1
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+10
-10
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+35
-35
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+31
-31
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+31
-69
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+2
-2
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+17
-16
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+10
-10
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+1
-1
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+4
-4
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+2
-2
TestTwoPhaseCommit.java
h2/src/test/org/h2/test/db/TestTwoPhaseCommit.java
+4
-4
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+57
-57
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+65
-65
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+107
-107
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+17
-17
TestTransactionIsolation.java
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
+5
-5
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+70
-70
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+5
-5
TestDataSource.java
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
+1
-1
TestMvcc1.java
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
+44
-44
TestNestedLoop.java
h2/src/test/org/h2/test/server/TestNestedLoop.java
+4
-4
TestKill.java
h2/src/test/org/h2/test/synth/TestKill.java
+1
-1
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
+4
-4
TestCompress.java
h2/src/test/org/h2/test/unit/TestCompress.java
+1
-1
TestDataPage.java
h2/src/test/org/h2/test/unit/TestDataPage.java
+1
-1
TestFileLock.java
h2/src/test/org/h2/test/unit/TestFileLock.java
+1
-1
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+6
-6
TestFtp.java
h2/src/test/org/h2/test/unit/TestFtp.java
+2
-2
TestIntArray.java
h2/src/test/org/h2/test/unit/TestIntArray.java
+4
-4
TestPgServer.java
h2/src/test/org/h2/test/unit/TestPgServer.java
+9
-9
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
TestSecurity.java
h2/src/test/org/h2/test/unit/TestSecurity.java
+1
-1
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+2
-2
没有找到文件。
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
69aee033
...
@@ -8,6 +8,8 @@ package org.h2.test;
...
@@ -8,6 +8,8 @@ package org.h2.test;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.sql.Connection
;
import
java.sql.Connection
;
...
@@ -504,7 +506,7 @@ public abstract class TestBase {
...
@@ -504,7 +506,7 @@ public abstract class TestBase {
* @throws AssertionError if the values are not equal
* @throws AssertionError if the values are not equal
*/
*/
protected
void
assertEquals
(
byte
[]
expected
,
byte
[]
actual
)
{
protected
void
assertEquals
(
byte
[]
expected
,
byte
[]
actual
)
{
assertEquals
(
"length"
,
expected
.
length
,
actual
.
length
);
assertEquals
(
expected
.
length
,
actual
.
length
);
for
(
int
i
=
0
;
i
<
expected
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
expected
.
length
;
i
++)
{
if
(
expected
[
i
]
!=
actual
[
i
])
{
if
(
expected
[
i
]
!=
actual
[
i
])
{
fail
(
"["
+
i
+
"]: expected: "
+
(
int
)
expected
[
i
]
+
" actual: "
+
(
int
)
actual
[
i
]);
fail
(
"["
+
i
+
"]: expected: "
+
(
int
)
expected
[
i
]
+
" actual: "
+
(
int
)
actual
[
i
]);
...
@@ -512,6 +514,57 @@ public abstract class TestBase {
...
@@ -512,6 +514,57 @@ public abstract class TestBase {
}
}
}
}
/**
* Check if two readers are equal, and if not throw an exception.
*
* @param expected the expected value
* @param actual the actual value
* @throws AssertionError if the values are not equal
*/
protected
void
assertEqualReaders
(
Reader
expected
,
Reader
actual
,
int
len
)
throws
IOException
{
for
(
int
i
=
0
;
len
<
0
||
i
<
len
;
i
++)
{
int
ce
=
expected
.
read
();
int
ca
=
actual
.
read
();
assertEquals
(
ce
,
ca
);
if
(
ce
==
-
1
)
{
break
;
}
}
expected
.
close
();
actual
.
close
();
}
/**
* Check if two streams are equal, and if not throw an exception.
*
* @param expected the expected value
* @param actual the actual value
* @throws AssertionError if the values are not equal
*/
protected
void
assertEqualStreams
(
InputStream
expected
,
InputStream
actual
,
int
len
)
throws
IOException
{
// this doesn't actually read anything - just tests reading 0 bytes
actual
.
read
(
new
byte
[
0
]);
expected
.
read
(
new
byte
[
0
]);
actual
.
read
(
new
byte
[
10
],
3
,
0
);
expected
.
read
(
new
byte
[
10
],
0
,
0
);
for
(
int
i
=
0
;
len
<
0
||
i
<
len
;
i
++)
{
int
ca
=
actual
.
read
();
actual
.
read
(
new
byte
[
0
]);
int
ce
=
expected
.
read
();
assertEquals
(
ce
,
ca
);
if
(
ca
==
-
1
)
{
break
;
}
}
actual
.
read
(
new
byte
[
10
],
3
,
0
);
expected
.
read
(
new
byte
[
10
],
0
,
0
);
actual
.
read
(
new
byte
[
0
]);
expected
.
read
(
new
byte
[
0
]);
actual
.
close
();
expected
.
close
();
}
/**
/**
* Check if two values are equal, and if not throw an exception.
* Check if two values are equal, and if not throw an exception.
*
*
...
@@ -703,7 +756,7 @@ public abstract class TestBase {
...
@@ -703,7 +756,7 @@ public abstract class TestBase {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
i
++;
i
++;
}
}
assertEquals
(
i
,
expected
);
assertEquals
(
expected
,
i
);
}
}
/**
/**
...
@@ -724,12 +777,12 @@ public abstract class TestBase {
...
@@ -724,12 +777,12 @@ public abstract class TestBase {
/**
/**
* Check that the result set of a query is exactly this value.
* Check that the result set of a query is exactly this value.
*
*
* @param expected the expected result value
* @param stat the statement
* @param stat the statement
* @param sql the SQL statement to execute
* @param sql the SQL statement to execute
* @param expected the expected result value
* @throws AssertionError if a different result value was returned
* @throws AssertionError if a different result value was returned
*/
*/
protected
void
assertResult
(
St
atement
stat
,
String
sql
,
String
expected
)
throws
SQLException
{
protected
void
assertResult
(
St
ring
expected
,
Statement
stat
,
String
sql
)
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
sql
);
ResultSet
rs
=
stat
.
executeQuery
(
sql
);
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
String
actual
=
rs
.
getString
(
1
);
String
actual
=
rs
.
getString
(
1
);
...
@@ -773,24 +826,24 @@ public abstract class TestBase {
...
@@ -773,24 +826,24 @@ public abstract class TestBase {
String
className
=
meta
.
getColumnClassName
(
i
+
1
);
String
className
=
meta
.
getColumnClassName
(
i
+
1
);
switch
(
t
)
{
switch
(
t
)
{
case
Types
.
INTEGER
:
case
Types
.
INTEGER
:
assertEquals
(
typeName
,
"INTEGER"
);
assertEquals
(
"INTEGER"
,
typeName
);
assertEquals
(
className
,
"java.lang.Integer"
);
assertEquals
(
"java.lang.Integer"
,
className
);
break
;
break
;
case
Types
.
VARCHAR
:
case
Types
.
VARCHAR
:
assertEquals
(
typeName
,
"VARCHAR"
);
assertEquals
(
"VARCHAR"
,
typeName
);
assertEquals
(
className
,
"java.lang.String"
);
assertEquals
(
"java.lang.String"
,
className
);
break
;
break
;
case
Types
.
SMALLINT
:
case
Types
.
SMALLINT
:
assertEquals
(
typeName
,
"SMALLINT"
);
assertEquals
(
"SMALLINT"
,
typeName
);
assertEquals
(
className
,
"java.lang.Short"
);
assertEquals
(
"java.lang.Short"
,
className
);
break
;
break
;
case
Types
.
TIMESTAMP
:
case
Types
.
TIMESTAMP
:
assertEquals
(
typeName
,
"TIMESTAMP"
);
assertEquals
(
"TIMESTAMP"
,
typeName
);
assertEquals
(
className
,
"java.sql.Timestamp"
);
assertEquals
(
"java.sql.Timestamp"
,
className
);
break
;
break
;
case
Types
.
DECIMAL
:
case
Types
.
DECIMAL
:
assertEquals
(
typeName
,
"DECIMAL"
);
assertEquals
(
"DECIMAL"
,
typeName
);
assertEquals
(
className
,
"java.math.BigDecimal"
);
assertEquals
(
"java.math.BigDecimal"
,
className
);
break
;
break
;
default
:
default
:
}
}
...
@@ -1034,7 +1087,7 @@ public abstract class TestBase {
...
@@ -1034,7 +1087,7 @@ public abstract class TestBase {
fail
(
"only found in first: "
+
s
);
fail
(
"only found in first: "
+
s
);
}
}
}
}
assertEquals
(
list2
.
size
(),
0
);
assertEquals
(
0
,
list2
.
size
()
);
assertFalse
(
rs2
.
next
());
assertFalse
(
rs2
.
next
());
}
}
...
...
h2/src/test/org/h2/test/db/TestAutoRecompile.java
浏览文件 @
69aee033
...
@@ -33,12 +33,12 @@ public class TestAutoRecompile extends TestBase {
...
@@ -33,12 +33,12 @@ public class TestAutoRecompile extends TestBase {
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST"
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
1
,
prep
.
executeQuery
().
getMetaData
().
getColumnCount
()
);
stat
.
execute
(
"ALTER TABLE TEST ADD COLUMN NAME VARCHAR(255)"
);
stat
.
execute
(
"ALTER TABLE TEST ADD COLUMN NAME VARCHAR(255)"
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
2
,
prep
.
executeQuery
().
getMetaData
().
getColumnCount
()
);
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, X INT, Y INT)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, X INT, Y INT)"
);
assertEquals
(
prep
.
executeQuery
().
getMetaData
().
getColumnCount
(),
3
);
assertEquals
(
3
,
prep
.
executeQuery
().
getMetaData
().
getColumnCount
()
);
// TODO test auto-recompile with insert..select, views and so on
// TODO test auto-recompile with insert..select, views and so on
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(1, 2, 3)"
);
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(1, 2, 3)"
);
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
69aee033
...
@@ -412,7 +412,7 @@ public class TestCases extends TestBase {
...
@@ -412,7 +412,7 @@ public class TestCases extends TestBase {
conn
=
getConnection
(
"cases"
);
conn
=
getConnection
(
"cases"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"1"
);
assertEquals
(
"1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
...
@@ -424,7 +424,7 @@ public class TestCases extends TestBase {
...
@@ -424,7 +424,7 @@ public class TestCases extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"1"
);
assertEquals
(
"1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"create table test(id identity)"
);
stat
.
execute
(
"create table test(id identity)"
);
...
@@ -439,7 +439,7 @@ public class TestCases extends TestBase {
...
@@ -439,7 +439,7 @@ public class TestCases extends TestBase {
conn
=
getConnection
(
"cases"
);
conn
=
getConnection
(
"cases"
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"1"
);
assertEquals
(
"1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
...
@@ -455,18 +455,18 @@ public class TestCases extends TestBase {
...
@@ -455,18 +455,18 @@ public class TestCases extends TestBase {
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select name from test order by name"
);
rs
=
stat
.
executeQuery
(
"select name from test order by name"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"HELLO"
);
assertEquals
(
"HELLO"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"WORLD"
);
assertEquals
(
"WORLD"
,
rs
.
getString
(
1
)
);
rs
=
stat
.
executeQuery
(
"select name from test where name like 'He%'"
);
rs
=
stat
.
executeQuery
(
"select name from test where name like 'He%'"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"HELLO"
);
assertEquals
(
"HELLO"
,
rs
.
getString
(
1
)
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -555,7 +555,7 @@ public class TestCases extends TestBase {
...
@@ -555,7 +555,7 @@ public class TestCases extends TestBase {
stat
.
execute
(
"insert into test(name) values('test')"
);
stat
.
execute
(
"insert into test(name) values('test')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
...
@@ -596,17 +596,17 @@ public class TestCases extends TestBase {
...
@@ -596,17 +596,17 @@ public class TestCases extends TestBase {
prep
.
execute
();
prep
.
execute
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
big
);
assertEquals
(
big
,
rs
.
getString
(
2
)
);
assertEquals
(
readString
(
rs
.
getCharacterStream
(
2
)),
big
);
assertEquals
(
big
,
readString
(
rs
.
getCharacterStream
(
2
))
);
assertEquals
(
rs
.
getString
(
3
),
big
);
assertEquals
(
big
,
rs
.
getString
(
3
)
);
assertEquals
(
readString
(
rs
.
getCharacterStream
(
3
)),
big
);
assertEquals
(
big
,
readString
(
rs
.
getCharacterStream
(
3
))
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
big
);
assertEquals
(
big
,
rs
.
getString
(
2
)
);
assertEquals
(
readString
(
rs
.
getCharacterStream
(
2
)),
big
);
assertEquals
(
big
,
readString
(
rs
.
getCharacterStream
(
2
))
);
assertEquals
(
rs
.
getString
(
3
),
big
);
assertEquals
(
big
,
rs
.
getString
(
3
)
);
assertEquals
(
readString
(
rs
.
getCharacterStream
(
3
)),
big
);
assertEquals
(
big
,
readString
(
rs
.
getCharacterStream
(
3
))
);
rs
.
next
();
rs
.
next
();
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
...
@@ -779,9 +779,9 @@ public class TestCases extends TestBase {
...
@@ -779,9 +779,9 @@ public class TestCases extends TestBase {
deleteDb
(
"cases"
);
deleteDb
(
"cases"
);
Connection
conn
=
getConnection
(
"cases"
);
Connection
conn
=
getConnection
(
"cases"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table employee(id int,
"
+
"firstName VARCHAR(50), "
+
"
salary decimal(10, 2), "
stat
.
execute
(
"create table employee(id int,
firstName VARCHAR(50),
salary decimal(10, 2), "
+
"superior_id int,
"
+
"
CONSTRAINT PK_employee PRIMARY KEY (id), "
+
"superior_id int, CONSTRAINT PK_employee PRIMARY KEY (id), "
+
"CONSTRAINT FK_superior FOREIGN KEY (superior_id)
"
+
"
REFERENCES employee(ID))"
);
+
"CONSTRAINT FK_superior FOREIGN KEY (superior_id) REFERENCES employee(ID))"
);
stat
.
execute
(
"DROP TABLE employee"
);
stat
.
execute
(
"DROP TABLE employee"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"cases"
);
conn
=
getConnection
(
"cases"
);
...
@@ -794,17 +794,17 @@ public class TestCases extends TestBase {
...
@@ -794,17 +794,17 @@ public class TestCases extends TestBase {
Connection
c0
=
getConnection
(
"cases"
);
Connection
c0
=
getConnection
(
"cases"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
c0
.
createStatement
().
executeUpdate
(
.
createStatement
()
"create table australia (ID INTEGER NOT NULL, "
+
.
executeUpdate
(
"Name VARCHAR(100), firstName VARCHAR(100), "
+
"create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), firstName VARCHAR(100),
Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"
);
"
Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"
);
c0
.
createStatement
().
executeUpdate
(
"COMMIT"
);
c0
.
createStatement
().
executeUpdate
(
"COMMIT"
);
c0
.
close
();
c0
.
close
();
c0
=
getConnection
(
"cases"
);
c0
=
getConnection
(
"cases"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
PreparedStatement
p15
=
c0
PreparedStatement
p15
=
c0
.
prepareStatement
(
"insert into australia"
.
prepareStatement
(
"insert into australia (id,Name,firstName,Points,LicenseID) values (?,?,?,?,
?)"
);
+
"(id, Name, firstName, Points, LicenseID) values (?, ?, ?, ?,
?)"
);
int
len
=
getSize
(
1
,
1000
);
int
len
=
getSize
(
1
,
1000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
p15
.
setInt
(
1
,
i
);
p15
.
setInt
(
1
,
i
);
...
@@ -833,17 +833,16 @@ public class TestCases extends TestBase {
...
@@ -833,17 +833,16 @@ public class TestCases extends TestBase {
c0
=
getConnection
(
"cases"
);
c0
=
getConnection
(
"cases"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
.
createStatement
().
executeUpdate
(
"drop table australia"
);
c0
.
createStatement
().
executeUpdate
(
"drop table australia"
);
c0
c0
.
createStatement
().
executeUpdate
(
.
createStatement
()
"create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), "
.
executeUpdate
(
+
"firstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"
);
"create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), firstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))"
);
c0
.
createStatement
().
executeUpdate
(
"COMMIT"
);
c0
.
createStatement
().
executeUpdate
(
"COMMIT"
);
c0
.
close
();
c0
.
close
();
c0
=
getConnection
(
"cases"
);
c0
=
getConnection
(
"cases"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
c0
.
createStatement
().
executeUpdate
(
"SET AUTOCOMMIT FALSE"
);
PreparedStatement
p65
=
c0
PreparedStatement
p65
=
c0
.
prepareStatement
(
"insert into australia"
.
prepareStatement
(
"insert into australia (id,Name,FirstName,Points,LicenseID) values (?,?,?,?,
?)"
);
+
"(id, Name, FirstName, Points, LicenseID) values (?, ?, ?, ?,
?)"
);
len
=
getSize
(
1
,
1000
);
len
=
getSize
(
1
,
1000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
p65
.
setInt
(
1
,
i
);
p65
.
setInt
(
1
,
i
);
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
69aee033
...
@@ -146,7 +146,7 @@ public class TestCluster extends TestBase {
...
@@ -146,7 +146,7 @@ public class TestCluster extends TestBase {
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
1
,
i
);
ResultSet
rs
=
prep
.
executeQuery
();
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
2
),
"Data"
+
i
);
assertEquals
(
"Data"
+
i
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
69aee033
...
@@ -155,10 +155,10 @@ public class TestCompatibility extends TestBase {
...
@@ -155,10 +155,10 @@ public class TestCompatibility extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT, NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World')"
);
org
.
h2
.
mode
.
FunctionsMySQL
.
register
(
conn
);
org
.
h2
.
mode
.
FunctionsMySQL
.
register
(
conn
);
assertResult
(
stat
,
"SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19Z')"
,
"1196418619
"
);
assertResult
(
"1196418619"
,
stat
,
"SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19Z')
"
);
assertResult
(
stat
,
"SELECT UNIX_TIMESTAMP(FROM_UNIXTIME(1196418619))"
,
"1196418619
"
);
assertResult
(
"1196418619"
,
stat
,
"SELECT UNIX_TIMESTAMP(FROM_UNIXTIME(1196418619))
"
);
assertResult
(
stat
,
"SELECT FROM_UNIXTIME(1196300000, '%Y %M')"
,
"2007 November
"
);
assertResult
(
"2007 November"
,
stat
,
"SELECT FROM_UNIXTIME(1196300000, '%Y %M')
"
);
assertResult
(
stat
,
"SELECT DATE('2003-12-31 11:02:03')"
,
"2003-12-31
"
);
assertResult
(
"2003-12-31"
,
stat
,
"SELECT DATE('2003-12-31 11:02:03')
"
);
}
}
...
...
h2/src/test/org/h2/test/db/TestExclusive.java
浏览文件 @
69aee033
...
@@ -66,7 +66,7 @@ public class TestExclusive extends TestBase {
...
@@ -66,7 +66,7 @@ public class TestExclusive extends TestBase {
break
;
break
;
}
}
}
}
assertEquals
(
state
[
0
],
2
);
assertEquals
(
2
,
state
[
0
]
);
stat
.
execute
(
"set exclusive true"
);
stat
.
execute
(
"set exclusive true"
);
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
69aee033
...
@@ -155,28 +155,28 @@ public class TestFullText extends TestBase {
...
@@ -155,28 +155,28 @@ public class TestFullText extends TestBase {
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hallo Welt')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hallo Welt')"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CALL "
+
prefix
+
"REINDEX()"
);
stat
.
execute
(
"CALL "
+
prefix
+
"REINDEX()"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hello', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('Hallo', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello World')"
);
...
@@ -185,13 +185,13 @@ public class TestFullText extends TestBase {
...
@@ -185,13 +185,13 @@ public class TestFullText extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0) ORDER BY QUERY"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0) ORDER BY QUERY"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=3"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=3"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=4"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=4"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=5"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=5"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 1, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 1, 0)"
);
...
@@ -215,7 +215,7 @@ public class TestFullText extends TestBase {
...
@@ -215,7 +215,7 @@ public class TestFullText extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('1', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('1', 0, 0)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
);
assertEquals
(
"\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
69aee033
...
@@ -291,45 +291,45 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -291,45 +291,45 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
test
(
stat
,
"abs(null)"
,
null
);
assertCallResult
(
null
,
stat
,
"abs(null)"
);
test
(
stat
,
"abs(1)"
,
"1
"
);
assertCallResult
(
"1"
,
stat
,
"abs(1)
"
);
test
(
stat
,
"abs(1)"
,
"1
"
);
assertCallResult
(
"1"
,
stat
,
"abs(1)
"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE ALIAS ADD_ROW FOR \""
+
getClass
().
getName
()
+
".addRow\""
);
stat
.
execute
(
"CREATE ALIAS ADD_ROW FOR \""
+
getClass
().
getName
()
+
".addRow\""
);
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(1, 'Hello')"
);
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(1, 'Hello')"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(2, 'World')"
);
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(2, 'World')"
);
stat
.
execute
(
"CREATE ALIAS SELECT_F FOR \""
+
getClass
().
getName
()
+
".select\""
);
stat
.
execute
(
"CREATE ALIAS SELECT_F FOR \""
+
getClass
().
getName
()
+
".select\""
);
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"
);
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
2
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC"
);
rs
=
stat
.
executeQuery
(
"SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
1
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
1
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID"
);
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
1
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
"((1, Hello))"
,
rs
.
getString
(
1
));
assertEquals
(
"((1, Hello))"
,
rs
.
getString
(
1
));
rs
.
next
();
rs
.
next
();
...
@@ -337,7 +337,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -337,7 +337,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL"
);
rs
=
stat
.
executeQuery
(
"SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
1
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
"((1, Hello), (2, World))"
,
rs
.
getString
(
1
));
assertEquals
(
"((1, Hello), (2, World))"
,
rs
.
getString
(
1
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
...
@@ -351,50 +351,50 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -351,50 +351,50 @@ public class TestFunctions extends TestBase implements AggregateFunction {
stat
.
execute
(
"CREATE ALIAS SIMPLE FOR \""
+
getClass
().
getName
()
+
".simpleResultSet\""
);
stat
.
execute
(
"CREATE ALIAS SIMPLE FOR \""
+
getClass
().
getName
()
+
".simpleResultSet\""
);
rs
=
stat
.
executeQuery
(
"CALL SIMPLE(2, 1,1,1,1,1,1,1)"
);
rs
=
stat
.
executeQuery
(
"CALL SIMPLE(2, 1,1,1,1,1,1,1)"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
2
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
0
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM SIMPLE(1, 1,1,1,1,1,1,1)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM SIMPLE(1, 1,1,1,1,1,1,1)"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
2
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
0
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS ARRAY FOR \""
+
getClass
().
getName
()
+
".getArray\""
);
stat
.
execute
(
"CREATE ALIAS ARRAY FOR \""
+
getClass
().
getName
()
+
".getArray\""
);
rs
=
stat
.
executeQuery
(
"CALL ARRAY()"
);
rs
=
stat
.
executeQuery
(
"CALL ARRAY()"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
2
);
assertEquals
(
2
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
0
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS ROOT FOR \""
+
getClass
().
getName
()
+
".root\""
);
stat
.
execute
(
"CREATE ALIAS ROOT FOR \""
+
getClass
().
getName
()
+
".root\""
);
rs
=
stat
.
executeQuery
(
"CALL ROOT(9)"
);
rs
=
stat
.
executeQuery
(
"CALL ROOT(9)"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS MAX_ID FOR \""
+
getClass
().
getName
()
+
".selectMaxId\""
);
stat
.
execute
(
"CREATE ALIAS MAX_ID FOR \""
+
getClass
().
getName
()
+
".selectMaxId\""
);
rs
=
stat
.
executeQuery
(
"CALL MAX_ID()"
);
rs
=
stat
.
executeQuery
(
"CALL MAX_ID()"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM MAX_ID()"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM MAX_ID()"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"CALL CASE WHEN -9 < 0 THEN 0 ELSE ROOT(-9) END"
);
rs
=
stat
.
executeQuery
(
"CALL CASE WHEN -9 < 0 THEN 0 ELSE ROOT(-9) END"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
0
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"CREATE ALIAS blob2stream FOR \""
+
getClass
().
getName
()
+
".blob2stream\""
);
stat
.
execute
(
"CREATE ALIAS blob2stream FOR \""
+
getClass
().
getName
()
+
".blob2stream\""
);
...
@@ -414,19 +414,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -414,19 +414,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
stat
.
execute
(
"CREATE ALIAS NULL_RESULT FOR \""
+
getClass
().
getName
()
+
".nullResultSet\""
);
stat
.
execute
(
"CREATE ALIAS NULL_RESULT FOR \""
+
getClass
().
getName
()
+
".nullResultSet\""
);
rs
=
stat
.
executeQuery
(
"CALL NULL_RESULT()"
);
rs
=
stat
.
executeQuery
(
"CALL NULL_RESULT()"
);
assertEquals
(
rs
.
getMetaData
().
getColumnCount
(),
1
);
assertEquals
(
1
,
rs
.
getMetaData
().
getColumnCount
()
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
null
);
assertEquals
(
null
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
private
void
test
(
Statement
stat
,
String
sql
,
String
value
)
throws
SQLException
{
private
void
assertCallResult
(
String
expected
,
Statement
stat
,
String
sql
)
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"CALL "
+
sql
);
ResultSet
rs
=
stat
.
executeQuery
(
"CALL "
+
sql
);
rs
.
next
();
rs
.
next
();
String
s
=
rs
.
getString
(
1
);
String
s
=
rs
.
getString
(
1
);
assertEquals
(
value
,
s
);
assertEquals
(
expected
,
s
);
}
}
/**
/**
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
69aee033
...
@@ -204,10 +204,10 @@ public class TestLinkedTable extends TestBase {
...
@@ -204,10 +204,10 @@ public class TestLinkedTable extends TestBase {
stat2
.
execute
(
"CREATE LINKED TABLE two('org.h2.Driver', 'jdbc:h2:mem:one', 'sa', 'sa', 'PUBLIC.A');"
);
stat2
.
execute
(
"CREATE LINKED TABLE two('org.h2.Driver', 'jdbc:h2:mem:one', 'sa', 'sa', 'PUBLIC.A');"
);
ResultSet
rs
=
stat2
.
executeQuery
(
"SELECT * FROM one"
);
ResultSet
rs
=
stat2
.
executeQuery
(
"SELECT * FROM one"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
rs
=
stat2
.
executeQuery
(
"SELECT * FROM two"
);
rs
=
stat2
.
executeQuery
(
"SELECT * FROM two"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
conn
.
close
();
conn
.
close
();
conn2
.
close
();
conn2
.
close
();
}
}
...
@@ -270,29 +270,29 @@ public class TestLinkedTable extends TestBase {
...
@@ -270,29 +270,29 @@ public class TestLinkedTable extends TestBase {
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_DI ORDER BY ID"
);
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_DI ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
"Hello2"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assertEquals
(
"World3"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_U ORDER BY ID"
);
rs
=
stat2
.
executeQuery
(
"SELECT * FROM TEST_LINK_U ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
"Hello2"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assertEquals
(
"World3"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello2"
);
assertEquals
(
"Hello2"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World3"
);
assertEquals
(
"World3"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
...
@@ -385,22 +385,22 @@ public class TestLinkedTable extends TestBase {
...
@@ -385,22 +385,22 @@ public class TestLinkedTable extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
4
);
assertEquals
(
4
,
rs
.
getInt
(
1
)
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST WHERE NAME='Link Test'"
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST WHERE NAME='Link Test'"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
int
uc
=
stat
.
executeUpdate
(
"DELETE FROM LINK_TEST WHERE ID=3"
);
int
uc
=
stat
.
executeUpdate
(
"DELETE FROM LINK_TEST WHERE ID=3"
);
assertEquals
(
uc
,
1
);
assertEquals
(
1
,
uc
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM LINK_TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='LINK_TEST'"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='LINK_TEST'"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"TABLE_TYPE"
),
"TABLE LINK"
);
assertEquals
(
"TABLE LINK"
,
rs
.
getString
(
"TABLE_TYPE"
)
);
rs
.
next
();
rs
.
next
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST WHERE ID=0"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST WHERE ID=0"
);
...
@@ -427,7 +427,7 @@ public class TestLinkedTable extends TestBase {
...
@@ -427,7 +427,7 @@ public class TestLinkedTable extends TestBase {
+
"', 'sa1', 'abc abc', '(SELECT COUNT(*) FROM TEST)')"
);
+
"', 'sa1', 'abc abc', '(SELECT COUNT(*) FROM TEST)')"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM LINK_TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
...
@@ -439,23 +439,23 @@ public class TestLinkedTable extends TestBase {
...
@@ -439,23 +439,23 @@ public class TestLinkedTable extends TestBase {
private
void
testRow
(
Statement
stat
,
String
name
)
throws
SQLException
{
private
void
testRow
(
Statement
stat
,
String
name
)
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
name
+
" WHERE ID=1"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
name
+
" WHERE ID=1"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"NAME"
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
"NAME"
)
);
assertEquals
(
rs
.
getByte
(
"XT"
),
-
1
);
assertEquals
(
-
1
,
rs
.
getByte
(
"XT"
)
);
BigDecimal
bd
=
rs
.
getBigDecimal
(
"XD"
);
BigDecimal
bd
=
rs
.
getBigDecimal
(
"XD"
);
assertTrue
(
bd
.
equals
(
new
BigDecimal
(
"10.30"
)));
assertTrue
(
bd
.
equals
(
new
BigDecimal
(
"10.30"
)));
Timestamp
ts
=
rs
.
getTimestamp
(
"XTS"
);
Timestamp
ts
=
rs
.
getTimestamp
(
"XTS"
);
String
s
=
ts
.
toString
();
String
s
=
ts
.
toString
();
assertEquals
(
s
,
"2001-02-03 11:22:33.4455"
);
assertEquals
(
"2001-02-03 11:22:33.4455"
,
s
);
assertTrue
(
ts
.
equals
(
Timestamp
.
valueOf
(
"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
}
);
assertEquals
(
new
byte
[]
{
(
byte
)
255
,
(
byte
)
1
,
(
byte
)
2
},
rs
.
getBytes
(
"XBY"
)
);
assertTrue
(
rs
.
getBoolean
(
"XBO"
));
assertTrue
(
rs
.
getBoolean
(
"XBO"
));
assertEquals
(
rs
.
getShort
(
"XSM"
),
3000
);
assertEquals
(
3000
,
rs
.
getShort
(
"XSM"
)
);
assertEquals
(
rs
.
getLong
(
"XBI"
),
1234567890123456789L
);
assertEquals
(
1234567890123456789L
,
rs
.
getLong
(
"XBI"
)
);
assertEquals
(
rs
.
getString
(
"XBL"
),
"1122aa"
);
assertEquals
(
"1122aa"
,
rs
.
getString
(
"XBL"
)
);
assertEquals
(
rs
.
getString
(
"XDA"
),
"0002-01-01"
);
assertEquals
(
"0002-01-01"
,
rs
.
getString
(
"XDA"
)
);
assertEquals
(
rs
.
getString
(
"XTI"
),
"00:00:00"
);
assertEquals
(
"00:00:00"
,
rs
.
getString
(
"XTI"
)
);
assertEquals
(
rs
.
getString
(
"XCL"
),
"J\u00fcrg"
);
assertEquals
(
"J\u00fcrg"
,
rs
.
getString
(
"XCL"
)
);
assertEquals
(
rs
.
getString
(
"XDO"
),
"2.25"
);
assertEquals
(
"2.25"
,
rs
.
getString
(
"XDO"
)
);
}
}
}
}
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
69aee033
...
@@ -9,7 +9,6 @@ package org.h2.test.db;
...
@@ -9,7 +9,6 @@ package org.h2.test.db;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.CharArrayReader
;
import
java.io.CharArrayReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.io.StringReader
;
import
java.io.StringReader
;
...
@@ -324,7 +323,7 @@ public class TestLob extends TestBase {
...
@@ -324,7 +323,7 @@ public class TestLob extends TestBase {
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
rs
.
getInt
(
1
);
rs
.
getInt
(
1
);
assertEquals
(
rs
.
getString
(
2
).
length
(),
10000
);
assertEquals
(
10000
,
rs
.
getString
(
2
).
length
()
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -449,7 +448,7 @@ public class TestLob extends TestBase {
...
@@ -449,7 +448,7 @@ public class TestLob extends TestBase {
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select value from information_schema.settings where NAME='COMPRESS_LOB'"
);
rs
=
stat
.
executeQuery
(
"select value from information_schema.settings where NAME='COMPRESS_LOB'"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
compress
?
"LZF"
:
"NO"
);
assertEquals
(
compress
?
"LZF"
:
"NO"
,
rs
.
getString
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"create table test(text clob)"
);
stat
.
execute
(
"create table test(text clob)"
);
stat
.
execute
(
"create table test2(text clob)"
);
stat
.
execute
(
"create table test2(text clob)"
);
...
@@ -462,15 +461,15 @@ public class TestLob extends TestBase {
...
@@ -462,15 +461,15 @@ public class TestLob extends TestBase {
stat
.
execute
(
"insert into test2 select * from test"
);
stat
.
execute
(
"insert into test2 select * from test"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
spaces
);
assertEquals
(
spaces
,
rs
.
getString
(
1
)
);
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
spaces
);
assertEquals
(
spaces
,
rs
.
getString
(
1
)
);
stat
.
execute
(
"alter table test2 add column id int before text"
);
stat
.
execute
(
"alter table test2 add column id int before text"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
=
stat
.
executeQuery
(
"select * from test2"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"text"
),
spaces
);
assertEquals
(
spaces
,
rs
.
getString
(
"text"
)
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -545,10 +544,10 @@ public class TestLob extends TestBase {
...
@@ -545,10 +544,10 @@ public class TestLob extends TestBase {
Blob
b
=
rs
.
getBlob
(
"B"
);
Blob
b
=
rs
.
getBlob
(
"B"
);
Clob
c
=
rs
.
getClob
(
"C"
);
Clob
c
=
rs
.
getClob
(
"C"
);
int
l
=
i
;
int
l
=
i
;
assertEquals
(
b
.
length
(),
l
);
assertEquals
(
l
,
b
.
length
()
);
assertEquals
(
c
.
length
(),
l
);
assertEquals
(
l
,
c
.
length
()
);
checkStream
(
b
.
getBinaryStream
(),
getRandomStream
(
l
,
i
),
-
1
);
assertEqualStreams
(
getRandomStream
(
l
,
i
),
b
.
getBinaryStream
(
),
-
1
);
checkReader
(
c
.
getCharacterStream
(),
getRandomReader
(
l
,
i
),
-
1
);
assertEqualReaders
(
getRandomReader
(
l
,
i
),
c
.
getCharacterStream
(
),
-
1
);
}
}
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET B=?, C=? WHERE ID=?"
);
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET B=?, C=? WHERE ID=?"
);
...
@@ -567,10 +566,10 @@ public class TestLob extends TestBase {
...
@@ -567,10 +566,10 @@ public class TestLob extends TestBase {
Blob
b
=
rs
.
getBlob
(
"B"
);
Blob
b
=
rs
.
getBlob
(
"B"
);
Clob
c
=
rs
.
getClob
(
"C"
);
Clob
c
=
rs
.
getClob
(
"C"
);
int
l
=
i
;
int
l
=
i
;
assertEquals
(
b
.
length
(),
l
);
assertEquals
(
l
,
b
.
length
()
);
assertEquals
(
c
.
length
(),
l
);
assertEquals
(
l
,
c
.
length
()
);
checkStream
(
b
.
getBinaryStream
(),
getRandomStream
(
l
,
-
i
),
-
1
);
assertEqualStreams
(
getRandomStream
(
l
,
-
i
),
b
.
getBinaryStream
(
),
-
1
);
checkReader
(
c
.
getCharacterStream
(),
getRandomReader
(
l
,
-
i
),
-
1
);
assertEqualReaders
(
getRandomReader
(
l
,
-
i
),
c
.
getCharacterStream
(
),
-
1
);
}
}
conn
.
close
();
conn
.
close
();
...
@@ -594,21 +593,21 @@ public class TestLob extends TestBase {
...
@@ -594,21 +593,21 @@ public class TestLob extends TestBase {
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
"Bohlen"
,
rs
.
getString
(
"C"
));
assertEquals
(
"Bohlen"
,
rs
.
getString
(
"C"
));
checkReader
(
new
CharArrayReader
(
"Bohlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
assertEqualReaders
(
new
CharArrayReader
(
"Bohlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
rs
.
next
();
rs
.
next
();
checkReader
(
new
CharArrayReader
(
"B\u00f6hlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
assertEqualReaders
(
new
CharArrayReader
(
"B\u00f6hlen"
.
toCharArray
()),
rs
.
getCharacterStream
(
"C"
),
-
1
);
rs
.
next
();
rs
.
next
();
checkReader
(
getRandomReader
(
501
,
1
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
assertEqualReaders
(
getRandomReader
(
501
,
1
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
Clob
clob
=
rs
.
getClob
(
"C"
);
Clob
clob
=
rs
.
getClob
(
"C"
);
checkReader
(
getRandomReader
(
501
,
1
),
clob
.
getCharacterStream
(),
-
1
);
assertEqualReaders
(
getRandomReader
(
501
,
1
),
clob
.
getCharacterStream
(),
-
1
);
assertEquals
(
clob
.
length
(),
501
);
assertEquals
(
501
,
clob
.
length
()
);
rs
.
next
();
rs
.
next
();
checkReader
(
getRandomReader
(
401
,
2
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
assertEqualReaders
(
getRandomReader
(
401
,
2
),
rs
.
getCharacterStream
(
"C"
),
-
1
);
checkReader
(
getRandomReader
(
1500
,
2
),
rs
.
getCharacterStream
(
"C"
),
401
);
assertEqualReaders
(
getRandomReader
(
1500
,
2
),
rs
.
getCharacterStream
(
"C"
),
401
);
clob
=
rs
.
getClob
(
"C"
);
clob
=
rs
.
getClob
(
"C"
);
checkReader
(
getRandomReader
(
1501
,
2
),
clob
.
getCharacterStream
(),
401
);
assertEqualReaders
(
getRandomReader
(
1501
,
2
),
clob
.
getCharacterStream
(),
401
);
checkReader
(
getRandomReader
(
401
,
2
),
clob
.
getCharacterStream
(),
401
);
assertEqualReaders
(
getRandomReader
(
401
,
2
),
clob
.
getCharacterStream
(),
401
);
assertEquals
(
clob
.
length
(),
401
);
assertEquals
(
401
,
clob
.
length
()
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
...
@@ -687,7 +686,7 @@ public class TestLob extends TestBase {
...
@@ -687,7 +686,7 @@ public class TestLob extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID=1"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID=1"
);
rs
.
next
();
rs
.
next
();
checkStream
(
new
ByteArrayInputStream
(
data
),
rs
.
getBinaryStream
(
"TEXT"
),
-
1
);
assertEqualStreams
(
rs
.
getBinaryStream
(
"TEXT"
),
new
ByteArrayInputStream
(
data
),
-
1
);
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET TEXT = ?"
);
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET TEXT = ?"
);
prep
.
setBinaryStream
(
1
,
new
ByteArrayInputStream
(
data
),
0
);
prep
.
setBinaryStream
(
1
,
new
ByteArrayInputStream
(
data
),
0
);
...
@@ -697,7 +696,7 @@ public class TestLob extends TestBase {
...
@@ -697,7 +696,7 @@ public class TestLob extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID=1"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID=1"
);
rs
.
next
();
rs
.
next
();
checkStream
(
new
ByteArrayInputStream
(
data
),
rs
.
getBinaryStream
(
"TEXT"
),
-
1
);
assertEqualStreams
(
rs
.
getBinaryStream
(
"TEXT"
),
new
ByteArrayInputStream
(
data
),
-
1
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
conn
.
close
();
conn
.
close
();
...
@@ -743,20 +742,20 @@ public class TestLob extends TestBase {
...
@@ -743,20 +742,20 @@ public class TestLob extends TestBase {
int
size
=
id
*
id
;
int
size
=
id
*
id
;
if
(
clob
)
{
if
(
clob
)
{
Reader
rt
=
rs
.
getCharacterStream
(
2
);
Reader
rt
=
rs
.
getCharacterStream
(
2
);
checkReader
(
rt
,
getRandomReader
(
size
,
id
)
,
-
1
);
assertEqualReaders
(
getRandomReader
(
size
,
id
),
rt
,
-
1
);
Object
obj
=
rs
.
getObject
(
2
);
Object
obj
=
rs
.
getObject
(
2
);
if
(
obj
instanceof
Clob
)
{
if
(
obj
instanceof
Clob
)
{
obj
=
((
Clob
)
obj
).
getCharacterStream
();
obj
=
((
Clob
)
obj
).
getCharacterStream
();
}
}
checkReader
((
Reader
)
obj
,
getRandomReader
(
size
,
id
)
,
-
1
);
assertEqualReaders
(
getRandomReader
(
size
,
id
),
(
Reader
)
obj
,
-
1
);
}
else
{
}
else
{
InputStream
in
=
rs
.
getBinaryStream
(
2
);
InputStream
in
=
rs
.
getBinaryStream
(
2
);
checkStream
(
in
,
getRandomStream
(
size
,
id
)
,
-
1
);
assertEqualStreams
(
getRandomStream
(
size
,
id
),
in
,
-
1
);
Object
obj
=
rs
.
getObject
(
2
);
Object
obj
=
rs
.
getObject
(
2
);
if
(
obj
instanceof
Blob
)
{
if
(
obj
instanceof
Blob
)
{
obj
=
((
Blob
)
obj
).
getBinaryStream
();
obj
=
((
Blob
)
obj
).
getBinaryStream
();
}
}
checkStream
((
InputStream
)
obj
,
getRandomStream
(
size
,
id
)
,
-
1
);
assertEqualStreams
(
getRandomStream
(
size
,
id
),
(
InputStream
)
obj
,
-
1
);
}
}
}
}
trace
(
"select="
+
(
System
.
currentTimeMillis
()
-
time
));
trace
(
"select="
+
(
System
.
currentTimeMillis
()
-
time
));
...
@@ -808,49 +807,12 @@ public class TestLob extends TestBase {
...
@@ -808,49 +807,12 @@ public class TestLob extends TestBase {
TestLobObject
a
=
(
TestLobObject
)
oa
;
TestLobObject
a
=
(
TestLobObject
)
oa
;
Object
ob
=
rs
.
getObject
(
"DATA"
);
Object
ob
=
rs
.
getObject
(
"DATA"
);
TestLobObject
b
=
(
TestLobObject
)
ob
;
TestLobObject
b
=
(
TestLobObject
)
ob
;
assertEquals
(
a
.
data
,
"abc"
);
assertEquals
(
"abc"
,
a
.
data
);
assertEquals
(
b
.
data
,
"abc"
);
assertEquals
(
"abc"
,
b
.
data
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
private
void
checkStream
(
InputStream
a
,
InputStream
b
,
int
len
)
throws
IOException
{
// this doesn't actually read anything - just tests reading 0 bytes
a
.
read
(
new
byte
[
0
]);
b
.
read
(
new
byte
[
0
]);
a
.
read
(
new
byte
[
10
],
3
,
0
);
b
.
read
(
new
byte
[
10
],
0
,
0
);
for
(
int
i
=
0
;
len
<
0
||
i
<
len
;
i
++)
{
int
ca
=
a
.
read
();
a
.
read
(
new
byte
[
0
]);
int
cb
=
b
.
read
();
assertEquals
(
ca
,
cb
);
if
(
ca
==
-
1
)
{
break
;
}
}
a
.
read
(
new
byte
[
10
],
3
,
0
);
b
.
read
(
new
byte
[
10
],
0
,
0
);
a
.
read
(
new
byte
[
0
]);
b
.
read
(
new
byte
[
0
]);
a
.
close
();
b
.
close
();
}
private
void
checkReader
(
Reader
a
,
Reader
b
,
int
len
)
throws
IOException
{
for
(
int
i
=
0
;
len
<
0
||
i
<
len
;
i
++)
{
int
ca
=
a
.
read
();
int
cb
=
b
.
read
();
assertEquals
(
ca
,
cb
);
if
(
ca
==
-
1
)
{
break
;
}
}
a
.
close
();
b
.
close
();
}
private
Reader
getRandomReader
(
int
len
,
int
seed
)
{
private
Reader
getRandomReader
(
int
len
,
int
seed
)
{
return
new
CharArrayReader
(
getRandomChars
(
len
,
seed
));
return
new
CharArrayReader
(
getRandomChars
(
len
,
seed
));
}
}
...
...
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
69aee033
...
@@ -79,7 +79,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
...
@@ -79,7 +79,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
).
length
(),
10000
);
assertEquals
(
10000
,
rs
.
getString
(
1
).
length
()
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
FileUtils
.
delete
(
baseDir
+
"/test.zip"
);
FileUtils
.
delete
(
baseDir
+
"/test.zip"
);
...
@@ -165,7 +165,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
...
@@ -165,7 +165,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from employee"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from employee"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
len
);
assertEquals
(
len
,
rs
.
getInt
(
1
)
);
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
69aee033
...
@@ -353,15 +353,15 @@ public class TestOptimizations extends TestBase {
...
@@ -353,15 +353,15 @@ public class TestOptimizations extends TestBase {
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select * from test where id = (select id from test2)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select * from test where id = (select id from test2)"
);
ResultSet
rs1
=
prep
.
executeQuery
();
ResultSet
rs1
=
prep
.
executeQuery
();
rs1
.
next
();
rs1
.
next
();
assertEquals
(
rs1
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs1
.
getInt
(
1
)
);
rs1
.
next
();
rs1
.
next
();
assertEquals
(
rs1
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs1
.
getInt
(
1
)
);
assertFalse
(
rs1
.
next
());
assertFalse
(
rs1
.
next
());
stat
.
execute
(
"update test2 set id = 2"
);
stat
.
execute
(
"update test2 set id = 2"
);
ResultSet
rs2
=
prep
.
executeQuery
();
ResultSet
rs2
=
prep
.
executeQuery
();
rs2
.
next
();
rs2
.
next
();
assertEquals
(
rs2
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs2
.
getInt
(
1
)
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -455,8 +455,8 @@ public class TestOptimizations extends TestBase {
...
@@ -455,8 +455,8 @@ public class TestOptimizations extends TestBase {
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
1
,
1
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(?, ?) order by id"
);
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(?, ?) order by id"
);
...
@@ -464,29 +464,30 @@ public class TestOptimizations extends TestBase {
...
@@ -464,29 +464,30 @@ public class TestOptimizations extends TestBase {
prep
.
setInt
(
2
,
2
);
prep
.
setInt
(
2
,
2
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=?)"
);
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id "
+
"in(select t2.id from test t2 where t2.id=?)"
);
prep
.
setInt
(
1
,
2
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id "
.
prepareStatement
(
"select * from test t1 where t1.id
in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"
);
+
"
in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"
);
prep
.
setInt
(
1
,
2
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id "
.
prepareStatement
(
"select * from test t1 where t1.id
in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"
);
+
"
in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"
);
prep
.
setInt
(
1
,
2
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
69aee033
...
@@ -90,14 +90,14 @@ public class TestPowerOff extends TestBase {
...
@@ -90,14 +90,14 @@ public class TestPowerOff extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
+
i
+
" ORDER BY ID"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
+
i
+
" ORDER BY ID"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
j
);
assertEquals
(
j
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
}
}
if
(
i
==
1
)
{
if
(
i
==
1
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
j
+
10
);
assertEquals
(
j
+
10
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
}
}
}
}
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
...
@@ -219,7 +219,7 @@ public class TestPowerOff extends TestBase {
...
@@ -219,7 +219,7 @@ public class TestPowerOff extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -317,18 +317,18 @@ public class TestPowerOff extends TestBase {
...
@@ -317,18 +317,18 @@ public class TestPowerOff extends TestBase {
if
(!
rs
.
next
())
{
if
(!
rs
.
next
())
{
state
=
1
;
state
=
1
;
}
else
{
}
else
{
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
String
name1
=
rs
.
getString
(
2
);
String
name1
=
rs
.
getString
(
2
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
String
name2
=
rs
.
getString
(
2
);
String
name2
=
rs
.
getString
(
2
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
if
(
"Hello"
.
equals
(
name1
))
{
if
(
"Hello"
.
equals
(
name1
))
{
assertEquals
(
name2
,
"World"
);
assertEquals
(
"World"
,
name2
);
state
=
2
;
state
=
2
;
}
else
{
}
else
{
assertEquals
(
name1
,
"Hallo"
);
assertEquals
(
"Hallo"
,
name1
);
assertEquals
(
name2
,
"Welt"
);
assertEquals
(
"Welt"
,
name2
);
state
=
3
;
state
=
3
;
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
69aee033
...
@@ -271,7 +271,7 @@ public class TestRights extends TestBase {
...
@@ -271,7 +271,7 @@ public class TestRights extends TestBase {
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"
);
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
1
),
type
);
assertEquals
(
type
,
rs
.
getString
(
1
)
);
executeSuccess
(
"DROP TABLE TEST"
);
executeSuccess
(
"DROP TABLE TEST"
);
}
}
...
...
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
69aee033
...
@@ -76,11 +76,11 @@ public class TestSequence extends TestBase {
...
@@ -76,11 +76,11 @@ public class TestSequence extends TestBase {
stat
.
execute
(
"call next value for test_Sequence3"
);
stat
.
execute
(
"call next value for test_Sequence3"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from information_schema.sequences order by sequence_name"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from information_schema.sequences order by sequence_name"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE"
);
assertEquals
(
"TEST_SEQUENCE"
,
rs
.
getString
(
"SEQUENCE_NAME"
)
);
assertEquals
(
rs
.
getString
(
"CACHE"
),
"32"
);
assertEquals
(
"32"
,
rs
.
getString
(
"CACHE"
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"SEQUENCE_NAME"
),
"TEST_SEQUENCE3"
);
assertEquals
(
"TEST_SEQUENCE3"
,
rs
.
getString
(
"SEQUENCE_NAME"
)
);
assertEquals
(
rs
.
getString
(
"CACHE"
),
"3"
);
assertEquals
(
"3"
,
rs
.
getString
(
"CACHE"
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
69aee033
...
@@ -123,12 +123,12 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
...
@@ -123,12 +123,12 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
2
),
"Hello-updated"
);
assertEquals
(
"Hello-updated"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"UPDATE TEST SET NAME=NAME||'-upd'"
);
stat
.
execute
(
"UPDATE TEST SET NAME=NAME||'-upd'"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
2
),
"Hello-updated-upd-updated2"
);
assertEquals
(
"Hello-updated-upd-updated2"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
mustNotCallTrigger
=
true
;
mustNotCallTrigger
=
true
;
...
...
h2/src/test/org/h2/test/db/TestTwoPhaseCommit.java
浏览文件 @
69aee033
...
@@ -52,12 +52,12 @@ public class TestTwoPhaseCommit extends TestBase {
...
@@ -52,12 +52,12 @@ public class TestTwoPhaseCommit extends TestBase {
stat
.
execute
(
"SET WRITE_DELAY 0"
);
stat
.
execute
(
"SET WRITE_DELAY 0"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
if
(!
rolledBack
)
{
if
(!
rolledBack
)
{
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"World"
);
assertEquals
(
"World"
,
rs
.
getString
(
2
)
);
}
}
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
69aee033
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
69aee033
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
69aee033
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
69aee033
...
@@ -193,9 +193,9 @@ public class TestStatement extends TestBase {
...
@@ -193,9 +193,9 @@ public class TestStatement extends TestBase {
// calls are ignored
// calls are ignored
if
(
config
.
jdk14
)
{
if
(
config
.
jdk14
)
{
assertEquals
(
stat
.
getResultSetHoldability
(),
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
stat
.
getResultSetHoldability
()
);
}
}
assertEquals
(
stat
.
getResultSetConcurrency
(),
ResultSet
.
CONCUR_READ_ONLY
);
assertEquals
(
ResultSet
.
CONCUR_READ_ONLY
,
stat
.
getResultSetConcurrency
()
);
stat
.
cancel
();
stat
.
cancel
();
stat
.
setQueryTimeout
(
10
);
stat
.
setQueryTimeout
(
10
);
...
@@ -212,22 +212,22 @@ public class TestStatement extends TestBase {
...
@@ -212,22 +212,22 @@ public class TestStatement extends TestBase {
assertTrue
(
stat
.
getQueryTimeout
()
==
0
);
assertTrue
(
stat
.
getQueryTimeout
()
==
0
);
trace
(
"executeUpdate"
);
trace
(
"executeUpdate"
);
count
=
stat
.
executeUpdate
(
"CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"
);
count
=
stat
.
executeUpdate
(
"CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"
);
assertEquals
(
count
,
0
);
assertEquals
(
0
,
count
);
count
=
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(1,'Hello')"
);
count
=
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(1,'Hello')"
);
assertEquals
(
count
,
1
);
assertEquals
(
1
,
count
);
count
=
stat
.
executeUpdate
(
"INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)"
);
count
=
stat
.
executeUpdate
(
"INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)"
);
assertEquals
(
count
,
1
);
assertEquals
(
1
,
count
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='LDBC' WHERE ID=2 OR ID=1"
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='LDBC' WHERE ID=2 OR ID=1"
);
assertEquals
(
count
,
2
);
assertEquals
(
2
,
count
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='\\LDBC\\' WHERE VALUE LIKE 'LDBC' "
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='\\LDBC\\' WHERE VALUE LIKE 'LDBC' "
);
assertEquals
(
count
,
2
);
assertEquals
(
2
,
count
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='LDBC' WHERE VALUE LIKE '\\\\LDBC\\\\'"
);
count
=
stat
.
executeUpdate
(
"UPDATE TEST SET VALUE='LDBC' WHERE VALUE LIKE '\\\\LDBC\\\\'"
);
trace
(
"count:"
+
count
);
trace
(
"count:"
+
count
);
assertEquals
(
count
,
2
);
assertEquals
(
2
,
count
);
count
=
stat
.
executeUpdate
(
"DELETE FROM TEST WHERE ID=-1"
);
count
=
stat
.
executeUpdate
(
"DELETE FROM TEST WHERE ID=-1"
);
assertEquals
(
count
,
0
);
assertEquals
(
0
,
count
);
count
=
stat
.
executeUpdate
(
"DELETE FROM TEST WHERE ID=2"
);
count
=
stat
.
executeUpdate
(
"DELETE FROM TEST WHERE ID=2"
);
assertEquals
(
count
,
1
);
assertEquals
(
1
,
count
);
try
{
try
{
stat
.
executeUpdate
(
"SELECT * FROM TEST"
);
stat
.
executeUpdate
(
"SELECT * FROM TEST"
);
fail
(
"executeUpdate allowed SELECT"
);
fail
(
"executeUpdate allowed SELECT"
);
...
@@ -349,37 +349,37 @@ public class TestStatement extends TestBase {
...
@@ -349,37 +349,37 @@ public class TestStatement extends TestBase {
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
);
ResultSet
rs
=
stat
.
getGeneratedKeys
();
ResultSet
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
Statement
.
RETURN_GENERATED_KEYS
);
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
Statement
.
RETURN_GENERATED_KEYS
);
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
2
);
assertEquals
(
2
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
int
[]
{
1
});
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
int
[]
{
1
});
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
3
);
assertEquals
(
3
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
String
[]
{
"ID"
});
stat
.
execute
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
String
[]
{
"ID"
});
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
4
);
assertEquals
(
4
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
Statement
.
RETURN_GENERATED_KEYS
);
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
Statement
.
RETURN_GENERATED_KEYS
);
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
5
);
assertEquals
(
5
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
int
[]
{
1
});
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
int
[]
{
1
});
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
6
);
assertEquals
(
6
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
String
[]
{
"ID"
});
stat
.
executeUpdate
(
"INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)"
,
new
String
[]
{
"ID"
});
rs
=
stat
.
getGeneratedKeys
();
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
7
);
assertEquals
(
7
,
rs
.
getInt
(
1
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST"
);
stat
.
execute
(
"DROP TABLE TEST"
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
浏览文件 @
69aee033
...
@@ -38,17 +38,17 @@ public class TestTransactionIsolation extends TestBase {
...
@@ -38,17 +38,17 @@ public class TestTransactionIsolation extends TestBase {
private
void
testTableLevelLocking
()
throws
SQLException
{
private
void
testTableLevelLocking
()
throws
SQLException
{
deleteDb
(
"transactionIsolation"
);
deleteDb
(
"transactionIsolation"
);
conn1
=
getConnection
(
"transactionIsolation"
);
conn1
=
getConnection
(
"transactionIsolation"
);
assertEquals
(
conn1
.
getTransactionIsolation
(),
Connection
.
TRANSACTION_READ_COMMITTED
);
assertEquals
(
Connection
.
TRANSACTION_READ_COMMITTED
,
conn1
.
getTransactionIsolation
()
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_SERIALIZABLE
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_SERIALIZABLE
);
assertEquals
(
conn1
.
getTransactionIsolation
(),
Connection
.
TRANSACTION_SERIALIZABLE
);
assertEquals
(
Connection
.
TRANSACTION_SERIALIZABLE
,
conn1
.
getTransactionIsolation
()
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
);
assertEquals
(
conn1
.
getTransactionIsolation
(),
Connection
.
TRANSACTION_READ_UNCOMMITTED
);
assertEquals
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
,
conn1
.
getTransactionIsolation
()
);
assertSingleValue
(
conn1
.
createStatement
(),
"CALL LOCK_MODE()"
,
0
);
assertSingleValue
(
conn1
.
createStatement
(),
"CALL LOCK_MODE()"
,
0
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_COMMITTED
);
conn1
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_COMMITTED
);
assertSingleValue
(
conn1
.
createStatement
(),
"CALL LOCK_MODE()"
,
3
);
assertSingleValue
(
conn1
.
createStatement
(),
"CALL LOCK_MODE()"
,
3
);
assertEquals
(
conn1
.
getTransactionIsolation
(),
Connection
.
TRANSACTION_READ_COMMITTED
);
assertEquals
(
Connection
.
TRANSACTION_READ_COMMITTED
,
conn1
.
getTransactionIsolation
()
);
conn1
.
createStatement
().
execute
(
"SET LOCK_MODE 1"
);
conn1
.
createStatement
().
execute
(
"SET LOCK_MODE 1"
);
assertEquals
(
conn1
.
getTransactionIsolation
(),
Connection
.
TRANSACTION_SERIALIZABLE
);
assertEquals
(
Connection
.
TRANSACTION_SERIALIZABLE
,
conn1
.
getTransactionIsolation
()
);
conn1
.
createStatement
().
execute
(
"CREATE TABLE TEST(ID INT)"
);
conn1
.
createStatement
().
execute
(
"CREATE TABLE TEST(ID INT)"
);
conn1
.
createStatement
().
execute
(
"INSERT INTO TEST VALUES(1)"
);
conn1
.
createStatement
().
execute
(
"INSERT INTO TEST VALUES(1)"
);
conn1
.
setAutoCommit
(
false
);
conn1
.
setAutoCommit
(
false
);
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
69aee033
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
69aee033
...
@@ -67,13 +67,13 @@ public class TestZloty extends TestBase {
...
@@ -67,13 +67,13 @@ public class TestZloty extends TestBase {
prep
.
execute
();
prep
.
execute
();
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
0
);
assertEquals
(
0
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getBytes
(
2
)[
0
],
0
);
assertEquals
(
0
,
rs
.
getBytes
(
2
)[
0
]
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getBytes
(
2
)[
0
],
1
);
assertEquals
(
1
,
rs
.
getBytes
(
2
)[
0
]
);
rs
.
getBytes
(
2
)[
0
]
=
2
;
rs
.
getBytes
(
2
)[
0
]
=
2
;
assertEquals
(
rs
.
getBytes
(
2
)[
0
],
1
);
assertEquals
(
1
,
rs
.
getBytes
(
2
)[
0
]
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
浏览文件 @
69aee033
...
@@ -73,7 +73,7 @@ public class TestDataSource extends TestBase {
...
@@ -73,7 +73,7 @@ public class TestDataSource extends TestBase {
XAResource
res
=
xaConn
.
getXAResource
();
XAResource
res
=
xaConn
.
getXAResource
();
Connection
conn
=
xaConn
.
getConnection
();
Connection
conn
=
xaConn
.
getConnection
();
Xid
[]
list
=
res
.
recover
(
XAResource
.
TMSTARTRSCAN
);
Xid
[]
list
=
res
.
recover
(
XAResource
.
TMSTARTRSCAN
);
assertEquals
(
list
.
length
,
0
);
assertEquals
(
0
,
list
.
length
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SELECT * FROM DUAL"
);
stat
.
execute
(
"SELECT * FROM DUAL"
);
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
浏览文件 @
69aee033
差异被折叠。
点击展开。
h2/src/test/org/h2/test/server/TestNestedLoop.java
浏览文件 @
69aee033
...
@@ -60,13 +60,13 @@ public class TestNestedLoop extends TestBase {
...
@@ -60,13 +60,13 @@ public class TestNestedLoop extends TestBase {
int
id
=
rs
.
getInt
(
1
);
int
id
=
rs
.
getInt
(
1
);
ResultSet
rs2
=
stat2
.
executeQuery
(
"select * from test where id="
+
id
);
ResultSet
rs2
=
stat2
.
executeQuery
(
"select * from test where id="
+
id
);
while
(
rs2
.
next
())
{
while
(
rs2
.
next
())
{
assertEquals
(
rs2
.
getInt
(
1
),
id
);
assertEquals
(
id
,
rs2
.
getInt
(
1
)
);
assertEquals
(
rs2
.
getString
(
2
),
"Hello World"
);
assertEquals
(
"Hello World"
,
rs2
.
getString
(
2
)
);
}
}
rs2
=
stat2
.
executeQuery
(
"select * from test where id="
+
id
);
rs2
=
stat2
.
executeQuery
(
"select * from test where id="
+
id
);
while
(
rs2
.
next
())
{
while
(
rs2
.
next
())
{
assertEquals
(
rs2
.
getInt
(
1
),
id
);
assertEquals
(
id
,
rs2
.
getInt
(
1
)
);
assertEquals
(
rs2
.
getString
(
2
),
"Hello World"
);
assertEquals
(
"Hello World"
,
rs2
.
getString
(
2
)
);
}
}
}
}
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/synth/TestKill.java
浏览文件 @
69aee033
...
@@ -125,7 +125,7 @@ public class TestKill extends TestBase {
...
@@ -125,7 +125,7 @@ public class TestKill extends TestBase {
ResultSet
rs2
=
prep
.
executeQuery
();
ResultSet
rs2
=
prep
.
executeQuery
();
rs2
.
next
();
rs2
.
next
();
int
sumLog
=
rs2
.
getInt
(
1
);
int
sumLog
=
rs2
.
getInt
(
1
);
assertEquals
(
sum
Log
,
sum
);
assertEquals
(
sum
,
sumLog
);
trace
(
"account="
+
account
+
" sum="
+
sum
);
trace
(
"account="
+
account
+
" sum="
+
sum
);
}
}
PreparedStatement
p1
=
conn
.
prepareStatement
(
"SELECT * FROM TEST_A WHERE ID=?"
);
PreparedStatement
p1
=
conn
.
prepareStatement
(
"SELECT * FROM TEST_A WHERE ID=?"
);
...
...
h2/src/test/org/h2/test/synth/TestTimer.java
浏览文件 @
69aee033
...
@@ -80,7 +80,7 @@ public class TestTimer extends TestBase {
...
@@ -80,7 +80,7 @@ public class TestTimer extends TestBase {
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
rs
.
next
();
int
c
=
rs
.
getInt
(
1
);
int
c
=
rs
.
getInt
(
1
);
assertEquals
(
c
,
count
);
assertEquals
(
c
ount
,
c
);
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
if
(
time
>
start
+
5000
)
{
if
(
time
>
start
+
5000
)
{
println
(
"rows: "
+
count
);
println
(
"rows: "
+
count
);
...
...
h2/src/test/org/h2/test/synth/thread/TestMultiOrder.java
浏览文件 @
69aee033
...
@@ -136,17 +136,17 @@ public class TestMultiOrder extends TestMultiThread {
...
@@ -136,17 +136,17 @@ public class TestMultiOrder extends TestMultiThread {
conn
=
base
.
getConnection
();
conn
=
base
.
getConnection
();
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from customer"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from customer"
);
rs
.
next
();
rs
.
next
();
base
.
assertEquals
(
rs
.
getInt
(
1
),
customerCount
);
base
.
assertEquals
(
customerCount
,
rs
.
getInt
(
1
)
);
// System.out.println("customers: " + rs.getInt(1));
// System.out.println("customers: " + rs.getInt(1));
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from orders"
);
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from orders"
);
rs
.
next
();
rs
.
next
();
base
.
assertEquals
(
rs
.
getInt
(
1
),
orderCount
);
base
.
assertEquals
(
orderCount
,
rs
.
getInt
(
1
)
);
// System.out.println("orders: " + rs.getInt(1));
// System.out.println("orders: " + rs.getInt(1));
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from orderLine"
);
rs
=
conn
.
createStatement
().
executeQuery
(
"select count(*) from orderLine"
);
rs
.
next
();
rs
.
next
();
base
.
assertEquals
(
rs
.
getInt
(
1
),
orderLineCount
);
base
.
assertEquals
(
orderLineCount
,
rs
.
getInt
(
1
)
);
// System.out.println("orderLines: " + rs.getInt(1));
// System.out.println("orderLines: " + rs.getInt(1));
conn
.
close
();
conn
.
close
();
...
...
h2/src/test/org/h2/test/unit/TestBitField.java
浏览文件 @
69aee033
...
@@ -118,9 +118,9 @@ public class TestBitField extends TestBase {
...
@@ -118,9 +118,9 @@ public class TestBitField extends TestBase {
set
.
clear
(
idx
);
set
.
clear
(
idx
);
}
}
}
else
{
}
else
{
assertEquals
(
bits
.
get
(
idx
),
set
.
get
(
idx
));
assertEquals
(
set
.
get
(
idx
),
bits
.
get
(
idx
));
assertEquals
(
bits
.
nextClearBit
(
idx
),
set
.
nextClearBit
(
idx
));
assertEquals
(
set
.
nextClearBit
(
idx
),
bits
.
nextClearBit
(
idx
));
assertEquals
(
bits
.
nextSetBit
(
idx
),
set
.
nextSetBit
(
idx
));
assertEquals
(
set
.
nextSetBit
(
idx
),
bits
.
nextSetBit
(
idx
));
}
}
}
}
}
}
...
@@ -164,7 +164,7 @@ public class TestBitField extends TestBase {
...
@@ -164,7 +164,7 @@ public class TestBitField extends TestBase {
set
.
set
(
offset
,
offset
+
len
,
val
);
set
.
set
(
offset
,
offset
+
len
,
val
);
bits
.
setRange
(
offset
,
len
,
val
);
bits
.
setRange
(
offset
,
len
,
val
);
for
(
int
j
=
0
;
j
<
total
;
j
++)
{
for
(
int
j
=
0
;
j
<
total
;
j
++)
{
assertEquals
(
bits
.
get
(
j
),
set
.
get
(
j
));
assertEquals
(
set
.
get
(
j
),
bits
.
get
(
j
));
}
}
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestCompress.java
浏览文件 @
69aee033
...
@@ -80,7 +80,7 @@ public class TestCompress extends TestBase {
...
@@ -80,7 +80,7 @@ public class TestCompress extends TestBase {
for
(
String
a
:
new
String
[]
{
"LZF"
,
"Deflate"
,
"No"
})
{
for
(
String
a
:
new
String
[]
{
"LZF"
,
"Deflate"
,
"No"
})
{
byte
[]
out
=
utils
.
compress
(
buff
,
a
);
byte
[]
out
=
utils
.
compress
(
buff
,
a
);
byte
[]
test
=
utils
.
expand
(
out
);
byte
[]
test
=
utils
.
expand
(
out
);
assertEquals
(
test
.
length
,
buff
.
length
);
assertEquals
(
buff
.
length
,
test
.
length
);
assertEquals
(
buff
,
test
);
assertEquals
(
buff
,
test
);
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestDataPage.java
浏览文件 @
69aee033
...
@@ -51,7 +51,7 @@ public class TestDataPage extends TestBase implements DataHandler {
...
@@ -51,7 +51,7 @@ public class TestDataPage extends TestBase implements DataHandler {
String
s
=
new
String
(
data
);
String
s
=
new
String
(
data
);
page
.
writeString
(
s
);
page
.
writeString
(
s
);
int
len
=
page
.
length
();
int
len
=
page
.
length
();
assertEquals
(
page
.
getStringLen
(
s
),
len
);
assertEquals
(
len
,
page
.
getStringLen
(
s
)
);
page
.
reset
();
page
.
reset
();
assertEquals
(
s
,
page
.
readString
());
assertEquals
(
s
,
page
.
readString
());
page
.
reset
();
page
.
reset
();
...
...
h2/src/test/org/h2/test/unit/TestFileLock.java
浏览文件 @
69aee033
...
@@ -84,7 +84,7 @@ public class TestFileLock extends TestBase implements Runnable {
...
@@ -84,7 +84,7 @@ public class TestFileLock extends TestBase implements Runnable {
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
{
threads
[
i
].
join
();
threads
[
i
].
join
();
}
}
assertEquals
(
locks
,
0
);
assertEquals
(
0
,
locks
);
}
}
public
void
run
()
{
public
void
run
()
{
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
69aee033
...
@@ -146,11 +146,11 @@ public class TestFileSystem extends TestBase {
...
@@ -146,11 +146,11 @@ public class TestFileSystem extends TestBase {
long
lastMod
=
fs
.
getLastModified
(
fsBase
+
"/test"
);
long
lastMod
=
fs
.
getLastModified
(
fsBase
+
"/test"
);
if
(
lastMod
<
time
-
1999
)
{
if
(
lastMod
<
time
-
1999
)
{
// at most 2 seconds difference
// at most 2 seconds difference
assertEquals
(
lastMod
,
time
);
assertEquals
(
time
,
lastMod
);
}
}
assertEquals
(
fs
.
length
(
fsBase
+
"/test"
),
10000
);
assertEquals
(
10000
,
fs
.
length
(
fsBase
+
"/test"
)
);
String
[]
list
=
fs
.
listFiles
(
fsBase
);
String
[]
list
=
fs
.
listFiles
(
fsBase
);
assertEquals
(
list
.
length
,
1
);
assertEquals
(
1
,
list
.
length
);
assertTrue
(
list
[
0
].
endsWith
(
"test"
));
assertTrue
(
list
[
0
].
endsWith
(
"test"
));
fs
.
copy
(
fsBase
+
"/test"
,
fsBase
+
"/test3"
);
fs
.
copy
(
fsBase
+
"/test"
,
fsBase
+
"/test3"
);
...
@@ -279,10 +279,10 @@ public class TestFileSystem extends TestBase {
...
@@ -279,10 +279,10 @@ public class TestFileSystem extends TestBase {
out
.
close
();
out
.
close
();
InputStream
in
=
fs
.
openFileInputStream
(
s
);
InputStream
in
=
fs
.
openFileInputStream
(
s
);
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
assertEquals
(
in
.
read
(),
0
);
assertEquals
(
0
,
in
.
read
()
);
}
}
assertEquals
(
in
.
read
(),
1
);
assertEquals
(
1
,
in
.
read
()
);
assertEquals
(
in
.
read
(),
-
1
);
assertEquals
(
-
1
,
in
.
read
()
);
in
.
close
();
in
.
close
();
out
.
close
();
out
.
close
();
}
}
...
...
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
69aee033
...
@@ -41,11 +41,11 @@ public class TestFtp extends TestBase implements FtpEventListener {
...
@@ -41,11 +41,11 @@ public class TestFtp extends TestBase implements FtpEventListener {
client
.
login
(
"sa"
,
"sa"
);
client
.
login
(
"sa"
,
"sa"
);
client
.
makeDirectory
(
"test"
);
client
.
makeDirectory
(
"test"
);
client
.
changeWorkingDirectory
(
"test"
);
client
.
changeWorkingDirectory
(
"test"
);
assertEquals
(
lastEvent
.
getCommand
(),
"CWD"
);
assertEquals
(
"CWD"
,
lastEvent
.
getCommand
()
);
client
.
makeDirectory
(
"hello"
);
client
.
makeDirectory
(
"hello"
);
client
.
changeWorkingDirectory
(
"hello"
);
client
.
changeWorkingDirectory
(
"hello"
);
client
.
changeDirectoryUp
();
client
.
changeDirectoryUp
();
assertEquals
(
lastEvent
.
getCommand
(),
"CDUP"
);
assertEquals
(
"CDUP"
,
lastEvent
.
getCommand
()
);
client
.
nameList
(
"hello"
);
client
.
nameList
(
"hello"
);
client
.
removeDirectory
(
"hello"
);
client
.
removeDirectory
(
"hello"
);
client
.
close
();
client
.
close
();
...
...
h2/src/test/org/h2/test/unit/TestIntArray.java
浏览文件 @
69aee033
...
@@ -73,11 +73,11 @@ public class TestIntArray extends TestBase {
...
@@ -73,11 +73,11 @@ public class TestIntArray extends TestBase {
test
=
sort
(
test
);
test
=
sort
(
test
);
int
a
=
array
.
findNextIndexSorted
(
v
);
int
a
=
array
.
findNextIndexSorted
(
v
);
int
b
=
findNextValueIndex
(
test
,
v
);
int
b
=
findNextValueIndex
(
test
,
v
);
assertEquals
(
a
,
b
);
assertEquals
(
b
,
a
);
break
;
break
;
case
4
:
case
4
:
if
(
test
.
length
>
idx
)
{
if
(
test
.
length
>
idx
)
{
assertEquals
(
array
.
get
(
idx
),
get
(
test
,
idx
));
assertEquals
(
get
(
test
,
idx
),
array
.
get
(
idx
));
}
}
break
;
break
;
case
5
:
case
5
:
...
@@ -96,11 +96,11 @@ public class TestIntArray extends TestBase {
...
@@ -96,11 +96,11 @@ public class TestIntArray extends TestBase {
test
=
set
(
test
,
idx
,
v
);
test
=
set
(
test
,
idx
,
v
);
break
;
break
;
case
8
:
case
8
:
assertEquals
(
array
.
size
(),
test
.
length
);
assertEquals
(
test
.
length
,
array
.
size
()
);
break
;
break
;
default
:
default
:
}
}
assertEquals
(
array
.
size
(),
test
.
length
);
assertEquals
(
test
.
length
,
array
.
size
()
);
for
(
int
j
=
0
;
j
<
test
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
test
.
length
;
j
++)
{
assertEquals
(
test
[
j
],
array
.
get
(
j
));
assertEquals
(
test
[
j
],
array
.
get
(
j
));
}
}
...
...
h2/src/test/org/h2/test/unit/TestPgServer.java
浏览文件 @
69aee033
...
@@ -69,34 +69,34 @@ public class TestPgServer extends TestBase {
...
@@ -69,34 +69,34 @@ public class TestPgServer extends TestBase {
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
rs
.
next
();
prep
.
close
();
prep
.
close
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test where id = ? and name = ?"
);
prep
=
conn
.
prepareStatement
(
"select * from test where id = ? and name = ?"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
1
,
1
);
prep
.
setString
(
2
,
"Hello"
);
prep
.
setString
(
2
,
"Hello"
);
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getInt
(
1
),
1
);
assertEquals
(
1
,
rs
.
getInt
(
1
)
);
assertEquals
(
rs
.
getString
(
2
),
"Hello"
);
assertEquals
(
"Hello"
,
rs
.
getString
(
2
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
.
close
();
rs
.
close
();
DatabaseMetaData
dbMeta
=
conn
.
getMetaData
();
DatabaseMetaData
dbMeta
=
conn
.
getMetaData
();
rs
=
dbMeta
.
getTables
(
null
,
null
,
"TEST"
,
null
);
rs
=
dbMeta
.
getTables
(
null
,
null
,
"TEST"
,
null
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"TABLE_NAME"
),
"TEST"
);
assertEquals
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
dbMeta
.
getColumns
(
null
,
null
,
"TEST"
,
null
);
rs
=
dbMeta
.
getColumns
(
null
,
null
,
"TEST"
,
null
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"COLUMN_NAME"
),
"ID"
);
assertEquals
(
"ID"
,
rs
.
getString
(
"COLUMN_NAME"
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"COLUMN_NAME"
),
"NAME"
);
assertEquals
(
"NAME"
,
rs
.
getString
(
"COLUMN_NAME"
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
dbMeta
.
getIndexInfo
(
null
,
null
,
"TEST"
,
false
,
false
);
rs
=
dbMeta
.
getIndexInfo
(
null
,
null
,
"TEST"
,
false
,
false
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"TABLE_NAME"
),
"TEST"
);
assertEquals
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
)
);
rs
.
next
();
rs
.
next
();
assertEquals
(
rs
.
getString
(
"TABLE_NAME"
),
"TEST"
);
assertEquals
(
"TEST"
,
rs
.
getString
(
"TABLE_NAME"
)
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"select version(), pg_postmaster_start_time(), current_schema()"
);
rs
=
stat
.
executeQuery
(
"select version(), pg_postmaster_start_time(), current_schema()"
);
rs
.
next
();
rs
.
next
();
...
...
h2/src/test/org/h2/test/unit/TestReader.java
浏览文件 @
69aee033
...
@@ -37,7 +37,7 @@ public class TestReader extends TestBase {
...
@@ -37,7 +37,7 @@ public class TestReader extends TestBase {
InputStream
in2
=
new
ByteArrayInputStream
(
buff
);
InputStream
in2
=
new
ByteArrayInputStream
(
buff
);
Reader
r2
=
IOUtils
.
getReader
(
in2
);
Reader
r2
=
IOUtils
.
getReader
(
in2
);
String
s2
=
IOUtils
.
readStringAndClose
(
r2
,
Integer
.
MAX_VALUE
);
String
s2
=
IOUtils
.
readStringAndClose
(
r2
,
Integer
.
MAX_VALUE
);
assertEquals
(
s
2
,
"\u00ef\u00f6\u00fc"
);
assertEquals
(
s
,
s2
);
}
}
}
}
h2/src/test/org/h2/test/unit/TestSampleApps.java
浏览文件 @
69aee033
...
@@ -88,10 +88,10 @@ public class TestSampleApps extends TestBase {
...
@@ -88,10 +88,10 @@ public class TestSampleApps extends TestBase {
if
(
expected
.
endsWith
(
"*"
))
{
if
(
expected
.
endsWith
(
"*"
))
{
expected
=
expected
.
substring
(
0
,
expected
.
length
()
-
1
);
expected
=
expected
.
substring
(
0
,
expected
.
length
()
-
1
);
if
(!
s
.
startsWith
(
expected
))
{
if
(!
s
.
startsWith
(
expected
))
{
assertEquals
(
s
.
trim
(),
expected
.
trim
());
assertEquals
(
expected
.
trim
(),
s
.
trim
());
}
}
}
else
{
}
else
{
assertEquals
(
s
.
trim
(),
expected
.
trim
());
assertEquals
(
expected
.
trim
(),
s
.
trim
());
}
}
}
}
}
}
h2/src/test/org/h2/test/unit/TestSecurity.java
浏览文件 @
69aee033
...
@@ -42,7 +42,7 @@ public class TestSecurity extends TestBase {
...
@@ -42,7 +42,7 @@ public class TestSecurity extends TestBase {
private
String
getHashString
(
SHA256
sha
,
byte
[]
data
)
{
private
String
getHashString
(
SHA256
sha
,
byte
[]
data
)
{
byte
[]
result
=
sha
.
getHash
(
data
,
true
);
byte
[]
result
=
sha
.
getHash
(
data
,
true
);
if
(
data
.
length
>
0
)
{
if
(
data
.
length
>
0
)
{
assertEquals
(
data
[
0
],
0
);
assertEquals
(
0
,
data
[
0
]
);
}
}
return
ByteUtils
.
convertBytesToString
(
result
);
return
ByteUtils
.
convertBytesToString
(
result
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
69aee033
...
@@ -68,9 +68,9 @@ public class TestValue extends TestBase {
...
@@ -68,9 +68,9 @@ public class TestValue extends TestBase {
minLow
&=
uuid
.
getLow
();
minLow
&=
uuid
.
getLow
();
}
}
ValueUuid
max
=
ValueUuid
.
get
(
maxHigh
,
maxLow
);
ValueUuid
max
=
ValueUuid
.
get
(
maxHigh
,
maxLow
);
assertEquals
(
max
.
getString
(),
"ffffffff-ffff-4fff-bfff-ffffffffffff"
);
assertEquals
(
"ffffffff-ffff-4fff-bfff-ffffffffffff"
,
max
.
getString
()
);
ValueUuid
min
=
ValueUuid
.
get
(
minHigh
,
minLow
);
ValueUuid
min
=
ValueUuid
.
get
(
minHigh
,
minLow
);
assertEquals
(
min
.
getString
(),
"00000000-0000-4000-8000-000000000000"
);
assertEquals
(
"00000000-0000-4000-8000-000000000000"
,
min
.
getString
()
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论