Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
03fc1e6f
提交
03fc1e6f
authored
4月 16, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow to run most tests in parallel (not enabled right now)
上级
f6397d84
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
34 个修改的文件
包含
782 行增加
和
759 行删除
+782
-759
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+252
-185
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+35
-25
TestAlter.java
h2/src/test/org/h2/test/db/TestAlter.java
+4
-4
TestAlterSchemaRename.java
h2/src/test/org/h2/test/db/TestAlterSchemaRename.java
+5
-5
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+1
-1
TestDateStorage.java
h2/src/test/org/h2/test/db/TestDateStorage.java
+113
-4
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+0
-3
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+0
-40
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+7
-9
TestViewAlterTable.java
h2/src/test/org/h2/test/db/TestViewAlterTable.java
+3
-3
TestViewDropView.java
h2/src/test/org/h2/test/db/TestViewDropView.java
+3
-3
TestBatchUpdates.java
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
+2
-11
TestLobApi.java
h2/src/test/org/h2/test/jdbc/TestLobApi.java
+5
-5
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+0
-110
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+0
-22
TestMvccMultiThreaded.java
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded.java
+7
-8
TestRowLocks.java
h2/src/test/org/h2/test/rowlock/TestRowLocks.java
+6
-6
TestAutoServer.java
h2/src/test/org/h2/test/server/TestAutoServer.java
+13
-13
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+24
-57
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+10
-16
TestMVRTree.java
h2/src/test/org/h2/test/store/TestMVRTree.java
+5
-8
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+83
-67
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+98
-109
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+0
-2
BnfRandom.java
h2/src/test/org/h2/test/synth/BnfRandom.java
+1
-1
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+8
-8
TestFuzzOptimizations.java
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
+3
-3
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+5
-11
TestAutoReconnect.java
h2/src/test/org/h2/test/unit/TestAutoReconnect.java
+10
-10
TestConnectionInfo.java
h2/src/test/org/h2/test/unit/TestConnectionInfo.java
+6
-6
TestFile.java
h2/src/test/org/h2/test/unit/TestFile.java
+1
-1
TestLocale.java
h2/src/test/org/h2/test/unit/TestLocale.java
+57
-0
TestSampleApps.java
h2/src/test/org/h2/test/unit/TestSampleApps.java
+3
-3
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+12
-0
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
03fc1e6f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
03fc1e6f
...
...
@@ -18,6 +18,8 @@ import java.lang.reflect.InvocationTargetException;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Proxy
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileLock
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
...
...
@@ -32,8 +34,7 @@ import java.util.LinkedList;
import
java.util.SimpleTimeZone
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceSystem
;
import
org.h2.store.FileLock
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.utils.ProxyCodeGenerator
;
import
org.h2.test.utils.ResultVerifier
;
...
...
@@ -52,7 +53,7 @@ public abstract class TestBase {
/**
* The temporary directory.
*/
pr
otected
static
final
String
TEMP_DIR
=
"./data/temp"
;
pr
ivate
static
final
String
TEMP_DIR
=
"./data/temp"
;
/**
* An id used to create unique file names.
...
...
@@ -115,6 +116,7 @@ public abstract class TestBase {
*/
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
baseDir
=
getTestDir
(
""
);
FileUtils
.
createDirectories
(
baseDir
);
System
.
setProperty
(
"java.io.tmpdir"
,
TEMP_DIR
);
this
.
config
=
conf
;
return
this
;
...
...
@@ -154,15 +156,6 @@ public abstract class TestBase {
if
(
e
instanceof
OutOfMemoryError
)
{
throw
(
OutOfMemoryError
)
e
;
}
}
finally
{
try
{
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
FileUtils
.
deleteRecursive
(
"nioMemFS:"
,
false
);
FileUtils
.
deleteRecursive
(
"memLZF:"
,
false
);
FileUtils
.
deleteRecursive
(
"nioMemLZF:"
,
false
);
}
catch
(
RuntimeException
e
)
{
e
.
printStackTrace
();
}
}
}
...
...
@@ -473,18 +466,31 @@ public abstract class TestBase {
System
.
err
.
println
(
"ERROR: "
+
s
+
" "
+
e
.
toString
()
+
" ------------------------------"
);
e
.
printStackTrace
();
try
{
TraceSystem
ts
=
new
TraceSystem
(
null
);
FileLock
lock
=
new
FileLock
(
ts
,
"error.lock"
,
1000
);
lock
.
lock
(
FileLock
.
LOCK_FILE
);
FileWriter
fw
=
new
FileWriter
(
"error.txt"
,
true
);
PrintWriter
pw
=
new
PrintWriter
(
fw
);
e
.
printStackTrace
(
pw
);
pw
.
close
();
fw
.
close
();
lock
.
unlock
();
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
// synchronize on this class, because file locks are only visible to
// other JVMs
synchronized
(
TestBase
.
class
)
{
try
{
// lock
FileChannel
fc
=
FilePath
.
get
(
"error.lock"
).
open
(
"rw"
);
FileLock
lock
;
while
(
true
)
{
lock
=
fc
.
tryLock
();
if
(
lock
!=
null
)
{
break
;
}
Thread
.
sleep
(
10
);
}
// append
FileWriter
fw
=
new
FileWriter
(
"error.txt"
,
true
);
PrintWriter
pw
=
new
PrintWriter
(
fw
);
e
.
printStackTrace
(
pw
);
pw
.
close
();
fw
.
close
();
// unlock
lock
.
release
();
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
}
}
System
.
err
.
flush
();
}
...
...
@@ -509,7 +515,7 @@ public abstract class TestBase {
* @param millis the time in milliseconds
* @param s the message
*/
static
void
printlnWithTime
(
long
millis
,
String
s
)
{
static
synchronized
void
printlnWithTime
(
long
millis
,
String
s
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
s
=
dateFormat
.
format
(
new
java
.
util
.
Date
())
+
" "
+
formatTime
(
millis
)
+
" "
+
s
;
...
...
@@ -1578,4 +1584,8 @@ public abstract class TestBase {
throw
(
E
)
e
;
}
protected
String
getTestName
()
{
return
getClass
().
getSimpleName
();
}
}
h2/src/test/org/h2/test/db/TestAlter.java
浏览文件 @
03fc1e6f
...
...
@@ -33,8 +33,8 @@ public class TestAlter extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"alter"
);
conn
=
getConnection
(
"alter"
);
deleteDb
(
getTestName
()
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
testAlterTableAlterColumnAsSelfColumn
();
testAlterTableDropColumnWithReferences
();
...
...
@@ -49,7 +49,7 @@ public class TestAlter extends TestBase {
testAlterTableAddColumnAfter
();
testAlterTableModifyColumn
();
conn
.
close
();
deleteDb
(
"alter"
);
deleteDb
(
getTestName
()
);
}
private
void
testAlterTableAlterColumnAsSelfColumn
()
throws
SQLException
{
...
...
@@ -121,7 +121,7 @@ public class TestAlter extends TestBase {
stat
.
execute
(
"alter table test alter id rename to id2"
);
// disconnect and reconnect
conn
.
close
();
conn
=
getConnection
(
"alter"
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"insert into test values(1)"
);
assertThrows
(
ErrorCode
.
CHECK_CONSTRAINT_VIOLATED_1
,
stat
).
...
...
h2/src/test/org/h2/test/db/TestAlterSchemaRename.java
浏览文件 @
03fc1e6f
...
...
@@ -32,8 +32,8 @@ public class TestAlterSchemaRename extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"alter"
);
conn
=
getConnection
(
"alter"
);
deleteDb
(
getTestName
()
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
testTryToRenameSystemSchemas
();
testSimpleRename
();
...
...
@@ -41,7 +41,7 @@ public class TestAlterSchemaRename extends TestBase {
testCrossSchemaViews
();
testAlias
();
conn
.
close
();
deleteDb
(
"alter"
);
deleteDb
(
getTestName
()
);
}
private
void
testTryToRenameSystemSchemas
()
throws
SQLException
{
...
...
@@ -93,7 +93,7 @@ public class TestAlterSchemaRename extends TestBase {
assertEquals
(
6
,
rs
.
getInt
(
1
));
if
(!
config
.
memory
)
{
conn
.
close
();
conn
=
getConnection
(
"alter"
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
executeQuery
(
"select * from s2_new.v1"
);
}
...
...
@@ -116,7 +116,7 @@ public class TestAlterSchemaRename extends TestBase {
assertEquals
(
"4321"
,
rs
.
getString
(
1
));
if
(!
config
.
memory
)
{
conn
.
close
();
conn
=
getConnection
(
"alter"
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
executeQuery
(
"CALL S2.REVERSE('1234')"
);
}
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
03fc1e6f
...
...
@@ -21,7 +21,7 @@ import org.h2.tools.Server;
import
org.h2.util.JdbcUtils
;
/**
* Test
for
the cluster feature.
* Test the cluster feature.
*/
public
class
TestCluster
extends
TestBase
{
...
...
h2/src/test/org/h2/test/db/TestDateStorage.java
浏览文件 @
03fc1e6f
...
...
@@ -6,12 +6,17 @@
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.Date
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.GregorianCalendar
;
import
java.util.SimpleTimeZone
;
import
java.util.TimeZone
;
import
org.h2.engine.SysProperties
;
...
...
@@ -37,12 +42,116 @@ public class TestDateStorage extends TestBase {
@Override
public
void
test
()
throws
SQLException
{
deleteDb
(
"date"
);
deleteDb
(
getTestName
());
testDateTimeTimestampWithCalendar
();
testMoveDatabaseToAnotherTimezone
();
testAllTimeZones
();
testCurrentTimeZone
();
}
private
void
testDateTimeTimestampWithCalendar
()
throws
SQLException
{
Connection
conn
=
getConnection
(
getTestName
());
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table ts(x timestamp primary key)"
);
stat
.
execute
(
"create table t(x time primary key)"
);
stat
.
execute
(
"create table d(x date)"
);
Calendar
utcCalendar
=
new
GregorianCalendar
(
new
SimpleTimeZone
(
0
,
"Z"
));
TimeZone
old
=
TimeZone
.
getDefault
();
DateTimeUtils
.
resetCalendar
();
TimeZone
.
setDefault
(
TimeZone
.
getTimeZone
(
"PST"
));
try
{
Timestamp
ts1
=
Timestamp
.
valueOf
(
"2010-03-13 18:15:00"
);
Time
t1
=
new
Time
(
ts1
.
getTime
());
Date
d1
=
new
Date
(
ts1
.
getTime
());
// when converted to UTC, this is 03:15, which doesn't actually
// exist because of summer time change at that day
Timestamp
ts2
=
Timestamp
.
valueOf
(
"2010-03-13 19:15:00"
);
Time
t2
=
new
Time
(
ts2
.
getTime
());
Date
d2
=
new
Date
(
ts2
.
getTime
());
PreparedStatement
prep
;
ResultSet
rs
;
prep
=
conn
.
prepareStatement
(
"insert into ts values(?)"
);
prep
.
setTimestamp
(
1
,
ts1
,
utcCalendar
);
prep
.
execute
();
prep
.
setTimestamp
(
1
,
ts2
,
utcCalendar
);
prep
.
execute
();
prep
=
conn
.
prepareStatement
(
"insert into t values(?)"
);
prep
.
setTime
(
1
,
t1
,
utcCalendar
);
prep
.
execute
();
prep
.
setTime
(
1
,
t2
,
utcCalendar
);
prep
.
execute
();
prep
=
conn
.
prepareStatement
(
"insert into d values(?)"
);
prep
.
setDate
(
1
,
d1
,
utcCalendar
);
prep
.
execute
();
prep
.
setDate
(
1
,
d2
,
utcCalendar
);
prep
.
execute
();
rs
=
stat
.
executeQuery
(
"select * from ts order by x"
);
rs
.
next
();
assertEquals
(
"2010-03-14 02:15:00.0"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13 18:15:00.0"
,
rs
.
getTimestamp
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
1
).
toString
());
assertEquals
(
"2010-03-14 02:15:00.0"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13 18:15:00.0"
,
rs
.
getTimestamp
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13 19:15:00.0"
,
rs
.
getTimestamp
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
1
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13 19:15:00.0"
,
rs
.
getTimestamp
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
"x"
).
toString
());
rs
=
stat
.
executeQuery
(
"select * from t order by x"
);
rs
.
next
();
assertEquals
(
"02:15:00"
,
rs
.
getString
(
1
));
assertEquals
(
"18:15:00"
,
rs
.
getTime
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getTime
(
1
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getString
(
"x"
));
assertEquals
(
"18:15:00"
,
rs
.
getTime
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getTime
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"03:15:00"
,
rs
.
getString
(
1
));
assertEquals
(
"19:15:00"
,
rs
.
getTime
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getTime
(
1
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getString
(
"x"
));
assertEquals
(
"19:15:00"
,
rs
.
getTime
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getTime
(
"x"
).
toString
());
rs
=
stat
.
executeQuery
(
"select * from d order by x"
);
rs
.
next
();
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
1
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
1
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
"x"
).
toString
());
}
finally
{
TimeZone
.
setDefault
(
old
);
DateTimeUtils
.
resetCalendar
();
}
stat
.
execute
(
"drop table ts"
);
stat
.
execute
(
"drop table t"
);
stat
.
execute
(
"drop table d"
);
conn
.
close
();
}
private
void
testMoveDatabaseToAnotherTimezone
()
throws
SQLException
{
if
(
config
.
memory
)
{
return
;
...
...
@@ -50,7 +159,7 @@ public class TestDateStorage extends TestBase {
if
(!
SysProperties
.
STORE_LOCAL_TIME
)
{
return
;
}
String
db
=
"date
;LOG=0;FILE_LOCK=NO"
;
String
db
=
getTestName
()
+
"
;LOG=0;FILE_LOCK=NO"
;
Connection
conn
=
getConnection
(
db
);
Statement
stat
;
stat
=
conn
.
createStatement
();
...
...
@@ -128,7 +237,7 @@ public class TestDateStorage extends TestBase {
}
private
void
testAllTimeZones
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"date"
);
Connection
conn
=
getConnection
(
getTestName
()
);
TimeZone
defaultTimeZone
=
TimeZone
.
getDefault
();
PreparedStatement
prep
=
conn
.
prepareStatement
(
"CALL CAST(? AS DATE)"
);
try
{
...
...
@@ -146,7 +255,7 @@ public class TestDateStorage extends TestBase {
DateTimeUtils
.
resetCalendar
();
}
conn
.
close
();
deleteDb
(
"date"
);
deleteDb
(
getTestName
()
);
}
private
void
test
(
PreparedStatement
prep
,
int
d
)
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
03fc1e6f
...
...
@@ -94,11 +94,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testToCharFromText
();
testTranslate
();
testGenerateSeries
();
// TODO
// testCachingOfDeterministicFunctionAlias();
deleteDb
(
"functions"
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
private
void
testDataType
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
03fc1e6f
...
...
@@ -22,14 +22,12 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.Savepoint
;
import
java.sql.Statement
;
import
java.util.List
;
import
java.util.Random
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.SysProperties
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
...
...
@@ -81,8 +79,6 @@ public class TestLob extends TestBase {
testConvert
();
testCreateAsSelect
();
testDelete
();
testTempFilesDeleted
(
true
);
testTempFilesDeleted
(
false
);
testLobServerMemory
();
testUpdatingLobRow
();
if
(
config
.
memory
)
{
...
...
@@ -110,7 +106,6 @@ public class TestLob extends TestBase {
testLob
(
true
);
testJavaObject
();
deleteDb
(
"lob"
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
private
void
testRemovedAfterTimeout
()
throws
Exception
{
...
...
@@ -669,41 +664,6 @@ public class TestLob extends TestBase {
conn
.
close
();
}
private
void
testTempFilesDeleted
(
boolean
stream
)
throws
Exception
{
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
FileUtils
.
createDirectories
(
TEMP_DIR
);
List
<
String
>
list
=
FileUtils
.
newDirectoryStream
(
TEMP_DIR
);
assertEquals
(
"Unexpected temp file: "
+
list
,
0
,
list
.
size
());
deleteDb
(
"lob"
);
Connection
conn
=
getConnection
(
"lob"
);
Statement
stat
;
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name text)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(2, ?)"
);
if
(
stream
)
{
String
large
=
new
String
(
new
char
[
1024
*
1024
*
2
]).
replace
((
char
)
0
,
'x'
);
prep
.
setCharacterStream
(
1
,
new
StringReader
(
large
),
-
1
);
large
=
null
;
prep
.
execute
();
}
else
{
stat
.
execute
(
"insert into test values(1, space(100000))"
);
}
/*
list = FileUtils.newDirectoryStream(TEMP_DIR);
assertEquals("Unexpected temp file: " + list, 0, list.size());
*/
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from test"
);
while
(
rs
.
next
())
{
rs
.
getCharacterStream
(
"name"
).
close
();
}
prep
.
close
();
conn
.
close
();
list
=
FileUtils
.
newDirectoryStream
(
TEMP_DIR
);
assertEquals
(
"Unexpected temp file: "
+
list
,
0
,
list
.
size
());
}
private
void
testLobUpdateMany
()
throws
SQLException
{
deleteDb
(
"lob"
);
Connection
conn
=
getConnection
(
"lob"
);
...
...
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
03fc1e6f
...
...
@@ -64,7 +64,7 @@ public class TestMultiThread extends TestBase implements Runnable {
}
private
void
testConcurrentSchemaChange
()
throws
Exception
{
String
db
=
"testConcurrentSchemaChange"
;
String
db
=
getTestName
()
;
deleteDb
(
db
);
final
String
url
=
getURL
(
db
+
";MULTI_THREADED=1"
,
true
);
Connection
conn
=
getConnection
(
url
);
...
...
@@ -98,7 +98,7 @@ public class TestMultiThread extends TestBase implements Runnable {
}
private
void
testConcurrentLobAdd
()
throws
Exception
{
String
db
=
"concurrentLobAdd"
;
String
db
=
getTestName
()
;
deleteDb
(
db
);
final
String
url
=
getURL
(
db
+
";MULTI_THREADED=1"
,
true
);
Connection
conn
=
getConnection
(
url
);
...
...
@@ -137,7 +137,7 @@ public class TestMultiThread extends TestBase implements Runnable {
if
(
config
.
mvcc
)
{
return
;
}
String
db
=
"concurrentView"
;
String
db
=
getTestName
()
;
deleteDb
(
db
);
final
String
url
=
getURL
(
db
+
";MULTI_THREADED=1"
,
true
);
final
Random
r
=
new
Random
();
...
...
@@ -176,8 +176,8 @@ public class TestMultiThread extends TestBase implements Runnable {
}
private
void
testConcurrentAlter
()
throws
Exception
{
deleteDb
(
"concurrentAlter"
);
final
Connection
conn
=
getConnection
(
"concurrentAlter"
);
deleteDb
(
getTestName
()
);
final
Connection
conn
=
getConnection
(
getTestName
()
);
Statement
stat
=
conn
.
createStatement
();
Task
t
=
new
Task
()
{
@Override
...
...
@@ -195,14 +195,13 @@ public class TestMultiThread extends TestBase implements Runnable {
}
t
.
get
();
conn
.
close
();
deleteDb
(
"concurrentAlter"
);
}
private
void
testConcurrentAnalyze
()
throws
Exception
{
if
(
config
.
mvcc
)
{
return
;
}
deleteDb
(
"concurrentAnalyze"
);
deleteDb
(
getTestName
()
);
final
String
url
=
getURL
(
"concurrentAnalyze;MULTI_THREADED=1"
,
true
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
...
...
@@ -227,7 +226,6 @@ public class TestMultiThread extends TestBase implements Runnable {
t
.
get
();
stat
.
execute
(
"drop table test"
);
conn
.
close
();
deleteDb
(
"concurrentAnalyze"
);
}
private
void
testConcurrentInsertUpdateSelect
()
throws
Exception
{
...
...
@@ -255,7 +253,7 @@ public class TestMultiThread extends TestBase implements Runnable {
}
private
Connection
getConnection
()
throws
SQLException
{
return
getConnection
(
"jdbc:h2:mem:
multiThread"
);
return
getConnection
(
"jdbc:h2:mem:
"
+
getTestName
()
);
}
@Override
...
...
h2/src/test/org/h2/test/db/TestViewAlterTable.java
浏览文件 @
03fc1e6f
...
...
@@ -31,8 +31,8 @@ public class TestViewAlterTable extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"alter"
);
conn
=
getConnection
(
"alter"
);
deleteDb
(
getTestName
()
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
testDropColumnWithoutViews
();
...
...
@@ -47,7 +47,7 @@ public class TestViewAlterTable extends TestBase {
testForeignKey
();
conn
.
close
();
deleteDb
(
"alter"
);
deleteDb
(
getTestName
()
);
}
private
void
testDropColumnWithoutViews
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/db/TestViewDropView.java
浏览文件 @
03fc1e6f
...
...
@@ -32,8 +32,8 @@ public class TestViewDropView extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"alter"
);
conn
=
getConnection
(
"alter"
);
deleteDb
(
getTestName
()
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
testDropViewDefaultBehaviour
();
...
...
@@ -45,7 +45,7 @@ public class TestViewDropView extends TestBase {
testCreateOrReplaceForceViewWithNowInvalidDependentViews
();
conn
.
close
();
deleteDb
(
"alter"
);
deleteDb
(
getTestName
()
);
}
private
void
testCreateForceView
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
浏览文件 @
03fc1e6f
...
...
@@ -5,8 +5,6 @@
*/
package
org
.
h2
.
test
.
jdbc
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.sql.BatchUpdateException
;
import
java.sql.CallableStatement
;
import
java.sql.Connection
;
...
...
@@ -156,16 +154,9 @@ public class TestBatchUpdates extends TestBase {
}
try
{
prep
.
executeBatch
();
fail
();
}
catch
(
BatchUpdateException
e
)
{
PrintStream
temp
=
System
.
err
;
try
{
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
PrintStream
p
=
new
PrintStream
(
buff
);
System
.
setErr
(
p
);
e
.
printStackTrace
();
}
finally
{
System
.
setErr
(
temp
);
}
// expected
}
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/jdbc/TestLobApi.java
浏览文件 @
03fc1e6f
...
...
@@ -45,12 +45,12 @@ public class TestLobApi extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"lob"
);
deleteDb
(
getTestName
()
);
testUnsupportedOperations
();
testLobStaysOpenUntilCommitted
();
testInputStreamThrowsException
(
true
);
testInputStreamThrowsException
(
false
);
conn
=
(
JdbcConnection
)
getConnection
(
"lob"
);
conn
=
(
JdbcConnection
)
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, x blob)"
);
testBlob
(
0
);
...
...
@@ -68,7 +68,7 @@ public class TestLobApi extends TestBase {
}
private
void
testUnsupportedOperations
()
throws
Exception
{
Connection
conn
=
getConnection
(
"lob"
);
Connection
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, c clob, b blob)"
);
stat
.
execute
(
"insert into test values(1, 'x', x'00')"
);
...
...
@@ -118,7 +118,7 @@ public class TestLobApi extends TestBase {
* the result set is closed (see ResultSet.close).
*/
private
void
testLobStaysOpenUntilCommitted
()
throws
Exception
{
Connection
conn
=
getConnection
(
"lob"
);
Connection
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id identity, c clob, b blob)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
...
...
@@ -163,7 +163,7 @@ public class TestLobApi extends TestBase {
private
void
testInputStreamThrowsException
(
final
boolean
ioException
)
throws
Exception
{
Connection
conn
=
getConnection
(
"lob"
);
Connection
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id identity, c clob, b blob)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
03fc1e6f
...
...
@@ -13,7 +13,6 @@ import java.math.BigDecimal;
import
java.net.URL
;
import
java.sql.Array
;
import
java.sql.Connection
;
import
java.sql.Date
;
import
java.sql.ParameterMetaData
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
...
...
@@ -21,19 +20,13 @@ import java.sql.ResultSetMetaData;
import
java.sql.RowId
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
java.util.Calendar
;
import
java.util.GregorianCalendar
;
import
java.util.SimpleTimeZone
;
import
java.util.TimeZone
;
import
java.util.UUID
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.Trigger
;
import
org.h2.test.TestBase
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.Task
;
/**
...
...
@@ -59,7 +52,6 @@ public class TestPreparedStatement extends TestBase {
testUnwrap
(
conn
);
testUnsupportedOperations
(
conn
);
testChangeType
(
conn
);
testDateTimeTimestampWithCalendar
(
conn
);
testCallTablePrepared
(
conn
);
testValues
(
conn
);
testToString
(
conn
);
...
...
@@ -169,108 +161,6 @@ public class TestPreparedStatement extends TestBase {
prep
.
executeQuery
();
}
private
void
testDateTimeTimestampWithCalendar
(
Connection
conn
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table ts(x timestamp primary key)"
);
stat
.
execute
(
"create table t(x time primary key)"
);
stat
.
execute
(
"create table d(x date)"
);
Calendar
utcCalendar
=
new
GregorianCalendar
(
new
SimpleTimeZone
(
0
,
"Z"
));
TimeZone
old
=
TimeZone
.
getDefault
();
DateTimeUtils
.
resetCalendar
();
TimeZone
.
setDefault
(
TimeZone
.
getTimeZone
(
"PST"
));
try
{
Timestamp
ts1
=
Timestamp
.
valueOf
(
"2010-03-13 18:15:00"
);
Time
t1
=
new
Time
(
ts1
.
getTime
());
Date
d1
=
new
Date
(
ts1
.
getTime
());
// when converted to UTC, this is 03:15, which doesn't actually
// exist because of summer time change at that day
Timestamp
ts2
=
Timestamp
.
valueOf
(
"2010-03-13 19:15:00"
);
Time
t2
=
new
Time
(
ts2
.
getTime
());
Date
d2
=
new
Date
(
ts2
.
getTime
());
PreparedStatement
prep
;
ResultSet
rs
;
prep
=
conn
.
prepareStatement
(
"insert into ts values(?)"
);
prep
.
setTimestamp
(
1
,
ts1
,
utcCalendar
);
prep
.
execute
();
prep
.
setTimestamp
(
1
,
ts2
,
utcCalendar
);
prep
.
execute
();
prep
=
conn
.
prepareStatement
(
"insert into t values(?)"
);
prep
.
setTime
(
1
,
t1
,
utcCalendar
);
prep
.
execute
();
prep
.
setTime
(
1
,
t2
,
utcCalendar
);
prep
.
execute
();
prep
=
conn
.
prepareStatement
(
"insert into d values(?)"
);
prep
.
setDate
(
1
,
d1
,
utcCalendar
);
prep
.
execute
();
prep
.
setDate
(
1
,
d2
,
utcCalendar
);
prep
.
execute
();
rs
=
stat
.
executeQuery
(
"select * from ts order by x"
);
rs
.
next
();
assertEquals
(
"2010-03-14 02:15:00.0"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13 18:15:00.0"
,
rs
.
getTimestamp
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
1
).
toString
());
assertEquals
(
"2010-03-14 02:15:00.0"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13 18:15:00.0"
,
rs
.
getTimestamp
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13 19:15:00.0"
,
rs
.
getTimestamp
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
1
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13 19:15:00.0"
,
rs
.
getTimestamp
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14 03:15:00.0"
,
rs
.
getTimestamp
(
"x"
).
toString
());
rs
=
stat
.
executeQuery
(
"select * from t order by x"
);
rs
.
next
();
assertEquals
(
"02:15:00"
,
rs
.
getString
(
1
));
assertEquals
(
"18:15:00"
,
rs
.
getTime
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getTime
(
1
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getString
(
"x"
));
assertEquals
(
"18:15:00"
,
rs
.
getTime
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"02:15:00"
,
rs
.
getTime
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"03:15:00"
,
rs
.
getString
(
1
));
assertEquals
(
"19:15:00"
,
rs
.
getTime
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getTime
(
1
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getString
(
"x"
));
assertEquals
(
"19:15:00"
,
rs
.
getTime
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"03:15:00"
,
rs
.
getTime
(
"x"
).
toString
());
rs
=
stat
.
executeQuery
(
"select * from d order by x"
);
rs
.
next
();
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
1
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
"x"
).
toString
());
rs
.
next
();
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
1
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
1
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
1
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getString
(
"x"
));
assertEquals
(
"2010-03-13"
,
rs
.
getDate
(
"x"
,
utcCalendar
).
toString
());
assertEquals
(
"2010-03-14"
,
rs
.
getDate
(
"x"
).
toString
());
}
finally
{
TimeZone
.
setDefault
(
old
);
DateTimeUtils
.
resetCalendar
();
}
stat
.
execute
(
"drop table ts"
);
stat
.
execute
(
"drop table t"
);
stat
.
execute
(
"drop table d"
);
}
private
static
void
testCallTablePrepared
(
Connection
conn
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"call table(x int = (1))"
);
prep
.
executeQuery
();
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
03fc1e6f
...
...
@@ -32,7 +32,6 @@ import java.sql.Timestamp;
import
java.sql.Types
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
org.h2.api.ErrorCode
;
...
...
@@ -70,7 +69,6 @@ public class TestResultSet extends TestBase {
testInsertRowWithUpdatableResultSetDefault
();
testBeforeFirstAfterLast
();
testParseSpecialValues
();
testSpecialLocale
();
testSubstringPrecision
();
testSubstringDataType
();
testColumnLabelColumnName
();
...
...
@@ -347,26 +345,6 @@ public class TestResultSet extends TestBase {
assertTrue
(
expected
.
equals
(
o
));
}
private
void
testSpecialLocale
()
throws
SQLException
{
Locale
old
=
Locale
.
getDefault
();
try
{
// when using Turkish as the default locale, "i".toUpperCase() is
// not "I"
Locale
.
setDefault
(
new
Locale
(
"tr"
));
stat
.
execute
(
"create table test(I1 int, i2 int, b int, c int, d int) "
+
"as select 1, 1, 1, 1, 1"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
rs
.
getString
(
"I1"
);
rs
.
getString
(
"i1"
);
rs
.
getString
(
"I2"
);
rs
.
getString
(
"i2"
);
stat
.
execute
(
"drop table test"
);
}
finally
{
Locale
.
setDefault
(
old
);
}
}
private
void
testSubstringDataType
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select substr(x, 1, 1) from dual"
);
rs
.
next
();
...
...
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded.java
浏览文件 @
03fc1e6f
...
...
@@ -38,8 +38,8 @@ public class TestMvccMultiThreaded extends TestBase {
}
private
void
testMergeWithUniqueKeyViolation
()
throws
Exception
{
deleteDb
(
"mvccMultiThreaded"
);
Connection
conn
=
getConnection
(
"mvccMultiThreaded"
);
deleteDb
(
getTestName
()
);
Connection
conn
=
getConnection
(
getTestName
()
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(x int primary key, y int unique)"
);
stat
.
execute
(
"insert into test values(1, 1)"
);
...
...
@@ -51,12 +51,12 @@ public class TestMvccMultiThreaded extends TestBase {
}
private
void
testConcurrentMerge
()
throws
Exception
{
deleteDb
(
"mvccMultiThreaded"
);
deleteDb
(
getTestName
()
);
int
len
=
3
;
final
Connection
[]
connList
=
new
Connection
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Connection
conn
=
getConnection
(
"mvccMultiThreaded
;MVCC=TRUE;LOCK_TIMEOUT=500"
);
getTestName
()
+
"
;MVCC=TRUE;LOCK_TIMEOUT=500"
);
connList
[
i
]
=
conn
;
}
Connection
conn
=
connList
[
0
];
...
...
@@ -88,16 +88,16 @@ public class TestMvccMultiThreaded extends TestBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
connList
[
i
].
close
();
}
deleteDb
(
"mvccMultiThreaded"
);
deleteDb
(
getTestName
()
);
}
private
void
testConcurrentUpdate
(
String
suffix
)
throws
Exception
{
deleteDb
(
"mvccMultiThreaded"
);
deleteDb
(
getTestName
()
);
int
len
=
2
;
final
Connection
[]
connList
=
new
Connection
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
connList
[
i
]
=
getConnection
(
"mvccMultiThreaded
;MVCC=TRUE"
+
suffix
);
getTestName
()
+
"
;MVCC=TRUE"
+
suffix
);
}
Connection
conn
=
connList
[
0
];
conn
.
createStatement
().
execute
(
...
...
@@ -133,7 +133,6 @@ public class TestMvccMultiThreaded extends TestBase {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
connList
[
i
].
close
();
}
deleteDb
(
"mvccMultiThreaded"
);
}
}
h2/src/test/org/h2/test/rowlock/TestRowLocks.java
浏览文件 @
03fc1e6f
...
...
@@ -39,12 +39,12 @@ public class TestRowLocks extends TestBase {
public
void
test
()
throws
Exception
{
testSetMode
();
testCases
();
deleteDb
(
"rowLocks"
);
deleteDb
(
getTestName
()
);
}
private
void
testSetMode
()
throws
SQLException
{
deleteDb
(
"rowLocks"
);
c1
=
getConnection
(
"rowLocks"
);
deleteDb
(
getTestName
()
);
c1
=
getConnection
(
getTestName
()
);
Statement
stat
=
c1
.
createStatement
();
stat
.
execute
(
"SET LOCK_MODE 2"
);
ResultSet
rs
=
stat
.
executeQuery
(
"call lock_mode()"
);
...
...
@@ -54,8 +54,8 @@ public class TestRowLocks extends TestBase {
}
private
void
testCases
()
throws
Exception
{
deleteDb
(
"rowLocks"
);
c1
=
getConnection
(
"rowLocks
;MVCC=TRUE"
);
deleteDb
(
getTestName
()
);
c1
=
getConnection
(
getTestName
()
+
"
;MVCC=TRUE"
);
s1
=
c1
.
createStatement
();
s1
.
execute
(
"SET LOCK_TIMEOUT 10000"
);
s1
.
execute
(
"CREATE TABLE TEST AS "
+
...
...
@@ -64,7 +64,7 @@ public class TestRowLocks extends TestBase {
c1
.
setAutoCommit
(
false
);
s1
.
execute
(
"UPDATE TEST SET NAME='Hallo' WHERE ID=1"
);
c2
=
getConnection
(
"rowLocks"
);
c2
=
getConnection
(
getTestName
()
);
c2
.
setAutoCommit
(
false
);
s2
=
c2
.
createStatement
();
...
...
h2/src/test/org/h2/test/server/TestAutoServer.java
浏览文件 @
03fc1e6f
...
...
@@ -43,10 +43,10 @@ public class TestAutoServer extends TestBase {
private
void
testUnsupportedCombinations
()
throws
SQLException
{
String
[]
urls
=
{
"jdbc:h2:
test
;file_lock=no;auto_server=true"
,
"jdbc:h2:
test
;file_lock=serialized;auto_server=true"
,
"jdbc:h2:
test
;access_mode_data=r;auto_server=true"
,
"jdbc:h2:mem:
test
;auto_server=true"
"jdbc:h2:
"
+
getTestName
()
+
"
;file_lock=no;auto_server=true"
,
"jdbc:h2:
"
+
getTestName
()
+
"
;file_lock=serialized;auto_server=true"
,
"jdbc:h2:
"
+
getTestName
()
+
"
;access_mode_data=r;auto_server=true"
,
"jdbc:h2:mem:
"
+
getTestName
()
+
"
;auto_server=true"
};
for
(
String
url
:
urls
)
{
assertThrows
(
SQLException
.
class
,
this
).
getConnection
(
url
);
...
...
@@ -63,8 +63,8 @@ public class TestAutoServer extends TestBase {
if
(
config
.
memory
||
config
.
networked
)
{
return
;
}
deleteDb
(
"autoServer"
);
String
url
=
getURL
(
"autoServer
;AUTO_SERVER=TRUE"
,
true
);
deleteDb
(
getTestName
()
);
String
url
=
getURL
(
getTestName
()
+
"
;AUTO_SERVER=TRUE"
,
true
);
if
(
port
)
{
url
+=
";AUTO_SERVER_PORT=11111"
;
}
...
...
@@ -76,7 +76,7 @@ public class TestAutoServer extends TestBase {
for
(;
i
>
0
;
i
--)
{
Thread
.
sleep
(
100
);
SortedProperties
prop
=
SortedProperties
.
loadProperties
(
getBaseDir
()
+
"/
autoServer
.lock.db"
);
getBaseDir
()
+
"/
"
+
getTestName
()
+
"
.lock.db"
);
String
key
=
prop
.
getProperty
(
"id"
);
String
server
=
prop
.
getProperty
(
"server"
);
if
(
server
!=
null
)
{
...
...
@@ -117,10 +117,10 @@ public class TestAutoServer extends TestBase {
if
(
config
.
memory
||
config
.
networked
)
{
return
;
}
deleteDb
(
"autoServerLinkedTable
1"
);
deleteDb
(
"autoServerLinkedTable
2"
);
String
url
=
getURL
(
"autoServerLinkedTable
1;AUTO_SERVER=TRUE"
,
true
);
String
urlLinked
=
getURL
(
"autoServerLinkedTable
2"
,
true
);
deleteDb
(
getTestName
()
+
"
1"
);
deleteDb
(
getTestName
()
+
"
2"
);
String
url
=
getURL
(
getTestName
()
+
"
1;AUTO_SERVER=TRUE"
,
true
);
String
urlLinked
=
getURL
(
getTestName
()
+
"
2"
,
true
);
String
user
=
getUser
(),
password
=
getPassword
();
Connection
connLinked
=
getConnection
(
urlLinked
,
user
,
password
);
...
...
@@ -163,8 +163,8 @@ public class TestAutoServer extends TestBase {
// ignore
}
deleteDb
(
"autoServerLinkedTable
1"
);
deleteDb
(
"autoServerLinkedTable
2"
);
deleteDb
(
getTestName
()
+
"
1"
);
deleteDb
(
getTestName
()
+
"
2"
);
}
/**
...
...
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
03fc1e6f
...
...
@@ -6,11 +6,7 @@
package
org
.
h2
.
test
.
server
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
...
...
@@ -47,7 +43,6 @@ import org.h2.store.fs.FileUtils;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.AssertThrows
;
import
org.h2.tools.Server
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Task
;
...
...
@@ -72,7 +67,6 @@ public class TestWeb extends TestBase {
testServlet
();
testWrongParameters
();
testTools
();
testTransfer
();
testAlreadyRunning
();
testStartWebServerWithConnection
();
testServer
();
...
...
@@ -164,8 +158,8 @@ public class TestWeb extends TestBase {
if
(
config
.
memory
||
config
.
cipher
!=
null
)
{
return
;
}
deleteDb
(
"web"
);
Connection
conn
=
getConnection
(
"web"
);
deleteDb
(
getTestName
()
);
Connection
conn
=
getConnection
(
getTestName
()
);
conn
.
createStatement
().
execute
(
"create table test(id int) as select 1"
);
conn
.
close
();
...
...
@@ -183,14 +177,14 @@ public class TestWeb extends TestBase {
result
=
client
.
get
(
url
,
"tools.jsp"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/backup.zip"
);
result
=
client
.
get
(
url
,
"tools.do?tool=Backup&args=-dir,"
+
getBaseDir
()
+
",-db,
web
,-file,"
+
getBaseDir
()
+
",-db,
"
+
getTestName
()
+
"
,-file,"
+
getBaseDir
()
+
"/backup.zip"
);
deleteDb
(
"web"
);
deleteDb
(
getTestName
()
);
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/backup.zip"
));
result
=
client
.
get
(
url
,
"tools.do?tool=DeleteDbFiles&args=-dir,"
+
getBaseDir
()
+
",-db,
web"
);
String
fn
=
getBaseDir
()
+
"/
web"
;
getBaseDir
()
+
",-db,
"
+
getTestName
()
);
String
fn
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
if
(
config
.
mvStore
)
{
fn
+=
Constants
.
SUFFIX_MV_FILE
;
}
else
{
...
...
@@ -198,53 +192,23 @@ public class TestWeb extends TestBase {
}
assertFalse
(
FileUtils
.
exists
(
fn
));
result
=
client
.
get
(
url
,
"tools.do?tool=Restore&args=-dir,"
+
getBaseDir
()
+
",-db,
web
,-file,"
+
getBaseDir
()
+
getBaseDir
()
+
",-db,
"
+
getTestName
()
+
"
,-file,"
+
getBaseDir
()
+
"/backup.zip"
);
assertTrue
(
FileUtils
.
exists
(
fn
));
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/backup.zip"
);
result
=
client
.
get
(
url
,
"tools.do?tool=Recover&args=-dir,"
+
getBaseDir
()
+
",-db,
web"
);
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/
web
.h2.sql"
));
getBaseDir
()
+
",-db,
"
+
getTestName
()
);
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/
"
+
getTestName
()
+
"
.h2.sql"
));
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
result
=
client
.
get
(
url
,
"tools.do?tool=RunScript&args=-script,"
+
getBaseDir
()
+
"/
web.h2.sql,-url,"
+
getURL
(
"web"
,
true
)
+
getBaseDir
()
+
"/
"
+
getTestName
()
+
".h2.sql,-url,"
+
getURL
(
getTestName
()
,
true
)
+
",-user,"
+
getUser
()
+
",-password,"
+
getPassword
());
FileUtils
.
delete
(
getBaseDir
()
+
"/
web
.h2.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/
"
+
getTestName
()
+
"
.h2.sql"
);
assertTrue
(
FileUtils
.
exists
(
fn
));
deleteDb
(
"web"
);
}
finally
{
server
.
shutdown
();
}
}
private
void
testTransfer
()
throws
Exception
{
Server
server
=
new
Server
();
server
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
server
.
runTool
(
"-web"
,
"-webPort"
,
"8182"
,
"-properties"
,
"null"
);
File
transfer
=
new
File
(
"transfer"
);
transfer
.
mkdirs
();
try
{
FileOutputStream
f
=
new
FileOutputStream
(
"transfer/test.txt"
);
f
.
write
(
"Hello World"
.
getBytes
());
f
.
close
();
WebClient
client
=
new
WebClient
();
String
url
=
"http://localhost:8182"
;
String
result
=
client
.
get
(
url
);
client
.
readSessionId
(
result
);
String
test
=
client
.
get
(
url
,
"transfer/test.txt"
);
assertEquals
(
"Hello World"
,
test
);
new
File
(
"transfer/testUpload.txt"
).
delete
();
client
.
upload
(
url
+
"/transfer/testUpload.txt"
,
"testUpload.txt"
,
new
ByteArrayInputStream
(
"Hallo Welt"
.
getBytes
()));
byte
[]
d
=
IOUtils
.
readBytesAndClose
(
new
FileInputStream
(
"transfer/testUpload.txt"
),
-
1
);
assertEquals
(
"Hallo Welt"
,
new
String
(
d
));
new
File
(
"transfer/testUpload.txt"
).
delete
();
deleteDb
(
getTestName
());
}
finally
{
server
.
shutdown
();
FileUtils
.
deleteRecursive
(
"transfer"
,
true
);
}
}
...
...
@@ -289,7 +253,7 @@ public class TestWeb extends TestBase {
}
private
void
testIfExists
()
throws
Exception
{
Connection
conn
=
getConnection
(
"jdbc:h2:mem:
webExists"
,
Connection
conn
=
getConnection
(
"jdbc:h2:mem:
"
+
getTestName
()
,
getUser
(),
getPassword
());
Server
server
=
new
Server
();
server
.
setOut
(
new
PrintStream
(
new
ByteArrayOutputStream
()));
...
...
@@ -304,12 +268,12 @@ public class TestWeb extends TestBase {
client
.
readSessionId
(
result
);
result
=
client
.
get
(
url
,
"login.jsp"
);
result
=
client
.
get
(
url
,
"test.do?driver=org.h2.Driver"
+
"&url=jdbc:h2:mem:
webExists"
+
"&url=jdbc:h2:mem:
"
+
getTestName
()
+
"&user="
+
getUser
()
+
"&password="
+
getPassword
()
+
"&name=_test_"
);
assertTrue
(
result
.
indexOf
(
"Exception"
)
<
0
);
result
=
client
.
get
(
url
,
"test.do?driver=org.h2.Driver"
+
"&url=jdbc:h2:mem:
web
"
+
"&url=jdbc:h2:mem:
"
+
getTestName
()
+
"Wrong
"
+
"&user="
+
getUser
()
+
"&password="
+
getPassword
()
+
"&name=_test_"
);
assertContains
(
result
,
"Exception"
);
...
...
@@ -340,13 +304,16 @@ public class TestWeb extends TestBase {
result
=
client
.
get
(
url
,
"login.jsp"
);
assertTrue
(
result
.
indexOf
(
"Einstellung"
)
<
0
);
result
=
client
.
get
(
url
,
"test.do?driver=abc"
+
"&url=jdbc:abc:mem:web&user=sa&password=sa&name=_test_"
);
"&url=jdbc:abc:mem: "
+
getTestName
()
+
"&user=sa&password=sa&name=_test_"
);
assertContains
(
result
,
"Exception"
);
result
=
client
.
get
(
url
,
"test.do?driver=org.h2.Driver"
+
"&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"
);
"&url=jdbc:h2:mem:"
+
getTestName
()
+
"&user=sa&password=sa&name=_test_"
);
assertTrue
(
result
.
indexOf
(
"Exception"
)
<
0
);
result
=
client
.
get
(
url
,
"login.do?driver=org.h2.Driver"
+
"&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"
);
"&url=jdbc:h2:mem:"
+
getTestName
()
+
"&user=sa&password=sa&name=_test_"
);
result
=
client
.
get
(
url
,
"header.jsp"
);
result
=
client
.
get
(
url
,
"query.do?sql="
+
"create table test(id int primary key, name varchar);"
+
...
...
@@ -561,7 +528,8 @@ public class TestWeb extends TestBase {
result
=
client
.
get
(
url
,
"logout.do"
);
result
=
client
.
get
(
url
,
"login.do?driver=org.h2.Driver&"
+
"url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"
);
"url=jdbc:h2:mem:"
+
getTestName
()
+
"&user=sa&password=sa&name=_test_"
);
result
=
client
.
get
(
url
,
"logout.do"
);
result
=
client
.
get
(
url
,
"settingRemove.do?name=_test_"
);
...
...
@@ -580,7 +548,7 @@ public class TestWeb extends TestBase {
Server
.
openBrowser
(
"testUrl"
);
assertEquals
(
"testUrl"
,
lastUrl
);
String
oldUrl
=
lastUrl
;
final
Connection
conn
=
getConnection
(
"testWeb"
);
final
Connection
conn
=
getConnection
(
getTestName
()
);
Task
t
=
new
Task
()
{
@Override
public
void
call
()
throws
Exception
{
...
...
@@ -611,7 +579,6 @@ public class TestWeb extends TestBase {
}
else
{
System
.
clearProperty
(
SysProperties
.
H2_BROWSER
);
}
deleteDb
(
"testWeb"
);
}
}
...
...
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
03fc1e6f
...
...
@@ -46,10 +46,7 @@ public class TestConcurrent extends TestMVStore {
@Override
public
void
test
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
testInterruptReopen
();
testConcurrentSaveCompact
();
testConcurrentDataType
();
...
...
@@ -68,7 +65,7 @@ public class TestConcurrent extends TestMVStore {
}
private
void
testInterruptReopen
()
throws
Exception
{
String
fileName
=
"retry:nio:"
+
getBaseDir
()
+
"/
testInterruptReopen.h3"
;
String
fileName
=
"retry:nio:"
+
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
...
...
@@ -99,7 +96,7 @@ public class TestConcurrent extends TestMVStore {
}
private
void
testConcurrentSaveCompact
()
throws
Exception
{
String
fileName
=
"memFS:
testConcurrentSaveCompact"
;
String
fileName
=
"memFS:
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
...
...
@@ -188,7 +185,7 @@ public class TestConcurrent extends TestMVStore {
}
private
void
testConcurrentAutoCommitAndChange
()
throws
InterruptedException
{
String
fileName
=
"memFS:
testConcurrentChangeAndBackgroundCompact"
;
String
fileName
=
"memFS:
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
1000
).
...
...
@@ -268,7 +265,7 @@ public class TestConcurrent extends TestMVStore {
}
private
void
testConcurrentChangeAndCompact
()
throws
InterruptedException
{
String
fileName
=
"memFS:
testConcurrentChangeAndBackgroundCompact"
;
String
fileName
=
"memFS:
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
...
...
@@ -346,11 +343,10 @@ public class TestConcurrent extends TestMVStore {
s
.
commit
();
s
.
close
();
}
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
}
private
void
testConcurrentFree
()
throws
InterruptedException
{
String
fileName
=
"memFS:
testConcurrentFree.h3"
;
String
fileName
=
"memFS:
"
+
getTestName
()
;
for
(
int
test
=
0
;
test
<
10
;
test
++)
{
FileUtils
.
delete
(
fileName
);
final
MVStore
s1
=
new
MVStore
.
Builder
().
...
...
@@ -425,11 +421,11 @@ public class TestConcurrent extends TestMVStore {
assertTrue
(
""
+
chunkCount
,
chunkCount
<
3
);
s
.
close
();
}
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
}
private
void
testConcurrentStoreAndRemoveMap
()
throws
InterruptedException
{
String
fileName
=
"memFS:testConcurrentStoreAndRemoveMap.h3"
;
String
fileName
=
"memFS:"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
openStore
(
fileName
);
int
count
=
200
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
...
...
@@ -458,11 +454,10 @@ public class TestConcurrent extends TestMVStore {
}
task
.
get
();
s
.
close
();
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
}
private
void
testConcurrentStoreAndClose
()
throws
InterruptedException
{
String
fileName
=
"memFS:
testConcurrentStoreAndClose"
;
String
fileName
=
"memFS:
"
+
getTestName
()
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
FileUtils
.
delete
(
fileName
);
final
MVStore
s
=
openStore
(
fileName
);
...
...
@@ -500,7 +495,6 @@ public class TestConcurrent extends TestMVStore {
}
s
.
close
();
}
FileUtils
.
deleteRecursive
(
"memFS:"
,
false
);
}
/**
...
...
@@ -557,8 +551,8 @@ public class TestConcurrent extends TestMVStore {
}
private
void
testConcurrentOnlineBackup
()
throws
Exception
{
String
fileName
=
getBaseDir
()
+
"/
onlineBackup.h3"
;
String
fileNameRestore
=
getBaseDir
()
+
"/
onlineRestore.h3
"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
String
fileNameRestore
=
getBaseDir
()
+
"/
"
+
getTestName
()
+
"2
"
;
final
MVStore
s
=
openStore
(
fileName
);
final
MVMap
<
Integer
,
byte
[]>
map
=
s
.
openMap
(
"test"
);
final
Random
r
=
new
Random
();
...
...
h2/src/test/org/h2/test/store/TestMVRTree.java
浏览文件 @
03fc1e6f
...
...
@@ -44,9 +44,6 @@ public class TestMVRTree extends TestMVStore {
@Override
public
void
test
()
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
testRemoveAll
();
testRandomInsert
();
testSpatialKey
();
...
...
@@ -58,7 +55,7 @@ public class TestMVRTree extends TestMVStore {
}
private
void
testRemoveAll
()
{
String
fileName
=
getBaseDir
()
+
"/
testRemoveAll.h3"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
MVStore
s
;
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
...
...
@@ -77,7 +74,7 @@ public class TestMVRTree extends TestMVStore {
}
private
void
testRandomInsert
()
{
String
fileName
=
getBaseDir
()
+
"/
testMany.h3"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
MVStore
s
;
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
...
...
@@ -143,7 +140,7 @@ public class TestMVRTree extends TestMVStore {
}
private
void
testMany
()
{
String
fileName
=
getBaseDir
()
+
"/
testMany.h3"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
MVStore
s
;
s
=
openStore
(
fileName
);
...
...
@@ -209,7 +206,7 @@ public class TestMVRTree extends TestMVStore {
}
private
void
testSimple
()
{
String
fileName
=
getBaseDir
()
+
"/
testTree.h3"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
MVStore
s
;
s
=
openStore
(
fileName
);
...
...
@@ -387,7 +384,7 @@ public class TestMVRTree extends TestMVStore {
}
private
void
testRandom
(
boolean
quadraticSplit
)
{
String
fileName
=
getBaseDir
()
+
"/
testRandom.h3"
;
String
fileName
=
getBaseDir
()
+
"/
"
+
getTestName
()
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
03fc1e6f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
03fc1e6f
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
03fc1e6f
...
...
@@ -41,8 +41,6 @@ public class TestStreamStore extends TestBase {
@Override
public
void
test
()
throws
IOException
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
testIOException
();
testSaveCount
();
testExceptionDuringStore
();
...
...
h2/src/test/org/h2/test/synth/BnfRandom.java
浏览文件 @
03fc1e6f
...
...
@@ -27,7 +27,7 @@ public class BnfRandom implements BnfVisitor {
private
int
level
;
private
String
sql
;
BnfRandom
()
throws
Exception
{
public
BnfRandom
()
throws
Exception
{
Bnf
config
=
Bnf
.
getInstance
(
null
);
config
.
linkStatements
();
...
...
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
03fc1e6f
...
...
@@ -43,8 +43,8 @@ public class TestBtreeIndex extends TestBase {
}
private
void
testAddDelete
()
throws
SQLException
{
deleteDb
(
"index"
);
Connection
conn
=
getConnection
(
"index"
);
deleteDb
(
getTestName
()
);
Connection
conn
=
getConnection
(
getTestName
()
);
try
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID bigint primary key)"
);
...
...
@@ -54,7 +54,7 @@ public class TestBtreeIndex extends TestBase {
count
+
")"
);
if
(!
config
.
memory
)
{
conn
.
close
();
conn
=
getConnection
(
"index"
);
conn
=
getConnection
(
getTestName
()
);
stat
=
conn
.
createStatement
();
}
for
(
int
i
=
1
;
i
<
count
;
i
++)
{
...
...
@@ -68,7 +68,7 @@ public class TestBtreeIndex extends TestBase {
}
finally
{
conn
.
close
();
}
deleteDb
(
"index"
);
deleteDb
(
getTestName
()
);
}
@Override
...
...
@@ -78,7 +78,7 @@ public class TestBtreeIndex extends TestBase {
private
void
testOne
(
int
seed
)
throws
SQLException
{
org
.
h2
.
Driver
.
load
();
deleteDb
(
"index"
);
deleteDb
(
getTestName
()
);
printTime
(
"testIndex "
+
seed
);
Random
random
=
new
Random
(
seed
);
int
distinct
,
prefixLength
;
...
...
@@ -101,8 +101,8 @@ public class TestBtreeIndex extends TestBase {
}
}
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/
index"
,
null
,
true
);
Connection
conn
=
getConnection
(
"index"
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/
"
+
getTestName
()
,
null
,
true
);
Connection
conn
=
getConnection
(
getTestName
()
);
try
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE a(text VARCHAR PRIMARY KEY)"
);
...
...
@@ -192,7 +192,7 @@ public class TestBtreeIndex extends TestBase {
}
finally
{
conn
.
close
();
}
deleteDb
(
"index"
);
deleteDb
(
getTestName
()
);
}
private
void
printError
(
int
seed
,
String
message
)
{
...
...
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
浏览文件 @
03fc1e6f
...
...
@@ -38,15 +38,15 @@ public class TestFuzzOptimizations extends TestBase {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"optimizations"
);
conn
=
getConnection
(
"optimizations"
);
deleteDb
(
getTestName
()
);
conn
=
getConnection
(
getTestName
()
);
if
(!
config
.
diskResult
)
{
testIn
();
}
testGroupSorted
();
testInSelect
();
conn
.
close
();
deleteDb
(
"optimizations"
);
deleteDb
(
getTestName
()
);
}
/*
...
...
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
03fc1e6f
...
...
@@ -13,7 +13,6 @@ import org.h2.engine.SysProperties;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.MathUtils
;
/**
...
...
@@ -44,8 +43,8 @@ public class TestRandomSQL extends TestBase {
}
}
pr
ivate
String
getDatabaseName
()
{
return
"dataRandomSQL/randomSql
"
+
seed
;
pr
otected
String
getDatabaseName
()
{
return
getTestName
()
+
"/db
"
+
seed
;
}
private
Connection
connect
()
throws
SQLException
{
...
...
@@ -53,13 +52,7 @@ public class TestRandomSQL extends TestBase {
}
private
void
deleteDb
()
{
String
name
=
getDatabaseName
();
if
(
name
.
startsWith
(
"memFS:"
))
{
DeleteDbFiles
.
execute
(
"memFS:/"
,
name
,
true
);
}
else
{
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/dataRandomSQL"
,
null
,
true
);
FileUtils
.
delete
(
getBaseDir
()
+
"/dataRandomSQL"
);
}
FileUtils
.
delete
(
getDatabaseName
());
}
@Override
...
...
@@ -111,7 +104,8 @@ public class TestRandomSQL extends TestBase {
public
void
testCase
(
int
i
)
throws
Exception
{
String
old
=
SysProperties
.
getScriptDirectory
();
try
{
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
"dataScript/"
);
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
getBaseDir
()
+
"/"
+
getTestName
());
seed
=
i
;
printTime
(
"seed: "
+
seed
);
deleteDb
();
...
...
h2/src/test/org/h2/test/unit/TestAutoReconnect.java
浏览文件 @
03fc1e6f
...
...
@@ -56,28 +56,28 @@ public class TestAutoReconnect extends TestBase {
testReconnect
();
autoServer
=
false
;
testReconnect
();
deleteDb
(
"autoReconnect"
);
deleteDb
(
getTestName
()
);
}
private
void
testWrongUrl
()
throws
Exception
{
deleteDb
(
"autoReconnect"
);
deleteDb
(
getTestName
()
);
Server
tcp
=
Server
.
createTcpServer
().
start
();
try
{
conn
=
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/
autoReconnect
;AUTO_SERVER=TRUE"
);
"/
"
+
getTestName
()
+
"
;AUTO_SERVER=TRUE"
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
this
).
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/
autoReconnect
;OPEN_NEW=TRUE"
);
"/
"
+
getTestName
()
+
"
;OPEN_NEW=TRUE"
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
this
).
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/
autoReconnect
;OPEN_NEW=TRUE"
);
"/
"
+
getTestName
()
+
"
;OPEN_NEW=TRUE"
);
conn
.
close
();
conn
=
getConnection
(
"jdbc:h2:tcp://localhost/"
+
getBaseDir
()
+
"/
autoReconnect"
);
"/
"
+
getTestName
()
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
this
).
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/
autoReconnect
;AUTO_SERVER=TRUE;OPEN_NEW=TRUE"
);
"/
"
+
getTestName
()
+
"
;AUTO_SERVER=TRUE;OPEN_NEW=TRUE"
);
conn
.
close
();
}
finally
{
tcp
.
stop
();
...
...
@@ -85,15 +85,15 @@ public class TestAutoReconnect extends TestBase {
}
private
void
testReconnect
()
throws
Exception
{
deleteDb
(
"autoReconnect"
);
deleteDb
(
getTestName
()
);
if
(
autoServer
)
{
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/
autoReconnect
;"
+
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/
"
+
getTestName
()
+
"
;"
+
"FILE_LOCK=SOCKET;"
+
"AUTO_SERVER=TRUE;OPEN_NEW=TRUE"
;
restart
();
}
else
{
server
=
Server
.
createTcpServer
(
"-tcpPort"
,
"8181"
).
start
();
url
=
"jdbc:h2:tcp://localhost:8181/"
+
getBaseDir
()
+
"/
autoReconnect
;"
+
url
=
"jdbc:h2:tcp://localhost:8181/"
+
getBaseDir
()
+
"/
"
+
getTestName
()
+
"
;"
+
"FILE_LOCK=SOCKET;AUTO_RECONNECT=TRUE"
;
}
...
...
h2/src/test/org/h2/test/unit/TestConnectionInfo.java
浏览文件 @
03fc1e6f
...
...
@@ -44,12 +44,12 @@ public class TestConnectionInfo extends TestBase {
return
;
}
assertThrows
(
ErrorCode
.
URL_RELATIVE_TO_CWD
,
this
).
getConnection
(
"jdbc:h2:
test"
);
getConnection
(
"jdbc:h2:
"
+
getTestName
()
);
assertThrows
(
ErrorCode
.
URL_RELATIVE_TO_CWD
,
this
).
getConnection
(
"jdbc:h2:data/
test"
);
getConnection
(
"jdbc:h2:data/
"
+
getTestName
()
);
getConnection
(
"jdbc:h2:./
testDatabase"
).
close
();
DeleteDbFiles
.
execute
(
"
."
,
"testDatabase"
,
true
);
getConnection
(
"jdbc:h2:./
data/"
+
getTestName
()
).
close
();
DeleteDbFiles
.
execute
(
"
data"
,
getTestName
()
,
true
);
}
private
void
testConnectInitError
()
throws
Exception
{
...
...
@@ -62,14 +62,14 @@ public class TestConnectionInfo extends TestBase {
private
void
testConnectionInfo
()
{
Properties
info
=
new
Properties
();
ConnectionInfo
connectionInfo
=
new
ConnectionInfo
(
"jdbc:h2:mem:
test"
+
"jdbc:h2:mem:
"
+
getTestName
()
+
";LOG=2"
+
";ACCESS_MODE_DATA=rws"
+
";INIT=CREATE this...\\;INSERT that..."
+
";IFEXISTS=TRUE"
,
info
);
assertEquals
(
"jdbc:h2:mem:
test"
,
assertEquals
(
"jdbc:h2:mem:
"
+
getTestName
()
,
connectionInfo
.
getURL
());
assertEquals
(
"2"
,
...
...
h2/src/test/org/h2/test/unit/TestFile.java
浏览文件 @
03fc1e6f
...
...
@@ -17,7 +17,7 @@ import org.h2.util.SmallLRUCache;
import
org.h2.util.TempFileDeleter
;
/**
* Tests the in-memory file s
ystem
.
* Tests the in-memory file s
tore
.
*/
public
class
TestFile
extends
TestBase
implements
DataHandler
{
...
...
h2/src/test/org/h2/test/unit/TestLocale.java
0 → 100644
浏览文件 @
03fc1e6f
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
unit
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Locale
;
import
org.h2.test.TestBase
;
public
class
TestLocale
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
// System.setProperty("h2.storeLocalTime", "true");
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
SQLException
{
testSpecialLocale
();
}
private
void
testSpecialLocale
()
throws
SQLException
{
deleteDb
(
getTestName
());
Connection
conn
=
getConnection
(
getTestName
());
Statement
stat
=
conn
.
createStatement
();
Locale
old
=
Locale
.
getDefault
();
try
{
// when using Turkish as the default locale, "i".toUpperCase() is
// not "I"
Locale
.
setDefault
(
new
Locale
(
"tr"
));
stat
.
execute
(
"create table test(I1 int, i2 int, b int, c int, d int) "
+
"as select 1, 1, 1, 1, 1"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test"
);
rs
.
next
();
rs
.
getString
(
"I1"
);
rs
.
getString
(
"i1"
);
rs
.
getString
(
"I2"
);
rs
.
getString
(
"i2"
);
stat
.
execute
(
"drop table test"
);
}
finally
{
Locale
.
setDefault
(
old
);
}
conn
.
close
();
}
}
h2/src/test/org/h2/test/unit/TestSampleApps.java
浏览文件 @
03fc1e6f
...
...
@@ -38,18 +38,18 @@ public class TestSampleApps extends TestBase {
if
(!
getBaseDir
().
startsWith
(
TestBase
.
BASE_TEST_DIR
))
{
return
;
}
deleteDb
(
"optimizations"
);
deleteDb
(
getTestName
()
);
InputStream
in
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"org/h2/samples/optimizations.sql"
);
new
File
(
getBaseDir
()).
mkdirs
();
FileOutputStream
out
=
new
FileOutputStream
(
getBaseDir
()
+
"/optimizations.sql"
);
IOUtils
.
copyAndClose
(
in
,
out
);
String
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/
optimizations"
;
String
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/
"
+
getTestName
()
;
testApp
(
""
,
org
.
h2
.
tools
.
RunScript
.
class
,
"-url"
,
url
,
"-user"
,
"sa"
,
"-password"
,
"sa"
,
"-script"
,
getBaseDir
()
+
"/optimizations.sql"
,
"-checkResults"
);
deleteDb
(
"optimizations"
);
deleteDb
(
getTestName
()
);
testApp
(
"Compacting...\nDone."
,
org
.
h2
.
samples
.
Compact
.
class
);
testApp
(
"NAME: Bob Meier\n"
+
"EMAIL: bob.meier@abcde.abc\n"
+
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
03fc1e6f
...
...
@@ -517,6 +517,13 @@ public class TestTools extends TestBase {
}
private
void
testServerMain
()
throws
SQLException
{
testNonSSL
();
if
(!
config
.
fast
)
{
testSSL
();
}
}
private
void
testNonSSL
()
throws
SQLException
{
String
result
;
Connection
conn
;
...
...
@@ -538,6 +545,11 @@ public class TestTools extends TestBase {
result
=
runServer
(
0
,
new
String
[]{
"-tcpShutdown"
,
"tcp://localhost:9001"
,
"-tcpPassword"
,
"abc"
,
"-tcpShutdownForce"
});
assertTrue
(
result
.
contains
(
"Shutting down"
));
}
private
void
testSSL
()
throws
SQLException
{
String
result
;
Connection
conn
;
result
=
runServer
(
0
,
new
String
[]{
"-tcp"
,
"-tcpAllowOthers"
,
"-tcpPort"
,
"9001"
,
"-tcpPassword"
,
"abcdef"
,
"-tcpSSL"
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论