Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7c19e7bc
提交
7c19e7bc
authored
11月 04, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
ad13cf0d
显示空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
292 行增加
和
80 行删除
+292
-80
build.xml
h2/build.xml
+1
-1
build.html
h2/src/docsrc/html/build.html
+4
-1
Command.java
h2/src/main/org/h2/command/Command.java
+0
-4
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+0
-5
CreateSequence.java
h2/src/main/org/h2/command/ddl/CreateSequence.java
+0
-4
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+0
-12
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+0
-8
ScanCursor.java
h2/src/main/org/h2/index/ScanCursor.java
+0
-4
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+0
-2
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+0
-4
UpdatableRow.java
h2/src/main/org/h2/result/UpdatableRow.java
+0
-3
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+0
-4
FtpControl.java
h2/src/main/org/h2/server/ftp/FtpControl.java
+4
-7
DataPage.java
h2/src/main/org/h2/store/DataPage.java
+0
-4
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+21
-0
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+3
-0
Profile.java
h2/src/test/org/h2/test/coverage/Profile.java
+1
-1
FtpClient.java
h2/src/test/org/h2/test/unit/FtpClient.java
+231
-0
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+15
-11
TestFtp.java
h2/src/test/org/h2/test/unit/TestFtp.java
+11
-4
没有找到文件。
h2/build.xml
浏览文件 @
7c19e7bc
...
@@ -122,7 +122,7 @@
...
@@ -122,7 +122,7 @@
<fileset
dir=
"src/main"
/>
<fileset
dir=
"src/main"
/>
</copy>
</copy>
<java
classname=
"org.h2.test.coverage.Coverage"
classpath=
"bin"
dir=
"bin"
fork=
"true"
>
<java
classname=
"org.h2.test.coverage.Coverage"
classpath=
"bin"
dir=
"bin"
fork=
"true"
>
<arg
line=
"-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -r org/h2"
/>
<arg
line=
"-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -
e org/h2/store/fs -
r org/h2"
/>
</java>
</java>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"bin"
destdir=
"bin"
debug=
"true"
includes=
"org/h2/**"
/>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"bin"
destdir=
"bin"
debug=
"true"
includes=
"org/h2/**"
/>
</target>
</target>
...
...
h2/src/docsrc/html/build.html
浏览文件 @
7c19e7bc
...
@@ -31,8 +31,11 @@ It can also be compiled to a native executable using GCJ.
...
@@ -31,8 +31,11 @@ It can also be compiled to a native executable using GCJ.
<br
/><a
name=
"environment"
></a>
<br
/><a
name=
"environment"
></a>
<h2>
Environment
</h2>
<h2>
Environment
</h2>
<p>
<p>
A Java Runtime Environment (JRE) version 1.4 or higher is required to run this database.
</p>
<p>
To build the database executables, the following software stack was used.
To build the database executables, the following software stack was used.
In most cases, n
ewer version or compatible software works too.
N
ewer version or compatible software works too.
</p>
</p>
<ul>
<ul>
<li>
Windows XP
<li>
Windows XP
...
...
h2/src/main/org/h2/command/Command.java
浏览文件 @
7c19e7bc
...
@@ -139,8 +139,4 @@ public abstract class Command implements CommandInterface {
...
@@ -139,8 +139,4 @@ public abstract class Command implements CommandInterface {
public
void
cancel
()
{
public
void
cancel
()
{
this
.
cancel
=
true
;
this
.
cancel
=
true
;
}
}
public
String
getSQL
()
{
return
null
;
}
}
}
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
7c19e7bc
...
@@ -8,7 +8,6 @@ import java.io.IOException;
...
@@ -8,7 +8,6 @@ import java.io.IOException;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.SessionInterface
;
import
org.h2.engine.SessionRemote
;
import
org.h2.engine.SessionRemote
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.expression.ParameterRemote
;
import
org.h2.expression.ParameterRemote
;
...
@@ -192,10 +191,6 @@ public class CommandRemote implements CommandInterface {
...
@@ -192,10 +191,6 @@ public class CommandRemote implements CommandInterface {
}
}
}
}
public
SessionInterface
getSession
()
{
return
session
;
}
public
void
close
()
{
public
void
close
()
{
if
(
session
==
null
||
session
.
isClosed
())
{
if
(
session
==
null
||
session
.
isClosed
())
{
return
;
return
;
...
...
h2/src/main/org/h2/command/ddl/CreateSequence.java
浏览文件 @
7c19e7bc
...
@@ -60,10 +60,6 @@ public class CreateSequence extends SchemaCommand {
...
@@ -60,10 +60,6 @@ public class CreateSequence extends SchemaCommand {
this
.
increment
=
increment
;
this
.
increment
=
increment
;
}
}
public
boolean
getBelongsToTable
()
{
return
belongsToTable
;
}
public
void
setBelongsToTable
(
boolean
belongsToTable
)
{
public
void
setBelongsToTable
(
boolean
belongsToTable
)
{
this
.
belongsToTable
=
belongsToTable
;
this
.
belongsToTable
=
belongsToTable
;
}
}
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
7c19e7bc
...
@@ -163,7 +163,7 @@ public abstract class Query extends Prepared {
...
@@ -163,7 +163,7 @@ public abstract class Query extends Prepared {
}
}
}
else
{
}
else
{
String
s
=
e
.
getSQL
();
String
s
=
e
.
getSQL
();
for
(
int
j
=
0
;
j
<
expressionSQL
.
size
();
j
++)
{
for
(
int
j
=
0
;
expressionSQL
!=
null
&&
j
<
expressionSQL
.
size
();
j
++)
{
String
s2
=
(
String
)
expressionSQL
.
get
(
j
);
String
s2
=
(
String
)
expressionSQL
.
get
(
j
);
if
(
s2
.
equals
(
s
))
{
if
(
s2
.
equals
(
s
))
{
idx
=
j
;
idx
=
j
;
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
7c19e7bc
...
@@ -667,18 +667,6 @@ public class Select extends Query {
...
@@ -667,18 +667,6 @@ public class Select extends Query {
return
expressions
;
return
expressions
;
}
}
public
Expression
getCondition
()
{
return
condition
;
}
public
boolean
isDistinct
()
{
return
distinct
;
}
public
ObjectArray
getGroupBy
()
{
return
group
;
}
public
void
setForUpdate
(
boolean
b
)
{
public
void
setForUpdate
(
boolean
b
)
{
this
.
isForUpdate
=
b
;
this
.
isForUpdate
=
b
;
}
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
7c19e7bc
...
@@ -324,14 +324,6 @@ public class SelectUnion extends Query {
...
@@ -324,14 +324,6 @@ public class SelectUnion extends Query {
return
left
.
isReadOnly
()
&&
right
.
isReadOnly
();
return
left
.
isReadOnly
()
&&
right
.
isReadOnly
();
}
}
public
Query
getLeftQuery
()
{
return
left
;
}
public
Query
getRightQuery
()
{
return
right
;
}
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
left
.
updateAggregate
(
session
);
left
.
updateAggregate
(
session
);
right
.
updateAggregate
(
session
);
right
.
updateAggregate
(
session
);
...
...
h2/src/main/org/h2/index/ScanCursor.java
浏览文件 @
7c19e7bc
...
@@ -31,10 +31,6 @@ public class ScanCursor implements Cursor {
...
@@ -31,10 +31,6 @@ public class ScanCursor implements Cursor {
row
=
null
;
row
=
null
;
}
}
Session
getSession
()
{
return
session
;
}
public
Row
get
()
{
public
Row
get
()
{
return
row
;
return
row
;
}
}
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
7c19e7bc
...
@@ -34,8 +34,6 @@ import org.h2.message.Message;
...
@@ -34,8 +34,6 @@ import org.h2.message.Message;
/**
/**
* A data source for H2 database connections
* A data source for H2 database connections
*
* @author Tom
*/
*/
public
class
JdbcDataSource
extends
TraceObject
implements
public
class
JdbcDataSource
extends
TraceObject
implements
//#ifdef JDK14
//#ifdef JDK14
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
7c19e7bc
...
@@ -170,10 +170,6 @@ public class LogSystem {
...
@@ -170,10 +170,6 @@ public class LogSystem {
}
}
}
}
boolean
needMoreUndo
()
{
return
sessions
.
size
()
>
0
;
}
void
addUndoLogRecord
(
LogFile
log
,
int
logRecordId
,
int
sessionId
)
{
void
addUndoLogRecord
(
LogFile
log
,
int
logRecordId
,
int
sessionId
)
{
LogRecord
record
=
new
LogRecord
(
log
,
logRecordId
,
sessionId
);
LogRecord
record
=
new
LogRecord
(
log
,
logRecordId
,
sessionId
);
undo
.
add
(
record
);
undo
.
add
(
record
);
...
...
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
7c19e7bc
...
@@ -77,9 +77,6 @@ public class UpdatableRow {
...
@@ -77,9 +77,6 @@ public class UpdatableRow {
return
isUpdatable
;
return
isUpdatable
;
}
}
void
initKey
()
throws
SQLException
{
}
private
int
getColumnIndex
(
String
columnName
)
throws
SQLException
{
private
int
getColumnIndex
(
String
columnName
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
String
col
=
result
.
getColumnName
(
i
);
String
col
=
result
.
getColumnName
(
i
);
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
7c19e7bc
...
@@ -223,10 +223,6 @@ public class TcpServer implements Service {
...
@@ -223,10 +223,6 @@ public class TcpServer implements Service {
running
.
remove
(
t
);
running
.
remove
(
t
);
}
}
boolean
getLog
()
{
return
log
;
}
String
getBaseDir
()
{
String
getBaseDir
()
{
return
baseDir
;
return
baseDir
;
}
}
...
...
h2/src/main/org/h2/server/ftp/FtpControl.java
浏览文件 @
7c19e7bc
...
@@ -176,7 +176,7 @@ public class FtpControl extends Thread {
...
@@ -176,7 +176,7 @@ public class FtpControl extends Thread {
if
(!
readonly
)
{
if
(!
readonly
)
{
try
{
try
{
fs
.
mkdirs
(
fileName
);
fs
.
mkdirs
(
fileName
);
reply
(
257
,
"\""
+
param
+
"\" directory"
);
// TODO quote (" > "")
reply
(
257
,
StringUtils
.
quoteIdentifier
(
param
)
+
" directory"
);
ok
=
true
;
ok
=
true
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
server
.
logError
(
e
);
server
.
logError
(
e
);
...
@@ -209,14 +209,13 @@ public class FtpControl extends Thread {
...
@@ -209,14 +209,13 @@ public class FtpControl extends Thread {
break
;
break
;
case
'P'
:
case
'P'
:
if
(
"PWD"
.
equals
(
command
))
{
if
(
"PWD"
.
equals
(
command
))
{
reply
(
257
,
"\""
+
currentDir
+
"\" directory"
);
// TODO quote (" > "")
reply
(
257
,
StringUtils
.
quoteIdentifier
(
currentDir
)
+
" directory"
);
}
else
if
(
"PASV"
.
equals
(
command
))
{
}
else
if
(
"PASV"
.
equals
(
command
))
{
ServerSocket
dataSocket
=
server
.
createDataSocket
();
ServerSocket
dataSocket
=
server
.
createDataSocket
();
data
=
new
FtpData
(
server
,
control
.
getInetAddress
(),
dataSocket
);
data
=
new
FtpData
(
server
,
control
.
getInetAddress
(),
dataSocket
);
data
.
start
();
data
.
start
();
int
port
=
dataSocket
.
getLocalPort
();
int
port
=
dataSocket
.
getLocalPort
();
reply
(
227
,
"Passive Mode ("
+
serverIpAddress
+
","
+
(
port
>>
8
)
+
","
+
(
port
&
255
)
+
")"
);
reply
(
227
,
"Passive Mode ("
+
serverIpAddress
+
","
+
(
port
>>
8
)
+
","
+
(
port
&
255
)
+
")"
);
// reply(501, ne.getMessage());
}
}
break
;
break
;
case
'R'
:
case
'R'
:
...
@@ -261,8 +260,7 @@ public class FtpControl extends Thread {
...
@@ -261,8 +260,7 @@ public class FtpControl extends Thread {
}
}
restart
=
0
;
restart
=
0
;
}
else
{
}
else
{
processList
(
param
,
true
);
// Firefox compatibility (still
processList
(
param
,
true
);
// Firefox compatibility (still not good)
// not good)
// reply(426, "Not a file");
// reply(426, "Not a file");
}
}
}
else
if
(
"RMD"
.
equals
(
command
))
{
}
else
if
(
"RMD"
.
equals
(
command
))
{
...
@@ -355,8 +353,7 @@ public class FtpControl extends Thread {
...
@@ -355,8 +353,7 @@ public class FtpControl extends Thread {
String
list
=
server
.
getDirectoryListing
(
directory
,
directories
);
String
list
=
server
.
getDirectoryListing
(
directory
,
directories
);
reply
(
150
,
"Starting transfer"
);
reply
(
150
,
"Starting transfer"
);
server
.
log
(
list
);
server
.
log
(
list
);
// need to use the current locale (UTF-8 would be wrong for the Windows
// need to use the current locale (UTF-8 would be wrong for the Windows Explorer)
// Explorer)
data
.
send
(
list
.
getBytes
());
data
.
send
(
list
.
getBytes
());
reply
(
226
,
"Done"
);
reply
(
226
,
"Done"
);
}
}
...
...
h2/src/main/org/h2/store/DataPage.java
浏览文件 @
7c19e7bc
...
@@ -62,10 +62,6 @@ public abstract class DataPage {
...
@@ -62,10 +62,6 @@ public abstract class DataPage {
}
}
}
}
protected
DataPage
(
DataHandler
handler
,
int
capacity
)
{
this
(
handler
,
new
byte
[
capacity
]);
}
protected
DataPage
(
DataHandler
handler
,
byte
[]
data
)
{
protected
DataPage
(
DataHandler
handler
,
byte
[]
data
)
{
this
.
handler
=
handler
;
this
.
handler
=
handler
;
this
.
data
=
data
;
this
.
data
=
data
;
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
7c19e7bc
...
@@ -79,6 +79,7 @@ import org.h2.test.unit.TestExit;
...
@@ -79,6 +79,7 @@ import org.h2.test.unit.TestExit;
import
org.h2.test.unit.TestFile
;
import
org.h2.test.unit.TestFile
;
import
org.h2.test.unit.TestFileLock
;
import
org.h2.test.unit.TestFileLock
;
import
org.h2.test.unit.TestFileSystem
;
import
org.h2.test.unit.TestFileSystem
;
import
org.h2.test.unit.TestFtp
;
import
org.h2.test.unit.TestIntArray
;
import
org.h2.test.unit.TestIntArray
;
import
org.h2.test.unit.TestIntIntHashMap
;
import
org.h2.test.unit.TestIntIntHashMap
;
import
org.h2.test.unit.TestMultiThreadedKernel
;
import
org.h2.test.unit.TestMultiThreadedKernel
;
...
@@ -134,6 +135,7 @@ java org.h2.test.TestAll timer
...
@@ -134,6 +135,7 @@ java org.h2.test.TestAll timer
public
boolean
jdk14
=
true
;
public
boolean
jdk14
=
true
;
private
Server
server
;
private
Server
server
;
public
boolean
cache2Q
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
...
@@ -142,6 +144,10 @@ java org.h2.test.TestAll timer
...
@@ -142,6 +144,10 @@ java org.h2.test.TestAll timer
/*
/*
unit tests for ftp
start writing javadocs for jdbcx package
replicating file system
replicating file system
background thread writing file system (all writes)
background thread writing file system (all writes)
...
@@ -276,6 +282,12 @@ write tests using the PostgreSQL JDBC driver
...
@@ -276,6 +282,12 @@ write tests using the PostgreSQL JDBC driver
// repeatable test with a very big database (making backups of the database files)
// repeatable test with a very big database (making backups of the database files)
/*
Features of H2
- Case insensitive string data type
- GROUP_CONCAT aggregate, User defined aggregates
*/
if
(
args
.
length
>
0
)
{
if
(
args
.
length
>
0
)
{
if
(
"crash"
.
equals
(
args
[
0
]))
{
if
(
"crash"
.
equals
(
args
[
0
]))
{
new
TestCrashAPI
().
runTest
(
test
);
new
TestCrashAPI
().
runTest
(
test
);
...
@@ -381,6 +393,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -381,6 +393,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
logMode
=
1
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
diskUndo
=
false
;
diskUndo
=
false
;
...
@@ -395,6 +408,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -395,6 +408,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
logMode
=
1
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
big
=
false
;
big
=
false
;
...
@@ -411,6 +425,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -411,6 +425,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
throttle
=
0
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
diskUndo
=
true
;
diskUndo
=
true
;
...
@@ -425,6 +440,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -425,6 +440,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
1
;
throttle
=
1
;
cipher
=
"XTEA"
;
cipher
=
"XTEA"
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
diskUndo
=
false
;
diskUndo
=
false
;
...
@@ -442,6 +458,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -442,6 +458,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
throttle
=
0
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
big
=
true
;
big
=
true
;
...
@@ -458,6 +475,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -458,6 +475,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
throttle
=
0
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
true
;
testAll
();
testAll
();
big
=
true
;
big
=
true
;
...
@@ -474,6 +492,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -474,6 +492,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
throttle
=
0
;
cipher
=
"AES"
;
cipher
=
"AES"
;
mvcc
=
false
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
testAll
();
smallLog
=
big
=
networked
=
memory
=
ssl
=
textStorage
=
diskResult
=
deleteIndex
=
traceSystemOut
=
false
;
smallLog
=
big
=
networked
=
memory
=
ssl
=
textStorage
=
diskResult
=
deleteIndex
=
traceSystemOut
=
false
;
...
@@ -481,6 +500,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -481,6 +500,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
logMode
=
1
;
cipher
=
null
;
cipher
=
null
;
mvcc
=
true
;
mvcc
=
true
;
cache2Q
=
false
;
testAll
();
testAll
();
}
}
...
@@ -499,6 +519,7 @@ write tests using the PostgreSQL JDBC driver
...
@@ -499,6 +519,7 @@ write tests using the PostgreSQL JDBC driver
new
TestExit
().
runTest
(
this
);
new
TestExit
().
runTest
(
this
);
new
TestFile
().
runTest
(
this
);
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFtp
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
new
TestIntIntHashMap
().
runTest
(
this
);
new
TestIntIntHashMap
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
7c19e7bc
...
@@ -138,6 +138,9 @@ public abstract class TestBase {
...
@@ -138,6 +138,9 @@ public abstract class TestBase {
if
(
config
.
mvcc
)
{
if
(
config
.
mvcc
)
{
url
+=
";MVCC=TRUE"
;
url
+=
";MVCC=TRUE"
;
}
}
if
(
config
.
cache2Q
)
{
url
+=
";CACHE_TYPE=TQ"
;
}
if
(
config
.
diskResult
&&
admin
)
{
if
(
config
.
diskResult
&&
admin
)
{
url
+=
";MAX_MEMORY_ROWS=100;CACHE_SIZE=0"
;
url
+=
";MAX_MEMORY_ROWS=100;CACHE_SIZE=0"
;
}
}
...
...
h2/src/test/org/h2/test/coverage/Profile.java
浏览文件 @
7c19e7bc
...
@@ -17,7 +17,7 @@ import java.io.Writer;
...
@@ -17,7 +17,7 @@ import java.io.Writer;
* The class used at runtime to measure the code usage and performance.
* The class used at runtime to measure the code usage and performance.
*/
*/
public
class
Profile
extends
Thread
{
public
class
Profile
extends
Thread
{
public
static
final
boolean
LIST_UNVISITED
=
tru
e
;
public
static
final
boolean
LIST_UNVISITED
=
fals
e
;
public
static
final
boolean
FAST
=
false
;
public
static
final
boolean
FAST
=
false
;
public
static
final
boolean
TRACE
=
false
;
public
static
final
boolean
TRACE
=
false
;
public
static
final
Profile
MAIN
=
new
Profile
();
public
static
final
Profile
MAIN
=
new
Profile
();
...
...
h2/src/t
ools/org/h2/tools/ftp
/FtpClient.java
→
h2/src/t
est/org/h2/test/unit
/FtpClient.java
浏览文件 @
7c19e7bc
package
org
.
h2
.
t
ools
.
ftp
;
package
org
.
h2
.
t
est
.
unit
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.net.InetAddress
;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.util.IOUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.StringUtils
;
public
class
FtpClient
{
public
class
FtpClient
{
private
Socket
socket
;
private
Socket
socket
;
...
@@ -20,6 +23,9 @@ public class FtpClient {
...
@@ -20,6 +23,9 @@ public class FtpClient {
private
PrintWriter
writer
;
private
PrintWriter
writer
;
private
int
code
;
private
int
code
;
private
String
message
;
private
String
message
;
private
Socket
socketData
;
private
InputStream
inData
;
private
OutputStream
outData
;
public
static
FtpClient
open
(
String
url
)
throws
SQLException
,
IOException
{
public
static
FtpClient
open
(
String
url
)
throws
SQLException
,
IOException
{
FtpClient
client
=
new
FtpClient
();
FtpClient
client
=
new
FtpClient
();
...
@@ -46,6 +52,7 @@ public class FtpClient {
...
@@ -46,6 +52,7 @@ public class FtpClient {
code
=
0
;
code
=
0
;
}
else
{
}
else
{
code
=
Integer
.
parseInt
(
message
.
substring
(
0
,
idx
));
code
=
Integer
.
parseInt
(
message
.
substring
(
0
,
idx
));
message
=
message
.
substring
(
idx
+
1
);
}
}
}
}
...
@@ -61,60 +68,164 @@ public class FtpClient {
...
@@ -61,60 +68,164 @@ public class FtpClient {
writer
.
flush
();
writer
.
flush
();
}
}
public
void
sendUser
(
String
userName
)
throws
IOException
{
public
void
login
(
String
userName
,
String
password
)
throws
IOException
{
send
(
"USER "
+
userName
);
send
(
"USER "
+
userName
);
readCode
(
331
);
readCode
(
331
);
}
send
(
"PASS "
+
password
);
readCode
(
230
);
public
void
sendQuit
()
throws
IOException
{
send
(
"SYST"
);
readCode
(
215
);
send
(
"SITE"
);
readCode
(
500
);
send
(
"STRU F"
);
readCode
(
200
);
send
(
"TYPE I"
);
readCode
(
200
);
}
public
void
close
()
throws
IOException
{
if
(
socket
!=
null
)
{
send
(
"QUIT"
);
send
(
"QUIT"
);
readCode
(
221
);
readCode
(
221
);
socket
.
close
();
}
}
public
void
sendPassword
(
String
password
)
throws
IOException
{
send
(
"PASS "
+
password
);
readCode
(
230
);
}
}
public
void
sendC
hangeWorkingDirectory
(
String
dir
)
throws
IOException
{
public
void
c
hangeWorkingDirectory
(
String
dir
)
throws
IOException
{
send
(
"CWD "
+
dir
);
send
(
"CWD "
+
dir
);
readCode
(
250
);
readCode
(
250
);
}
}
public
void
sendC
hangeDirectoryUp
()
throws
IOException
{
public
void
c
hangeDirectoryUp
()
throws
IOException
{
send
(
"CDUP"
);
send
(
"CDUP"
);
readCode
(
250
);
readCode
(
250
);
}
}
public
void
sendD
elete
(
String
fileName
)
throws
IOException
{
public
void
d
elete
(
String
fileName
)
throws
IOException
{
send
(
"DELE "
+
fileName
);
send
(
"DELE "
+
fileName
);
readCode
(
250
);
readCode
(
250
);
}
}
public
void
sendMakeDirectory
(
String
dir
)
throws
IOException
{
public
void
makeDirectory
(
String
dir
)
throws
IOException
{
send
(
"MKD "
+
dir
);
readCode
(
257
);
}
public
void
mode
(
String
mode
)
throws
IOException
{
send
(
"MODE "
+
mode
);
readCode
(
200
);
}
}
public
void
sendMode
(
String
dir
)
throws
IOException
{
public
void
modificationTime
(
String
fileName
)
throws
IOException
{
send
(
"MDTM "
+
fileName
);
readCode
(
213
);
}
}
public
void
sendModifiedTime
(
String
dir
)
throws
IOException
{
public
void
noOperation
()
throws
IOException
{
send
(
"NOOP"
);
readCode
(
200
);
}
}
public
void
sendNameList
(
String
dir
)
throws
IOException
{
public
String
printWorkingDirectory
()
throws
IOException
{
send
(
"PWD"
);
readCode
(
257
);
return
unquote
();
}
}
public
void
sendRenameFrom
(
String
dir
)
throws
IOException
{
private
String
unquote
()
{
int
first
=
message
.
indexOf
(
'"'
)
+
1
;
int
last
=
message
.
lastIndexOf
(
'"'
);
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
first
;
i
<
last
;
i
++)
{
char
ch
=
message
.
charAt
(
i
);
buff
.
append
(
ch
);
if
(
ch
==
'\"'
)
{
i
++;
}
}
return
buff
.
toString
();
}
}
public
String
[]
sendList
(
String
dir
)
throws
IOException
{
private
void
passive
()
throws
IOException
,
SQLException
{
send
(
"LIST "
+
dir
);
send
(
"PASV"
);
readCode
(
227
);
int
first
=
message
.
indexOf
(
'('
)
+
1
;
int
last
=
message
.
indexOf
(
')'
);
String
[]
address
=
StringUtils
.
arraySplit
(
message
.
substring
(
first
,
last
),
','
,
true
);
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
if
(
i
>
0
)
{
buff
.
append
(
'.'
);
}
buff
.
append
(
address
[
i
]);
}
String
ip
=
buff
.
toString
();
InetAddress
addr
=
InetAddress
.
getByName
(
ip
);
int
port
=
(
Integer
.
parseInt
(
address
[
4
])
<<
8
)
|
Integer
.
parseInt
(
address
[
5
]);
socketData
=
NetUtils
.
createSocket
(
addr
,
port
,
false
);
inData
=
socketData
.
getInputStream
();
outData
=
socketData
.
getOutputStream
();
}
public
void
rename
(
String
fromFileName
,
String
toFileName
)
throws
IOException
{
send
(
"RNFR "
+
fromFileName
);
readCode
(
350
);
send
(
"RNTO "
+
toFileName
);
readCode
(
250
);
readCode
(
250
);
ArrayList
list
=
new
ArrayList
();
}
public
void
retrieve
(
String
fileName
,
OutputStream
out
,
long
restartAt
)
throws
IOException
,
SQLException
{
passive
();
if
(
restartAt
>
0
)
{
send
(
"REST "
+
restartAt
);
readCode
(
350
);
}
send
(
"RETR "
+
fileName
);
IOUtils
.
copyAndClose
(
inData
,
out
);
readCode
(
226
);
}
public
void
removeDirectory
(
String
dir
)
throws
IOException
{
send
(
"RMD "
+
dir
);
readCode
(
250
);
}
String
[]
result
=
new
String
[
list
.
size
()];
public
long
size
(
String
fileName
)
throws
IOException
{
list
.
toArray
(
result
);
send
(
"SIZE "
+
fileName
);
return
result
;
readCode
(
250
);
long
size
=
Long
.
parseLong
(
message
);
return
size
;
}
public
void
store
(
String
fileName
,
InputStream
in
)
throws
IOException
,
SQLException
{
passive
();
send
(
"STOR "
+
fileName
);
readCode
(
150
);
IOUtils
.
copyAndClose
(
in
,
outData
);
readCode
(
226
);
}
public
String
nameList
(
String
dir
)
throws
IOException
,
SQLException
{
passive
();
send
(
"NLST "
+
dir
);
readCode
(
150
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
IOUtils
.
copyAndClose
(
inData
,
out
);
readCode
(
226
);
byte
[]
data
=
out
.
toByteArray
();
return
new
String
(
data
);
}
public
String
list
(
String
dir
)
throws
IOException
,
SQLException
{
passive
();
send
(
"LIST "
+
dir
);
readCode
(
150
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
IOUtils
.
copyAndClose
(
inData
,
out
);
readCode
(
226
);
byte
[]
data
=
out
.
toByteArray
();
return
new
String
(
data
);
}
}
}
}
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
7c19e7bc
...
@@ -18,19 +18,22 @@ import org.h2.test.TestBase;
...
@@ -18,19 +18,22 @@ import org.h2.test.TestBase;
public
class
TestFileSystem
extends
TestBase
{
public
class
TestFileSystem
extends
TestBase
{
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
testFileSystem
(
FileSystem
.
getInstance
(
FileSystemMemory
.
MEMORY_PREFIX
));
testFileSystem
(
FileSystemMemory
.
MEMORY_PREFIX
);
testFileSystem
(
FileSystem
.
getInstance
(
baseDir
+
"/fs"
));
testFileSystem
(
baseDir
+
"/fs"
);
testFileSystem
(
FileSystem
.
getInstance
(
FileSystemMemory
.
MEMORY_PREFIX_LZF
));
testFileSystem
(
FileSystemMemory
.
MEMORY_PREFIX_LZF
);
int
test
;
// testFileSystem("jdbc:h2:mem:fs;TRACE_LEVEL_FILE=0/");
}
}
private
void
testFileSystem
(
FileSystem
fs
)
throws
Exception
{
private
void
testFileSystem
(
String
fsBase
)
throws
Exception
{
testTempFile
(
fs
);
testTempFile
(
fs
Base
);
testRandomAccess
(
fs
);
testRandomAccess
(
fs
Base
);
}
}
private
void
testRandomAccess
(
FileSystem
fs
)
throws
Exception
{
private
void
testRandomAccess
(
String
fsBase
)
throws
Exception
{
String
s
=
fs
.
createTempFile
(
"temp"
,
"tmp"
,
false
,
false
);
FileSystem
fs
=
FileSystem
.
getInstance
(
fsBase
);
File
file
=
new
File
(
baseDir
+
"temp"
);
String
s
=
fs
.
createTempFile
(
fsBase
+
"/temp"
,
".tmp"
,
false
,
false
);
File
file
=
new
File
(
baseDir
+
"/temp"
);
file
.
delete
();
file
.
delete
();
RandomAccessFile
ra
=
new
RandomAccessFile
(
file
,
"rw"
);
RandomAccessFile
ra
=
new
RandomAccessFile
(
file
,
"rw"
);
fs
.
delete
(
s
);
fs
.
delete
(
s
);
...
@@ -100,8 +103,9 @@ public class TestFileSystem extends TestBase {
...
@@ -100,8 +103,9 @@ public class TestFileSystem extends TestBase {
ra
.
close
();
ra
.
close
();
}
}
private
void
testTempFile
(
FileSystem
fs
)
throws
Exception
{
private
void
testTempFile
(
String
fsBase
)
throws
Exception
{
String
s
=
fs
.
createTempFile
(
"temp"
,
"tmp"
,
false
,
false
);
FileSystem
fs
=
FileSystem
.
getInstance
(
fsBase
);
String
s
=
fs
.
createTempFile
(
fsBase
+
"/temp"
,
".tmp"
,
false
,
false
);
OutputStream
out
=
fs
.
openFileOutputStream
(
s
,
false
);
OutputStream
out
=
fs
.
openFileOutputStream
(
s
,
false
);
byte
[]
buffer
=
new
byte
[
10000
];
byte
[]
buffer
=
new
byte
[
10000
];
out
.
write
(
buffer
);
out
.
write
(
buffer
);
...
...
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
7c19e7bc
package
org
.
h2
.
test
.
unit
;
package
org
.
h2
.
test
.
unit
;
import
java.sql.SQLException
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
...
@@ -11,9 +9,18 @@ public class TestFtp extends TestBase {
...
@@ -11,9 +9,18 @@ public class TestFtp extends TestBase {
test
(
baseDir
);
test
(
baseDir
);
}
}
private
void
test
(
String
dir
)
throws
SQL
Exception
{
private
void
test
(
String
dir
)
throws
Exception
{
Server
server
=
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
}).
start
();
Server
server
=
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
}).
start
();
FtpClient
client
=
FtpClient
.
open
(
"localhost:8021"
);
client
.
login
(
"sa"
,
"sa"
);
client
.
makeDirectory
(
"test"
);
client
.
changeWorkingDirectory
(
"test"
);
client
.
makeDirectory
(
"hello"
);
client
.
changeWorkingDirectory
(
"hello"
);
client
.
changeDirectoryUp
();
client
.
nameList
(
"hello"
);
client
.
removeDirectory
(
"hello"
);
client
.
close
();
server
.
stop
();
server
.
stop
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论