Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6ae22bc7
提交
6ae22bc7
authored
6月 05, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
junit compatibility
上级
67a43816
隐藏空白字符变更
内嵌
并排
正在显示
49 个修改的文件
包含
352 行增加
和
182 行删除
+352
-182
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+21
-5
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+37
-35
TestAutoRecompile.java
h2/src/test/org/h2/test/db/TestAutoRecompile.java
+2
-2
TestBigResult.java
h2/src/test/org/h2/test/db/TestBigResult.java
+1
-1
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+7
-7
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+2
-2
TestEncryptedDb.java
h2/src/test/org/h2/test/db/TestEncryptedDb.java
+1
-1
TestExclusive.java
h2/src/test/org/h2/test/db/TestExclusive.java
+1
-1
TestFunctionOverload.java
h2/src/test/org/h2/test/db/TestFunctionOverload.java
+152
-0
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+1
-1
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+2
-2
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+5
-5
TestMemoryUsage.java
h2/src/test/org/h2/test/db/TestMemoryUsage.java
+4
-4
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+1
-1
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+3
-3
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+2
-2
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+7
-7
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+1
-1
TestSQLInjection.java
h2/src/test/org/h2/test/db/TestSQLInjection.java
+4
-4
TestSpaceReuse.java
h2/src/test/org/h2/test/db/TestSpaceReuse.java
+1
-1
TestTempTables.java
h2/src/test/org/h2/test/db/TestTempTables.java
+1
-1
TestTransaction.java
h2/src/test/org/h2/test/db/TestTransaction.java
+6
-6
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+2
-2
TestBatchUpdates.java
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
+16
-16
TestCancel.java
h2/src/test/org/h2/test/jdbc/TestCancel.java
+4
-4
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+5
-5
TestNativeSQL.java
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
+1
-1
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+8
-8
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+2
-2
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+12
-12
TestTransactionIsolation.java
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
+2
-2
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+1
-1
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+2
-2
TestMvcc1.java
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
+5
-5
TestNestedLoop.java
h2/src/test/org/h2/test/server/TestNestedLoop.java
+2
-2
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+1
-1
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+3
-3
TestKillRestartMulti.java
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
+3
-3
TestSimpleIndex.java
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
+1
-1
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+1
-1
TestExit.java
h2/src/test/org/h2/test/unit/TestExit.java
+2
-2
TestFile.java
h2/src/test/org/h2/test/unit/TestFile.java
+1
-1
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+1
-1
TestOverflow.java
h2/src/test/org/h2/test/unit/TestOverflow.java
+2
-2
TestPattern.java
h2/src/test/org/h2/test/unit/TestPattern.java
+2
-2
TestServlet.java
h2/src/test/org/h2/test/unit/TestServlet.java
+3
-3
TestStringUtils.java
h2/src/test/org/h2/test/unit/TestStringUtils.java
+2
-2
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+5
-5
TestValueMemory.java
h2/src/test/org/h2/test/unit/TestValueMemory.java
+1
-1
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
6ae22bc7
...
...
@@ -22,6 +22,7 @@ import org.h2.test.db.TestCsv;
import
org.h2.test.db.TestEncryptedDb
;
import
org.h2.test.db.TestExclusive
;
import
org.h2.test.db.TestFullText
;
import
org.h2.test.db.TestFunctionOverload
;
import
org.h2.test.db.TestFunctions
;
import
org.h2.test.db.TestIndex
;
import
org.h2.test.db.TestLinkedTable
;
...
...
@@ -167,11 +168,25 @@ java org.h2.test.TestAll timer
/*
feature to clear the screen for the command
line console (not the web console but the Shell) ? Whenever my Shell
gets too over populated with data, I have to close it and open it
again to clear the screen since there's no way I can clear the screen
for the current versions.
CREATE ALIAS IF NOT EXISTS FTL_INIT FOR "org.h2.fulltext.FullTextLucene.init";
CALL FTL_INIT();
DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR);
INSERT INTO TEST VALUES(1, 'Hello World');
CALL FTL_CREATE_INDEX('PUBLIC', 'TEST', NULL);
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
INSERT INTO TEST VALUES(2, 'Hallo Welt');
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
CALL FTL_REINDEX();
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
INSERT INTO TEST VALUES(3, 'Hello World');
INSERT INTO TEST VALUES(4, 'Hello World');
INSERT INTO TEST VALUES(5, 'Hello World');
SELECT * FROM FTL_SEARCH('World', 0, 0);
SELECT * FROM FTL_SEARCH('World', 1, 0);
C:\download\Data Concurrency and Consistency.pdf
Console says English but is German
...
...
@@ -461,6 +476,7 @@ Roadmap:
new
TestExclusive
().
runTest
(
this
);
new
TestFullText
().
runTest
(
this
);
new
TestFunctions
().
runTest
(
this
);
new
TestFunctionOverload
().
runTest
(
this
);
new
TestIndex
().
runTest
(
this
);
new
TestLinkedTable
().
runTest
(
this
);
new
TestListener
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
6ae22bc7
...
...
@@ -69,7 +69,8 @@ public abstract class TestBase {
test
();
println
(
""
);
}
catch
(
Exception
e
)
{
fail
(
"FAIL "
+
e
.
toString
(),
e
);
println
(
"FAIL "
+
e
.
toString
());
logError
(
"FAIL "
+
e
.
toString
(),
e
);
if
(
config
.
stopOnError
)
{
throw
new
Error
(
"ERROR"
);
}
...
...
@@ -226,20 +227,15 @@ public abstract class TestBase {
return
mb
;
}
protected
void
error
()
throws
Exception
{
error
(
"Unexpected success"
);
protected
void
fail
()
throws
Exception
{
fail
(
"Unexpected success"
);
}
protected
void
error
(
String
string
)
throws
Exception
{
protected
void
fail
(
String
string
)
throws
Exception
{
println
(
string
);
throw
new
Exception
(
string
);
}
protected
void
fail
(
String
s
,
Throwable
e
)
{
println
(
s
);
logError
(
s
,
e
);
}
public
static
void
logError
(
String
s
,
Throwable
e
)
{
if
(
e
==
null
)
{
e
=
new
Exception
(
s
);
...
...
@@ -287,9 +283,15 @@ public abstract class TestBase {
public
abstract
void
test
()
throws
Exception
;
public
void
assertEquals
(
String
message
,
int
expected
,
int
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
fail
(
"Expected: "
+
expected
+
" actual: "
+
actual
+
" message: "
+
message
);
}
}
public
void
assertEquals
(
int
expected
,
int
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
error
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
fail
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
}
}
...
...
@@ -297,7 +299,7 @@ public abstract class TestBase {
assertTrue
(
expected
.
length
==
actual
.
length
);
for
(
int
i
=
0
;
i
<
expected
.
length
;
i
++)
{
if
(
expected
[
i
]
!=
actual
[
i
])
{
error
(
"e
xpected["
+
i
+
"]: a="
+
(
int
)
expected
[
i
]
+
" actual="
+
(
int
)
actual
[
i
]);
fail
(
"E
xpected["
+
i
+
"]: a="
+
(
int
)
expected
[
i
]
+
" actual="
+
(
int
)
actual
[
i
]);
}
}
}
...
...
@@ -306,7 +308,7 @@ public abstract class TestBase {
if
(
expected
==
null
&&
actual
==
null
)
{
return
;
}
else
if
(
expected
==
null
||
actual
==
null
)
{
error
(
"Expected: "
+
expected
+
" Actual: "
+
actual
);
fail
(
"Expected: "
+
expected
+
" Actual: "
+
actual
);
}
if
(!
expected
.
equals
(
actual
))
{
for
(
int
i
=
0
;
i
<
expected
.
length
();
i
++)
{
...
...
@@ -324,49 +326,49 @@ public abstract class TestBase {
if
(
bl
>
100
)
{
actual
=
actual
.
substring
(
0
,
100
);
}
error
(
"Expected: "
+
expected
+
" ("
+
al
+
") actual: "
+
actual
+
" ("
+
bl
+
")"
);
fail
(
"Expected: "
+
expected
+
" ("
+
al
+
") actual: "
+
actual
+
" ("
+
bl
+
")"
);
}
}
protected
void
assertSmaller
(
long
a
,
long
b
)
throws
Exception
{
if
(
a
>=
b
)
{
error
(
"a: "
+
a
+
" is not smaller than b: "
+
b
);
fail
(
"a: "
+
a
+
" is not smaller than b: "
+
b
);
}
}
protected
void
assertContains
(
String
result
,
String
contains
)
throws
Exception
{
if
(
result
.
indexOf
(
contains
)
<
0
)
{
error
(
result
+
" does not contain: "
+
contains
);
fail
(
result
+
" does not contain: "
+
contains
);
}
}
protected
void
assertStartsWith
(
String
text
,
String
expectedStart
)
throws
Exception
{
if
(!
text
.
startsWith
(
expectedStart
))
{
error
(
text
+
" does not start with: "
+
expectedStart
);
fail
(
text
+
" does not start with: "
+
expectedStart
);
}
}
protected
void
assertEquals
(
long
expected
,
long
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
error
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
fail
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
}
}
protected
void
assertEquals
(
double
expected
,
double
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
error
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
fail
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
}
}
protected
void
assertEquals
(
float
expected
,
float
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
error
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
fail
(
"Expected: "
+
expected
+
" actual: "
+
actual
);
}
}
protected
void
assertEquals
(
boolean
expected
,
boolean
actual
)
throws
Exception
{
if
(
expected
!=
actual
)
{
error
(
"Boolean expected: "
+
expected
+
" actual: "
+
actual
);
fail
(
"Boolean expected: "
+
expected
+
" actual: "
+
actual
);
}
}
...
...
@@ -376,7 +378,7 @@ public abstract class TestBase {
protected
void
assertTrue
(
String
message
,
boolean
condition
)
throws
Exception
{
if
(!
condition
)
{
error
(
message
);
fail
(
message
);
}
}
...
...
@@ -386,7 +388,7 @@ public abstract class TestBase {
protected
void
assertFalse
(
String
message
,
boolean
value
)
throws
Exception
{
if
(
value
)
{
error
(
message
);
fail
(
message
);
}
}
...
...
@@ -410,19 +412,19 @@ public abstract class TestBase {
ResultSetMetaData
meta
=
rs
.
getMetaData
();
int
cc
=
meta
.
getColumnCount
();
if
(
cc
!=
columnCount
)
{
error
(
"result set contains "
+
cc
+
" columns not "
+
columnCount
);
fail
(
"result set contains "
+
cc
+
" columns not "
+
columnCount
);
}
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
if
(
labels
!=
null
)
{
String
l
=
meta
.
getColumnLabel
(
i
+
1
);
if
(!
labels
[
i
].
equals
(
l
))
{
error
(
"column label "
+
i
+
" is "
+
l
+
" not "
+
labels
[
i
]);
fail
(
"column label "
+
i
+
" is "
+
l
+
" not "
+
labels
[
i
]);
}
}
if
(
datatypes
!=
null
)
{
int
t
=
meta
.
getColumnType
(
i
+
1
);
if
(
datatypes
[
i
]
!=
t
)
{
error
(
"column datatype "
+
i
+
" is "
+
t
+
" not "
+
datatypes
[
i
]
+
" (prec="
fail
(
"column datatype "
+
i
+
" is "
+
t
+
" not "
+
datatypes
[
i
]
+
" (prec="
+
meta
.
getPrecision
(
i
+
1
)
+
" scale="
+
meta
.
getScale
(
i
+
1
)
+
")"
);
}
String
typeName
=
meta
.
getColumnTypeName
(
i
+
1
);
...
...
@@ -454,13 +456,13 @@ public abstract class TestBase {
if
(
precision
!=
null
)
{
int
p
=
meta
.
getPrecision
(
i
+
1
);
if
(
precision
[
i
]
!=
p
)
{
error
(
"column precision "
+
i
+
" is "
+
p
+
" not "
+
precision
[
i
]);
fail
(
"column precision "
+
i
+
" is "
+
p
+
" not "
+
precision
[
i
]);
}
}
if
(
scale
!=
null
)
{
int
s
=
meta
.
getScale
(
i
+
1
);
if
(
scale
[
i
]
!=
s
)
{
error
(
"column scale "
+
i
+
" is "
+
s
+
" not "
+
scale
[
i
]);
fail
(
"column scale "
+
i
+
" is "
+
s
+
" not "
+
scale
[
i
]);
}
}
...
...
@@ -481,22 +483,22 @@ public abstract class TestBase {
if
(
rows
==
0
)
{
// special case: no rows
if
(
rs
.
next
())
{
error
(
"testResultSet expected rowCount:"
+
rows
+
" got:0"
);
fail
(
"testResultSet expected rowCount:"
+
rows
+
" got:0"
);
}
}
int
len2
=
data
[
0
].
length
;
if
(
len
<
len2
)
{
error
(
"testResultSet expected columnCount:"
+
len2
+
" got:"
+
len
);
fail
(
"testResultSet expected columnCount:"
+
len2
+
" got:"
+
len
);
}
for
(
int
i
=
0
;
i
<
rows
;
i
++)
{
if
(!
rs
.
next
())
{
error
(
"testResultSet expected rowCount:"
+
rows
+
" got:"
+
i
);
fail
(
"testResultSet expected rowCount:"
+
rows
+
" got:"
+
i
);
}
String
[]
row
=
getData
(
rs
,
len
);
if
(
ordered
)
{
String
[]
good
=
data
[
i
];
if
(!
testRow
(
good
,
row
,
good
.
length
))
{
error
(
"testResultSet row not equal, got:\n"
+
formatRow
(
row
)
+
"\n"
+
formatRow
(
good
));
fail
(
"testResultSet row not equal, got:\n"
+
formatRow
(
row
)
+
"\n"
+
formatRow
(
good
));
}
}
else
{
boolean
found
=
false
;
...
...
@@ -508,13 +510,13 @@ public abstract class TestBase {
}
}
if
(!
found
)
{
error
(
"testResultSet no match for row:"
+
formatRow
(
row
));
fail
(
"testResultSet no match for row:"
+
formatRow
(
row
));
}
}
}
if
(
rs
.
next
())
{
String
[]
row
=
getData
(
rs
,
len
);
error
(
"testResultSet expected rowcount:"
+
rows
+
" got:>="
+
(
rows
+
1
)
+
" data:"
+
formatRow
(
row
));
fail
(
"testResultSet expected rowcount:"
+
rows
+
" got:>="
+
(
rows
+
1
)
+
" data:"
+
formatRow
(
row
));
}
}
...
...
@@ -558,7 +560,7 @@ public abstract class TestBase {
try
{
conn
.
createStatement
().
execute
(
"SET WRITE_DELAY 0"
);
conn
.
createStatement
().
execute
(
"CREATE TABLE TEST_A(ID INT)"
);
error
(
"should be crashed already"
);
fail
(
"should be crashed already"
);
}
catch
(
SQLException
e
)
{
// expected
}
...
...
@@ -622,7 +624,7 @@ public abstract class TestBase {
for
(
int
i
=
0
;
i
<
list1
.
size
();
i
++)
{
String
s
=
(
String
)
list1
.
get
(
i
);
if
(!
list2
.
remove
(
s
))
{
error
(
"not found: "
+
s
);
fail
(
"not found: "
+
s
);
}
}
assertEquals
(
list2
.
size
(),
0
);
...
...
h2/src/test/org/h2/test/db/TestAutoRecompile.java
浏览文件 @
6ae22bc7
...
...
@@ -36,13 +36,13 @@ public class TestAutoRecompile extends TestBase {
stat
.
execute
(
"ALTER TABLE TEST ADD COLUMN Z INT"
);
try
{
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestBigResult.java
浏览文件 @
6ae22bc7
...
...
@@ -79,7 +79,7 @@ public class TestBigResult extends TestBase {
deleteDb
(
"bigResult"
);
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"bigResult"
,
true
);
if
(
files
.
size
()
>
0
)
{
error
(
"file not deleted: "
+
files
.
get
(
0
));
fail
(
"file not deleted: "
+
files
.
get
(
0
));
}
}
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
6ae22bc7
...
...
@@ -215,13 +215,13 @@ public class TestCases extends TestBase {
conn
.
close
();
t
.
join
(
5000
);
if
(
stopped
[
0
]
==
null
)
{
error
(
"query still running"
);
fail
(
"query still running"
);
}
else
{
assertKnownException
(
stopped
[
0
]);
}
time
=
System
.
currentTimeMillis
()
-
time
;
if
(
time
>
5000
)
{
error
(
"closing took "
+
time
);
fail
(
"closing took "
+
time
);
}
deleteDb
(
"cases"
);
}
...
...
@@ -253,7 +253,7 @@ public class TestCases extends TestBase {
stat
.
execute
(
"insert into test values(1);"
);
try
{
stat
.
execute
(
"alter table test add column name varchar not null;"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -280,7 +280,7 @@ public class TestCases extends TestBase {
stat
.
execute
(
"insert into test values(1)"
);
try
{
stat
.
execute
(
"alter table test alter column id date"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -380,7 +380,7 @@ public class TestCases extends TestBase {
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select * from abc"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -568,7 +568,7 @@ public class TestCases extends TestBase {
int
id
=
rs
.
getInt
(
1
);
String
s
=
rs
.
getString
(
"DATA"
);
if
(!
s
.
endsWith
(
")"
))
{
error
(
"id="
+
id
);
fail
(
"id="
+
id
);
}
}
conn
.
close
();
...
...
@@ -587,7 +587,7 @@ public class TestCases extends TestBase {
Statement
stat2
=
conn2
.
createStatement
();
try
{
stat2
.
execute
(
"UPDATE TEST SET ID=2"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
6ae22bc7
...
...
@@ -59,14 +59,14 @@ public class TestCluster extends TestBase {
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9191/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
fail
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
fail
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestEncryptedDb.java
浏览文件 @
6ae22bc7
...
...
@@ -38,7 +38,7 @@ public class TestEncryptedDb extends TestBase {
try
{
conn
=
getConnection
(
"exclusive;CIPHER=AES"
,
"sa"
,
"1234 1234"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestExclusive.java
浏览文件 @
6ae22bc7
...
...
@@ -25,7 +25,7 @@ public class TestExclusive extends TestBase {
try
{
Connection
conn2
=
getConnection
(
"exclusive"
);
conn2
.
close
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestFunctionOverload.java
0 → 100644
浏览文件 @
6ae22bc7
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
/**
* Tests for overloaded user defined functions.
*
* @author Gary Tong
*/
public
class
TestFunctionOverload
extends
TestBase
{
private
static
final
String
ME
=
TestFunctionOverload
.
class
.
getName
();
private
Connection
conn
;
private
DatabaseMetaData
meta
;
public
void
test
()
throws
Exception
{
this
.
deleteDb
(
"functionOverload"
);
conn
=
getConnection
(
"functionOverload"
);
meta
=
conn
.
getMetaData
();
testControl
();
testOverload
();
testOverloadNamedArgs
();
testOverloadWithConnection
();
testOverloadError
();
conn
.
close
();
}
private
void
testOverloadError
()
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"create alias overloadError for \""
+
ME
+
".overloadError\""
);
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
}
private
void
testControl
()
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create alias overload0 for \""
+
ME
+
".overload0\""
);
ResultSet
rs
=
stat
.
executeQuery
(
"select overload0() from dual"
);
assertTrue
(
rs
.
next
());
assertEquals
(
"0 args"
,
0
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
rs
=
meta
.
getProcedures
(
null
,
null
,
"OVERLOAD0"
);
rs
.
next
();
assertFalse
(
rs
.
next
());
}
private
void
testOverload
()
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create alias overload1or2 for \""
+
ME
+
".overload1or2\""
);
ResultSet
rs
=
stat
.
executeQuery
(
"select overload1or2(1) from dual"
);
rs
.
next
();
assertEquals
(
"1 arg"
,
1
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"select overload1or2(1, 2) from dual"
);
rs
.
next
();
assertEquals
(
"2 args"
,
3
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
rs
=
meta
.
getProcedures
(
null
,
null
,
"OVERLOAD1OR2"
);
rs
.
next
();
assertEquals
(
1
,
rs
.
getInt
(
"NUM_INPUT_PARAMS"
));
rs
.
next
();
assertEquals
(
2
,
rs
.
getInt
(
"NUM_INPUT_PARAMS"
));
assertFalse
(
rs
.
next
());
}
private
void
testOverloadNamedArgs
()
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create alias overload1or2Named for \""
+
ME
+
".overload1or2(int)\""
);
ResultSet
rs
=
stat
.
executeQuery
(
"select overload1or2Named(1) from dual"
);
assertTrue
(
"First Row"
,
rs
.
next
());
assertEquals
(
"1 arg"
,
1
,
rs
.
getInt
(
1
));
assertFalse
(
"Second Row"
,
rs
.
next
());
rs
.
close
();
try
{
rs
=
stat
.
executeQuery
(
"select overload1or2Named(1, 2) from dual"
);
rs
.
close
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
stat
.
close
();
}
private
void
testOverloadWithConnection
()
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create alias overload1or2WithConn for \""
+
ME
+
".overload1or2WithConn\""
);
ResultSet
rs
=
stat
.
executeQuery
(
"select overload1or2WithConn(1) from dual"
);
rs
.
next
();
assertEquals
(
"1 arg"
,
1
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
rs
.
close
();
rs
=
stat
.
executeQuery
(
"select overload1or2WithConn(1, 2) from dual"
);
rs
.
next
();
assertEquals
(
"2 args"
,
3
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
rs
.
close
();
stat
.
close
();
}
public
static
int
overload0
()
{
return
0
;
}
public
static
int
overload1or2
(
int
one
)
{
return
one
;
}
public
static
int
overload1or2
(
int
one
,
int
two
)
{
return
one
+
two
;
}
public
static
int
overload1or2WithConn
(
Connection
conn
,
int
one
)
throws
SQLException
{
conn
.
createStatement
().
executeQuery
(
"select 1 from dual"
);
return
one
;
}
public
static
int
overload1or2WithConn
(
int
one
,
int
two
)
{
return
one
+
two
;
}
public
static
int
overloadError
(
int
one
,
int
two
)
{
return
one
+
two
;
}
public
static
int
overloadError
(
double
one
,
double
two
)
{
return
(
int
)
(
one
+
two
);
}
}
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
6ae22bc7
...
...
@@ -184,7 +184,7 @@ public class TestFunctions extends TestBase {
try
{
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('ERROR')"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
"42001"
,
e
.
getSQLState
());
}
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
6ae22bc7
...
...
@@ -135,7 +135,7 @@ public class TestLinkedTable extends TestBase {
stat2
.
executeUpdate
(
"INSERT INTO TEST_LINK_DI VALUES(2, 'World')"
);
try
{
stat2
.
executeUpdate
(
"UPDATE TEST_LINK_U SET ID=ID+1"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -225,7 +225,7 @@ public class TestLinkedTable extends TestBase {
testRow
(
stat
,
"TEST"
);
try
{
stat
.
execute
(
"SELECT * FROM TEST_TEMP"
);
error
(
"temp table must not be persistent"
);
fail
(
"temp table must not be persistent"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
6ae22bc7
...
...
@@ -77,7 +77,7 @@ public class TestLob extends TestBase {
stat
.
execute
(
"CHECKPOINT"
);
ArrayList
list2
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"lob"
,
true
);
if
(
list2
.
size
()
>=
list
.
size
()
+
5
)
{
error
(
"Expected not many more files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
fail
(
"Expected not many more files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
}
stat
.
execute
(
"DELETE FROM TEST"
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
...
...
@@ -86,7 +86,7 @@ public class TestLob extends TestBase {
stat
.
execute
(
"CHECKPOINT"
);
ArrayList
list3
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"lob"
,
true
);
if
(
list3
.
size
()
>=
list
.
size
())
{
error
(
"Expected less files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
fail
(
"Expected less files, got "
+
list2
.
size
()
+
" was "
+
list
.
size
());
}
conn
.
close
();
}
...
...
@@ -170,7 +170,7 @@ public class TestLob extends TestBase {
// in Linux, it seems it is still possible to read in files
// even if they are deleted
if
(
System
.
getProperty
(
"os.name"
).
indexOf
(
"Windows"
)
>
0
)
{
error
(
"Error expected; len="
+
len
);
fail
(
"Error expected; len="
+
len
);
}
}
}
catch
(
SQLException
e
)
{
...
...
@@ -380,12 +380,12 @@ public class TestLob extends TestBase {
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
int
ch
=
r
.
read
();
if
(
ch
!=
(
'0'
+
(
i
%
10
)))
{
error
(
"expected "
+
(
char
)
(
'0'
+
(
i
%
10
))
+
" got: "
+
ch
+
" ("
+
(
char
)
ch
+
")"
);
fail
(
"expected "
+
(
char
)
(
'0'
+
(
i
%
10
))
+
" got: "
+
ch
+
" ("
+
(
char
)
ch
+
")"
);
}
}
int
ch
=
r
.
read
();
if
(
ch
!=
-
1
)
{
error
(
"expected -1 got: "
+
ch
);
fail
(
"expected -1 got: "
+
ch
);
}
conn0
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestMemoryUsage.java
浏览文件 @
6ae22bc7
...
...
@@ -63,7 +63,7 @@ public class TestMemoryUsage extends TestBase {
System
.
gc
();
int
used
=
MemoryUtils
.
getMemoryUsed
();
if
((
used
-
start
)
>
16000
)
{
error
(
"Used: "
+
(
used
-
start
));
fail
(
"Used: "
+
(
used
-
start
));
}
}
conn
.
close
();
...
...
@@ -89,7 +89,7 @@ public class TestMemoryUsage extends TestBase {
System
.
gc
();
int
used
=
MemoryUtils
.
getMemoryUsed
();
if
((
used
-
start
)
>
4000
)
{
error
(
"Used: "
+
(
used
-
start
));
fail
(
"Used: "
+
(
used
-
start
));
}
stat
.
execute
(
"drop table test"
);
conn
.
close
();
...
...
@@ -153,7 +153,7 @@ public class TestMemoryUsage extends TestBase {
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
if
(
rs
.
next
())
{
error
(
"one row expected, got more"
);
fail
(
"one row expected, got more"
);
}
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
...
...
@@ -170,7 +170,7 @@ public class TestMemoryUsage extends TestBase {
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
if
(
rs
.
next
())
{
error
(
"one row expected, got more"
);
fail
(
"one row expected, got more"
);
}
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
6ae22bc7
...
...
@@ -206,7 +206,7 @@ public class TestOptimizations extends TestBase {
stat
.
execute
(
sql
);
time2
=
System
.
currentTimeMillis
()
-
time2
;
if
(
time2
>
time
*
2
)
{
error
(
"not optimized: "
+
time
+
" optimized: "
+
time2
+
" sql:"
+
sql
);
fail
(
"not optimized: "
+
time
+
" optimized: "
+
time2
+
" sql:"
+
sql
);
}
}
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
6ae22bc7
...
...
@@ -165,7 +165,7 @@ public class TestPowerOff extends TestBase {
try
{
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hello')"
);
stat
.
execute
(
"CHECKPOINT"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -199,7 +199,7 @@ public class TestPowerOff extends TestBase {
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hello')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello')"
);
stat
.
execute
(
"CHECKPOINT"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -294,7 +294,7 @@ public class TestPowerOff extends TestBase {
Database
.
setInitialPowerOffCount
(
0
);
Connection
conn
=
getConnection
(
url
);
if
(((
JdbcConnection
)
conn
).
getPowerOffCount
()
!=
0
)
{
error
(
"power off count is not 0"
);
fail
(
"power off count is not 0"
);
}
Statement
stat
=
conn
.
createStatement
();
DatabaseMetaData
meta
=
conn
.
getMetaData
();
...
...
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
6ae22bc7
...
...
@@ -68,7 +68,7 @@ public class TestReadOnly extends TestBase {
stat
.
execute
(
"SELECT * FROM TEST"
);
try
{
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
fail
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -83,7 +83,7 @@ public class TestReadOnly extends TestBase {
stat
.
execute
(
"SELECT * FROM TEST"
);
try
{
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
fail
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
6ae22bc7
...
...
@@ -53,7 +53,7 @@ public class TestRights extends TestBase {
Statement
stat2
=
conn2
.
createStatement
();
try
{
stat2
.
execute
(
"SELECT * FROM TEST"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -82,13 +82,13 @@ public class TestRights extends TestBase {
stat
.
execute
(
"select * from b.test"
);
try
{
stat
.
execute
(
"alter user test1 admin false"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
stat
.
execute
(
"drop user test1"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -171,19 +171,19 @@ public class TestRights extends TestBase {
try
{
conn
=
getConnection
(
"rights"
,
"Test"
,
"abc"
);
error
(
"mixed case user name"
);
fail
(
"mixed case user name"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
"abc"
);
error
(
"wrong password"
);
fail
(
"wrong password"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
null
);
error
(
"wrong password"
);
fail
(
"wrong password"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -249,7 +249,7 @@ public class TestRights extends TestBase {
public
void
executeError
(
String
sql
)
throws
Exception
{
try
{
stat
.
execute
(
sql
);
error
(
"not admin"
);
fail
(
"not admin"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
6ae22bc7
...
...
@@ -67,7 +67,7 @@ public class TestRunscript extends TestBase implements Trigger {
if
(
password
)
{
try
{
stat2
.
execute
(
sql
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestSQLInjection.java
浏览文件 @
6ae22bc7
...
...
@@ -43,13 +43,13 @@ public class TestSQLInjection extends TestBase {
stat
.
execute
(
"CALL 123"
);
try
{
stat
.
execute
(
"CALL 'Hello'"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
stat
.
execute
(
"CALL $$Hello World$$"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -58,7 +58,7 @@ public class TestSQLInjection extends TestBase {
try
{
assertTrue
(
checkPasswordInsecure
(
"123456"
));
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -74,7 +74,7 @@ public class TestSQLInjection extends TestBase {
try
{
assertTrue
(
checkPasswordInsecure
(
"123456"
));
error
(
"Should fail now"
);
fail
(
"Should fail now"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestSpaceReuse.java
浏览文件 @
6ae22bc7
...
...
@@ -38,7 +38,7 @@ public class TestSpaceReuse extends TestBase {
}
}
if
(
now
>
first
)
{
error
(
"first: "
+
first
+
" now: "
+
now
);
fail
(
"first: "
+
first
+
" now: "
+
now
);
}
}
...
...
h2/src/test/org/h2/test/db/TestTempTables.java
浏览文件 @
6ae22bc7
...
...
@@ -61,7 +61,7 @@ public class TestTempTables extends TestBase {
c1
.
commit
();
try
{
rs
=
s1
.
executeQuery
(
"select * from test_temp"
);
error
(
"test_temp should have been dropped automatically"
);
fail
(
"test_temp should have been dropped automatically"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestTransaction.java
浏览文件 @
6ae22bc7
...
...
@@ -66,7 +66,7 @@ public class TestTransaction extends TestBase {
Statement
s2
=
c2
.
createStatement
();
try
{
s2
.
executeUpdate
(
"insert into B values('two', 1)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -193,7 +193,7 @@ public class TestTransaction extends TestBase {
}
}
if
(
result
.
size
()
!=
4
)
{
error
(
"Wrong result, should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME but is "
+
result
);
fail
(
"Wrong result, should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME but is "
+
result
);
}
result
=
new
Vector
();
test
(
stat
,
"INSERT INTO NEST1 VALUES(1,'A')"
);
...
...
@@ -212,14 +212,14 @@ public class TestTransaction extends TestBase {
}
}
if
(
result
.
size
()
!=
4
)
{
error
(
"Wrong result, should be A/1, A/2, B/1, B/2 but is "
+
result
);
fail
(
"Wrong result, should be A/1, A/2, B/1, B/2 but is "
+
result
);
}
result
=
new
Vector
();
rs1
=
s1
.
executeQuery
(
"SELECT * FROM NEST1 ORDER BY ID"
);
rs2
=
s1
.
executeQuery
(
"SELECT * FROM NEST2 ORDER BY ID"
);
try
{
rs1
.
next
();
error
(
"next worked on a closed result set"
);
fail
(
"next worked on a closed result set"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -230,7 +230,7 @@ public class TestTransaction extends TestBase {
result
.
add
(
v1
);
}
if
(
result
.
size
()
!=
2
)
{
error
(
"Wrong result, should be A, B but is "
+
result
);
fail
(
"Wrong result, should be A, B but is "
+
result
);
}
test
(
stat
,
"DROP TABLE NEST1"
);
test
(
stat
,
"DROP TABLE NEST2"
);
...
...
@@ -241,7 +241,7 @@ public class TestTransaction extends TestBase {
rs
.
next
();
String
s
=
rs
.
getString
(
1
);
if
(
s
==
null
?
(
data
!=
null
)
:
(!
s
.
equals
(
data
)))
{
error
(
"s= "
+
s
+
" should be: "
+
data
);
fail
(
"s= "
+
s
+
" should be: "
+
data
);
}
}
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
6ae22bc7
...
...
@@ -126,7 +126,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
.
execute
(
"DROP TRIGGER IF EXISTS INS_BEFORE"
);
try
{
stat
.
execute
(
"DROP TRIGGER INS_BEFORE"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -148,7 +148,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
set
.
remove
(
rs
.
getString
(
1
));
}
if
(
set
.
size
()
>
0
)
{
error
(
"set should be empty: "
+
set
);
fail
(
"set should be empty: "
+
set
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
浏览文件 @
6ae22bc7
...
...
@@ -110,7 +110,7 @@ public class TestBatchUpdates extends TestBase {
stat
=
conn
.
createStatement
();
DatabaseMetaData
meta
=
conn
.
getMetaData
();
if
(!
meta
.
supportsBatchUpdates
())
{
error
(
"does not support BatchUpdates"
);
fail
(
"does not support BatchUpdates"
);
}
stat
.
executeUpdate
(
"CREATE TABLE TEST(KEY_ID INT PRIMARY KEY,"
+
"C_NAME VARCHAR(255),PRICE DECIMAL(20,2),TYPE_ID INT)"
);
...
...
@@ -176,7 +176,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"updateCount length:"
+
updateCountLen
);
if
(
updateCountLen
!=
3
)
{
error
(
"updateCount: "
+
updateCountLen
);
fail
(
"updateCount: "
+
updateCountLen
);
}
else
{
trace
(
"addBatch add the SQL statements to Batch "
);
}
...
...
@@ -213,7 +213,7 @@ public class TestBatchUpdates extends TestBase {
updCountLength
=
updateCount
.
length
;
trace
(
"updateCount Length:"
+
updCountLength
);
if
(
updCountLength
!=
3
)
{
error
(
"addBatch "
+
updCountLength
);
fail
(
"addBatch "
+
updCountLength
);
}
else
{
trace
(
"addBatch add the SQL statements to Batch "
);
}
...
...
@@ -230,7 +230,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"Update Count:"
+
updateCount
[
j
]);
trace
(
"Returned Value : "
+
retValue
[
j
]);
if
(
updateCount
[
j
]
!=
retValue
[
j
])
{
error
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
fail
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
}
}
}
...
...
@@ -252,7 +252,7 @@ public class TestBatchUpdates extends TestBase {
if
(
updCountLength
==
0
)
{
trace
(
"clearBatch Method clears the current Batch "
);
}
else
{
error
(
"clearBatch "
+
updCountLength
);
fail
(
"clearBatch "
+
updCountLength
);
}
}
...
...
@@ -272,7 +272,7 @@ public class TestBatchUpdates extends TestBase {
if
(
updCountLength
==
0
)
{
trace
(
"clearBatch Method clears the current Batch "
);
}
else
{
error
(
"clearBatch"
);
fail
(
"clearBatch"
);
}
}
...
...
@@ -296,7 +296,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"Successfully Updated"
);
trace
(
"updateCount Length:"
+
updCountLength
);
if
(
updCountLength
!=
3
)
{
error
(
"executeBatch"
);
fail
(
"executeBatch"
);
}
else
{
trace
(
"executeBatch executes the Batch of SQL statements"
);
}
...
...
@@ -320,7 +320,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"UpdateCount Value:"
+
updateCount
[
j
]);
trace
(
"RetValue : "
+
retValue
[
j
]);
if
(
updateCount
[
j
]
!=
retValue
[
j
])
{
error
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
fail
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
}
}
}
...
...
@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase {
if
(
updCountLength
==
0
)
{
trace
(
"executeBatch does not execute Empty Batch"
);
}
else
{
error
(
"executeBatch"
);
fail
(
"executeBatch"
);
}
}
...
...
@@ -360,7 +360,7 @@ public class TestBatchUpdates extends TestBase {
if
(
batchExceptionFlag
)
{
trace
(
"select not allowed; correct"
);
}
else
{
error
(
"executeBatch select"
);
fail
(
"executeBatch select"
);
}
}
...
...
@@ -380,7 +380,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"Successfully Updated"
);
trace
(
"updateCount Length:"
+
updCountLength
);
if
(
updCountLength
!=
3
)
{
error
(
"executeBatch"
);
fail
(
"executeBatch"
);
}
else
{
trace
(
"executeBatch executes the Batch of SQL statements"
);
}
...
...
@@ -395,7 +395,7 @@ public class TestBatchUpdates extends TestBase {
for
(
int
j
=
0
;
j
<
updateCount
.
length
;
j
++)
{
trace
(
"Update Count : "
+
updateCount
[
j
]);
if
(
updateCount
[
j
]
!=
retValue
[
j
])
{
error
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
fail
(
"j="
+
j
+
" right:"
+
retValue
[
j
]);
}
}
}
...
...
@@ -409,7 +409,7 @@ public class TestBatchUpdates extends TestBase {
if
(
updCountLength
==
0
)
{
trace
(
"executeBatch Method does not execute the Empty Batch "
);
}
else
{
error
(
"executeBatch 0!="
+
updCountLength
);
fail
(
"executeBatch 0!="
+
updCountLength
);
}
}
...
...
@@ -434,7 +434,7 @@ public class TestBatchUpdates extends TestBase {
if
(
batchExceptionFlag
)
{
trace
(
"executeBatch insert duplicate; correct"
);
}
else
{
error
(
"executeBatch"
);
fail
(
"executeBatch"
);
}
}
...
...
@@ -454,7 +454,7 @@ public class TestBatchUpdates extends TestBase {
if
(
batchExceptionFlag
)
{
trace
(
"executeBatch select"
);
}
else
{
error
(
"executeBatch"
);
fail
(
"executeBatch"
);
}
}
...
...
@@ -511,7 +511,7 @@ public class TestBatchUpdates extends TestBase {
// Make sure that we have the correct error code for
// the failed update.
if
(!(
batchUpdates
[
1
]
==
-
3
&&
count
==
1
))
{
error
(
"insert failed"
);
fail
(
"insert failed"
);
}
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCancel.java
浏览文件 @
6ae22bc7
...
...
@@ -72,7 +72,7 @@ public class TestCancel extends TestBase {
stat
.
execute
(
"set query_timeout 1"
);
try
{
stat
.
execute
(
"select count(*) from system_range(1, 1000000), system_range(1, 1000000)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -110,7 +110,7 @@ public class TestCancel extends TestBase {
assertEquals
(
1000
,
rs
.
getInt
(
1
));
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
@@ -127,7 +127,7 @@ public class TestCancel extends TestBase {
stat
.
execute
(
"SET QUERY_TIMEOUT 10"
);
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
@@ -143,7 +143,7 @@ public class TestCancel extends TestBase {
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
6ae22bc7
...
...
@@ -252,15 +252,15 @@ public class TestMetaData extends TestBase {
"NUM_INPUT_PARAMS"
,
"NUM_OUTPUT_PARAMS"
,
"NUM_RESULT_SETS"
,
"REMARKS"
,
"PROCEDURE_TYPE"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
SMALLINT
},
null
,
null
);
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"EXIT"
,
"
0
"
,
"0"
,
"0"
,
""
,
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"EXIT"
,
"
1
"
,
"0"
,
"0"
,
""
,
""
+
DatabaseMetaData
.
procedureNoResult
},
});
rs
=
meta
.
getProcedureColumns
(
null
,
null
,
null
,
null
);
testResultSetMeta
(
rs
,
1
3
,
testResultSetMeta
(
rs
,
1
5
,
new
String
[]
{
"PROCEDURE_CAT"
,
"PROCEDURE_SCHEM"
,
"PROCEDURE_NAME"
,
"COLUMN_NAME"
,
"COLUMN_TYPE"
,
"DATA_TYPE"
,
"TYPE_NAME"
,
"PRECISION"
,
"LENGTH"
,
"SCALE"
,
"RADIX"
,
"NULLABLE"
,
"REMARKS"
},
"DATA_TYPE"
,
"TYPE_NAME"
,
"PRECISION"
,
"LENGTH"
,
"SCALE"
,
"RADIX"
,
"NULLABLE"
,
"REMARKS"
,
"NUM_INPUT_PARAMS"
,
"POS"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
},
null
,
null
);
testResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"EXIT"
,
"P1"
,
""
+
DatabaseMetaData
.
procedureColumnIn
,
""
+
Types
.
INTEGER
,
"INTEGER"
,
"10"
,
"10"
,
"0"
,
"10"
,
""
+
DatabaseMetaData
.
procedureNoNulls
},
...
...
@@ -583,7 +583,7 @@ public class TestMetaData extends TestBase {
"SQL"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
},
null
,
null
);
if
(
rs
.
next
())
{
error
(
"Database is not empty after dropping all tables"
);
fail
(
"Database is not empty after dropping all tables"
);
}
stat
.
executeUpdate
(
"CREATE TABLE TEST("
+
"ID INT PRIMARY KEY,"
+
"TEXT_V VARCHAR(120),"
+
"DEC_V DECIMAL(12,3),"
+
"DATE_V DATETIME,"
+
"BLOB_V BLOB,"
+
"CLOB_V CLOB"
+
")"
);
...
...
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
浏览文件 @
6ae22bc7
...
...
@@ -224,7 +224,7 @@ public class TestNativeSQL extends TestBase {
stat
.
setEscapeProcessing
(
false
);
try
{
stat
.
execute
(
"CALL {d '2001-01-01'} // this is a test"
);
error
(
"expected error if setEscapeProcessing=false"
);
fail
(
"expected error if setEscapeProcessing=false"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
6ae22bc7
...
...
@@ -108,13 +108,13 @@ public class TestPreparedStatement extends TestBase {
PreparedStatement
prep
=
conn
.
prepareStatement
(
"CREATE TABLE BAD AS SELECT A"
);
try
{
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -219,7 +219,7 @@ public class TestPreparedStatement extends TestBase {
"SELECT * FROM (SELECT ? FROM DUAL)"
);
prep
.
setInt
(
1
,
1
);
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -387,20 +387,20 @@ public class TestPreparedStatement extends TestBase {
assertEquals
(
pm
.
isSigned
(
1
),
true
);
try
{
pm
.
getPrecision
(
0
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
pm
.
getPrecision
(
4
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
prep
.
close
();
try
{
pm
.
getPrecision
(
1
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -509,7 +509,7 @@ public class TestPreparedStatement extends TestBase {
assertFalse
(
rs
.
next
());
try
{
prep
=
conn
.
prepareStatement
(
"select ? from dual union select ? from dual"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -661,7 +661,7 @@ public class TestPreparedStatement extends TestBase {
try
{
// supposed to be closed now
rs
.
next
();
error
(
"getMoreResults didn't close this result set"
);
fail
(
"getMoreResults didn't close this result set"
);
}
catch
(
SQLException
e
)
{
trace
(
"no error - getMoreResults is supposed to close the result set"
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
6ae22bc7
...
...
@@ -296,7 +296,7 @@ public class TestResultSet extends TestBase {
// this should break
try
{
rs
.
setFetchSize
(-
1
);
error
(
"fetch size -1 is not allowed"
);
fail
(
"fetch size -1 is not allowed"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
e
.
toString
());
...
...
@@ -304,7 +304,7 @@ public class TestResultSet extends TestBase {
trace
(
"after try to set to -1, fetch size="
+
rs
.
getFetchSize
());
try
{
rs
.
setFetchSize
(
100
);
error
(
"fetch size 100 is bigger than maxrows - not allowed"
);
fail
(
"fetch size 100 is bigger than maxrows - not allowed"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
e
.
toString
());
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
6ae22bc7
...
...
@@ -58,7 +58,7 @@ public class TestStatement extends TestBase {
int
id1
=
savepoint1
.
getSavepointId
();
try
{
savepoint1
.
getSavepointName
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -70,7 +70,7 @@ public class TestStatement extends TestBase {
conn
.
releaseSavepoint
(
savepoint2a
);
try
{
savepoint2a
.
getSavepointId
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -82,7 +82,7 @@ public class TestStatement extends TestBase {
assertEquals
(
savepointTest
.
getSavepointName
(),
"Joe's"
);
try
{
savepointTest
.
getSavepointId
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -95,7 +95,7 @@ public class TestStatement extends TestBase {
assertFalse
(
rs
.
next
());
try
{
conn
.
rollback
(
savepoint2
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -164,7 +164,7 @@ public class TestStatement extends TestBase {
// this is supposed to throw an exception
try
{
stat
.
setQueryTimeout
(-
1
);
error
(
"setQueryTimeout(-1) didn't throw an exception"
);
fail
(
"setQueryTimeout(-1) didn't throw an exception"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -189,7 +189,7 @@ public class TestStatement extends TestBase {
assertEquals
(
count
,
1
);
try
{
stat
.
executeUpdate
(
"SELECT * FROM TEST"
);
error
(
"executeUpdate allowed SELECT"
);
fail
(
"executeUpdate allowed SELECT"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - SELECT not allowed with executeUpdate"
);
...
...
@@ -216,7 +216,7 @@ public class TestStatement extends TestBase {
trace
(
"executeQuery"
);
try
{
stat
.
executeQuery
(
"CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"
);
error
(
"executeQuery allowed CREATE TABLE"
);
fail
(
"executeQuery allowed CREATE TABLE"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - CREATE not allowed with executeQuery"
);
...
...
@@ -224,21 +224,21 @@ public class TestStatement extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"
);
try
{
stat
.
executeQuery
(
"INSERT INTO TEST VALUES(1,'Hello')"
);
error
(
"executeQuery allowed INSERT"
);
fail
(
"executeQuery allowed INSERT"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - INSERT not allowed with executeQuery"
);
}
try
{
stat
.
executeQuery
(
"UPDATE TEST SET VALUE='LDBC' WHERE ID=2"
);
error
(
"executeQuery allowed UPDATE"
);
fail
(
"executeQuery allowed UPDATE"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - UPDATE not allowed with executeQuery"
);
}
try
{
stat
.
executeQuery
(
"DELETE FROM TEST WHERE ID=3"
);
error
(
"executeQuery allowed DELETE"
);
fail
(
"executeQuery allowed DELETE"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - DELETE not allowed with executeQuery"
);
...
...
@@ -246,7 +246,7 @@ public class TestStatement extends TestBase {
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
try
{
stat
.
executeQuery
(
"DROP TABLE TEST"
);
error
(
"executeQuery allowed DROP"
);
fail
(
"executeQuery allowed DROP"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - DROP not allowed with executeQuery"
);
...
...
@@ -257,7 +257,7 @@ public class TestStatement extends TestBase {
try
{
// supposed to be closed now
rs
.
next
();
error
(
"getMoreResults didn't close this result set"
);
fail
(
"getMoreResults didn't close this result set"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
trace
(
"no error - getMoreResults is supposed to close the result set"
);
...
...
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
浏览文件 @
6ae22bc7
...
...
@@ -59,7 +59,7 @@ public class TestTransactionIsolation extends TestBase {
conn1
.
createStatement
().
executeUpdate
(
"UPDATE TEST SET ID=2"
);
try
{
assertSingleValue
(
conn2
.
createStatement
(),
"SELECT * FROM TEST"
,
1
);
error
(
"Expected lock timeout"
);
fail
(
"Expected lock timeout"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -81,7 +81,7 @@ public class TestTransactionIsolation extends TestBase {
conn2
.
createStatement
().
executeUpdate
(
"UPDATE TEST SET ID=4"
);
try
{
conn1
.
createStatement
().
executeUpdate
(
"DELETE FROM TEST"
);
error
(
"Expected lock timeout"
);
fail
(
"Expected lock timeout"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
6ae22bc7
...
...
@@ -55,7 +55,7 @@ public class TestUpdatableResultSet extends TestBase {
try
{
rs
.
insertRow
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
6ae22bc7
...
...
@@ -85,7 +85,7 @@ public class TestZloty extends TestBase {
try
{
prep
.
setBigDecimal
(
2
,
new
ZlotyBigDecimal
(
"11.0"
));
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -101,7 +101,7 @@ public class TestZloty extends TestBase {
};
prep
.
setBigDecimal
(
2
,
value
);
prep
.
execute
();
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
浏览文件 @
6ae22bc7
...
...
@@ -40,7 +40,7 @@ public class TestMvcc1 extends TestBase {
assertEquals
(
"FALSE"
,
rs
.
getString
(
"VALUE"
));
try
{
stat
.
execute
(
"SET MVCC TRUE"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
.
getErrorCode
());
}
...
...
@@ -105,7 +105,7 @@ public class TestMvcc1 extends TestBase {
s1
.
execute
(
"insert into a(code) values('one')"
);
try
{
s2
.
execute
(
"insert into b values('un B', 1)"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -120,7 +120,7 @@ public class TestMvcc1 extends TestBase {
s1
.
execute
(
"insert into test values(1)"
);
try
{
s2
.
execute
(
"drop table test"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
// lock timeout expected
assertKnownException
(
e
);
...
...
@@ -147,7 +147,7 @@ public class TestMvcc1 extends TestBase {
s2
.
execute
(
"select * from test for update"
);
try
{
s1
.
execute
(
"insert into test values(2, 'x')"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
// lock timeout expected
assertKnownException
(
e
);
...
...
@@ -370,7 +370,7 @@ public class TestMvcc1 extends TestBase {
c1
.
commit
();
try
{
s1
.
execute
(
"update test set id=2 where id=1"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/server/TestNestedLoop.java
浏览文件 @
6ae22bc7
...
...
@@ -32,7 +32,7 @@ public class TestNestedLoop extends TestBase {
stat
.
executeQuery
(
"select id from test"
);
try
{
rs
.
next
();
error
(
"Result set should be closed"
);
fail
(
"Result set should be closed"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -40,7 +40,7 @@ public class TestNestedLoop extends TestBase {
stat
.
close
();
try
{
rs
.
next
();
error
(
"Result set should be closed"
);
fail
(
"Result set should be closed"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
6ae22bc7
...
...
@@ -42,7 +42,7 @@ public class TestPgServer extends TestBase {
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select ***"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
6ae22bc7
...
...
@@ -46,17 +46,17 @@ public class TestKillRestart extends TestBase {
String
s
=
catcher
.
readLine
(
60
*
1000
);
// System.out.println("> " + s);
if
(
s
==
null
)
{
error
(
"No reply from process"
);
fail
(
"No reply from process"
);
}
else
if
(!
s
.
startsWith
(
"#"
))
{
// System.out.println(s);
error
(
"Expected: #..., got: "
+
s
);
fail
(
"Expected: #..., got: "
+
s
);
}
else
if
(
s
.
startsWith
(
"#Running"
))
{
Thread
.
sleep
(
100
);
printTime
(
"killing: "
+
i
);
p
.
destroy
();
break
;
}
else
if
(
s
.
startsWith
(
"#Fail"
))
{
error
(
"Failed: "
+
s
);
fail
(
"Failed: "
+
s
);
}
}
}
...
...
h2/src/test/org/h2/test/synth/TestKillRestartMulti.java
浏览文件 @
6ae22bc7
...
...
@@ -58,10 +58,10 @@ public class TestKillRestartMulti extends TestBase {
String
s
=
catcher
.
readLine
(
5
*
60
*
1000
);
// System.out.println("> " + s);
if
(
s
==
null
)
{
error
(
"No reply from process"
);
fail
(
"No reply from process"
);
}
else
if
(!
s
.
startsWith
(
"#"
))
{
// System.out.println(s);
error
(
"Expected: #..., got: "
+
s
);
fail
(
"Expected: #..., got: "
+
s
);
}
else
if
(
s
.
startsWith
(
"#Running"
))
{
int
sleep
=
10
+
random
.
nextInt
(
100
);
Thread
.
sleep
(
sleep
);
...
...
@@ -79,7 +79,7 @@ public class TestKillRestartMulti extends TestBase {
}
System
.
err
.
println
(
" "
+
a
);
}
error
(
"Failed: "
+
s
);
fail
(
"Failed: "
+
s
);
}
}
String
backup
=
baseDir
+
"/killRestartMulti-"
+
System
.
currentTimeMillis
()
+
".zip"
;
...
...
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
浏览文件 @
6ae22bc7
...
...
@@ -85,7 +85,7 @@ public class TestSimpleIndex extends TestBase {
ed
=
true
;
}
if
(
em
!=
ed
)
{
error
(
"different result: "
);
fail
(
"different result: "
);
}
if
(!
em
)
{
execute
(
"INSERT INTO TEST_M "
+
sql
);
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
6ae22bc7
...
...
@@ -264,7 +264,7 @@ select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGG
drop trigger TEST_TRIGGER;
@reconnect;
create alias parse_long for "java.lang.Long.parseLong";
create alias parse_long for "java.lang.Long.parseLong
(java.lang.String)
";
comment on alias parse_long is 'Parse a long with base';
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base;
...
...
h2/src/test/org/h2/test/unit/TestExit.java
浏览文件 @
6ae22bc7
...
...
@@ -53,14 +53,14 @@ public class TestExit extends TestBase implements DatabaseEventListener {
proc
.
waitFor
();
Thread
.
sleep
(
100
);
if
(!
getClosedFile
().
exists
())
{
error
(
"did not close database"
);
fail
(
"did not close database"
);
}
procDef
=
new
String
[]
{
"java"
,
"-cp"
,
classPath
,
getClass
().
getName
(),
""
+
OPEN_WITHOUT_CLOSE_ON_EXIT
};
proc
=
Runtime
.
getRuntime
().
exec
(
procDef
);
proc
.
waitFor
();
Thread
.
sleep
(
100
);
if
(
getClosedFile
().
exists
())
{
error
(
"closed database"
);
fail
(
"closed database"
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestFile.java
浏览文件 @
6ae22bc7
...
...
@@ -94,7 +94,7 @@ public class TestFile extends TestBase implements DataHandler {
}
if
(
a
!=
b
)
{
if
(
a
==
null
||
b
==
null
)
{
error
(
"only one threw an exception"
);
fail
(
"only one threw an exception"
);
}
}
assertEquals
(
buffMem
,
buffFile
);
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
6ae22bc7
...
...
@@ -182,7 +182,7 @@ public class TestFileSystem extends TestBase {
FileObject
f
=
fs
.
openFileObject
(
s
,
"rw"
);
try
{
f
.
readFully
(
new
byte
[
1
],
0
,
1
);
error
();
fail
();
}
catch
(
EOFException
e
)
{
// expected
}
...
...
h2/src/test/org/h2/test/unit/TestOverflow.java
浏览文件 @
6ae22bc7
...
...
@@ -71,13 +71,13 @@ public class TestOverflow extends TestBase {
void
onSuccess
()
throws
Exception
{
if
(!
successExpected
&&
SysProperties
.
OVERFLOW_EXCEPTIONS
)
{
error
();
fail
();
}
}
void
onError
()
throws
Exception
{
if
(
successExpected
)
{
error
();
fail
();
}
}
...
...
h2/src/test/org/h2/test/unit/TestPattern.java
浏览文件 @
6ae22bc7
...
...
@@ -35,7 +35,7 @@ public class TestPattern extends TestBase {
boolean
resultRegexp
=
value
.
matches
(
regexp
);
boolean
result
=
comp
.
test
(
pattern
,
value
,
'\\'
);
if
(
result
!=
resultRegexp
)
{
error
(
"Error: >"
+
value
+
"< LIKE >"
+
pattern
+
"< result="
+
result
+
" resultReg="
+
resultRegexp
);
fail
(
"Error: >"
+
value
+
"< LIKE >"
+
pattern
+
"< result="
+
result
+
" resultReg="
+
resultRegexp
);
}
}
...
...
@@ -72,7 +72,7 @@ public class TestPattern extends TestBase {
char
c
=
pattern
.
charAt
(
i
);
if
(
escape
==
c
)
{
if
(
i
>=
len
)
{
error
(
"escape can't be last char"
);
fail
(
"escape can't be last char"
);
}
c
=
pattern
.
charAt
(++
i
);
buff
.
append
(
'\\'
);
...
...
h2/src/test/org/h2/test/unit/TestServlet.java
浏览文件 @
6ae22bc7
...
...
@@ -183,7 +183,7 @@ public class TestServlet extends TestBase {
try
{
stat1
.
execute
(
"SELECT * FROM T"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -195,7 +195,7 @@ public class TestServlet extends TestBase {
// listener must be stopped
try
{
conn2
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:8888/"
+
baseDir
+
"/servlet"
,
getUser
(),
getPassword
());
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -203,7 +203,7 @@ public class TestServlet extends TestBase {
// connection must be closed
try
{
stat1
.
execute
(
"SELECT * FROM DUAL"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/unit/TestStringUtils.java
浏览文件 @
6ae22bc7
...
...
@@ -37,13 +37,13 @@ public class TestStringUtils extends TestBase {
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
ByteUtils
.
convertStringToBytes
(
"FaCe"
));
try
{
ByteUtils
.
convertStringToBytes
(
"120"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
try
{
ByteUtils
.
convertStringToBytes
(
"fast"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
6ae22bc7
...
...
@@ -94,7 +94,7 @@ public class TestTools extends TestBase {
assertTrue
(
result
.
indexOf
(
"Shutting down"
)
>=
0
);
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:ssl://localhost:9001/mem:"
,
"sa"
,
"sa"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -121,7 +121,7 @@ public class TestTools extends TestBase {
stop
.
shutdown
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9005/mem:"
,
"sa"
,
"sa"
);
error
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -409,7 +409,7 @@ public class TestTools extends TestBase {
new
String
[]
{
"-ifExists"
,
"-tcpPassword"
,
"abc"
,
"-baseDir"
,
baseDir
,
"-tcpPort"
,
"9192"
}).
start
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test2"
,
"sa"
,
""
);
error
(
"should not be able to create new db"
);
fail
(
"should not be able to create new db"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -417,7 +417,7 @@ public class TestTools extends TestBase {
conn
.
close
();
try
{
Server
.
shutdownTcpServer
(
"tcp://localhost:9192"
,
""
,
true
);
error
(
"shouldn't work and should throw an exception"
);
fail
(
"shouldn't work and should throw an exception"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
@@ -428,7 +428,7 @@ public class TestTools extends TestBase {
deleteDb
(
"test"
);
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test"
,
"sa"
,
""
);
error
(
"server must have been closed"
);
fail
(
"server must have been closed"
);
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
...
...
h2/src/test/org/h2/test/unit/TestValueMemory.java
浏览文件 @
6ae22bc7
...
...
@@ -81,7 +81,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
long
used
=
MemoryUtils
.
getMemoryUsed
()
-
first
;
memory
/=
1024
;
if
(
used
>
memory
*
3
)
{
error
(
"Type: "
+
type
+
" Used memory: "
+
used
+
" calculated: "
+
memory
+
" "
+
array
.
length
+
" size: "
+
size
);
fail
(
"Type: "
+
type
+
" Used memory: "
+
used
+
" calculated: "
+
memory
+
" "
+
array
.
length
+
" size: "
+
size
);
}
}
Value
create
(
int
type
)
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论