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 @@
<fileset
dir=
"src/main"
/>
</copy>
<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>
<javac
target=
"${jdk}"
source=
"${jdk}"
executable=
"${javac}"
srcdir=
"bin"
destdir=
"bin"
debug=
"true"
includes=
"org/h2/**"
/>
</target>
...
...
h2/src/docsrc/html/build.html
浏览文件 @
7c19e7bc
...
...
@@ -31,8 +31,11 @@ It can also be compiled to a native executable using GCJ.
<br
/><a
name=
"environment"
></a>
<h2>
Environment
</h2>
<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.
In most cases, n
ewer version or compatible software works too.
N
ewer version or compatible software works too.
</p>
<ul>
<li>
Windows XP
...
...
h2/src/main/org/h2/command/Command.java
浏览文件 @
7c19e7bc
...
...
@@ -139,8 +139,4 @@ public abstract class Command implements CommandInterface {
public
void
cancel
()
{
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;
import
java.sql.SQLException
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.SessionInterface
;
import
org.h2.engine.SessionRemote
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.expression.ParameterRemote
;
...
...
@@ -192,10 +191,6 @@ public class CommandRemote implements CommandInterface {
}
}
public
SessionInterface
getSession
()
{
return
session
;
}
public
void
close
()
{
if
(
session
==
null
||
session
.
isClosed
())
{
return
;
...
...
h2/src/main/org/h2/command/ddl/CreateSequence.java
浏览文件 @
7c19e7bc
...
...
@@ -60,10 +60,6 @@ public class CreateSequence extends SchemaCommand {
this
.
increment
=
increment
;
}
public
boolean
getBelongsToTable
()
{
return
belongsToTable
;
}
public
void
setBelongsToTable
(
boolean
belongsToTable
)
{
this
.
belongsToTable
=
belongsToTable
;
}
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
7c19e7bc
...
...
@@ -163,7 +163,7 @@ public abstract class Query extends Prepared {
}
}
else
{
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
);
if
(
s2
.
equals
(
s
))
{
idx
=
j
;
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
7c19e7bc
...
...
@@ -667,18 +667,6 @@ public class Select extends Query {
return
expressions
;
}
public
Expression
getCondition
()
{
return
condition
;
}
public
boolean
isDistinct
()
{
return
distinct
;
}
public
ObjectArray
getGroupBy
()
{
return
group
;
}
public
void
setForUpdate
(
boolean
b
)
{
this
.
isForUpdate
=
b
;
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
7c19e7bc
...
...
@@ -324,14 +324,6 @@ public class SelectUnion extends Query {
return
left
.
isReadOnly
()
&&
right
.
isReadOnly
();
}
public
Query
getLeftQuery
()
{
return
left
;
}
public
Query
getRightQuery
()
{
return
right
;
}
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
left
.
updateAggregate
(
session
);
right
.
updateAggregate
(
session
);
...
...
h2/src/main/org/h2/index/ScanCursor.java
浏览文件 @
7c19e7bc
...
...
@@ -31,10 +31,6 @@ public class ScanCursor implements Cursor {
row
=
null
;
}
Session
getSession
()
{
return
session
;
}
public
Row
get
()
{
return
row
;
}
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
7c19e7bc
...
...
@@ -34,8 +34,6 @@ import org.h2.message.Message;
/**
* A data source for H2 database connections
*
* @author Tom
*/
public
class
JdbcDataSource
extends
TraceObject
implements
//#ifdef JDK14
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
7c19e7bc
...
...
@@ -170,10 +170,6 @@ public class LogSystem {
}
}
boolean
needMoreUndo
()
{
return
sessions
.
size
()
>
0
;
}
void
addUndoLogRecord
(
LogFile
log
,
int
logRecordId
,
int
sessionId
)
{
LogRecord
record
=
new
LogRecord
(
log
,
logRecordId
,
sessionId
);
undo
.
add
(
record
);
...
...
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
7c19e7bc
...
...
@@ -77,9 +77,6 @@ public class UpdatableRow {
return
isUpdatable
;
}
void
initKey
()
throws
SQLException
{
}
private
int
getColumnIndex
(
String
columnName
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
String
col
=
result
.
getColumnName
(
i
);
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
7c19e7bc
...
...
@@ -223,10 +223,6 @@ public class TcpServer implements Service {
running
.
remove
(
t
);
}
boolean
getLog
()
{
return
log
;
}
String
getBaseDir
()
{
return
baseDir
;
}
...
...
h2/src/main/org/h2/server/ftp/FtpControl.java
浏览文件 @
7c19e7bc
...
...
@@ -176,7 +176,7 @@ public class FtpControl extends Thread {
if
(!
readonly
)
{
try
{
fs
.
mkdirs
(
fileName
);
reply
(
257
,
"\""
+
param
+
"\" directory"
);
// TODO quote (" > "")
reply
(
257
,
StringUtils
.
quoteIdentifier
(
param
)
+
" directory"
);
ok
=
true
;
}
catch
(
SQLException
e
)
{
server
.
logError
(
e
);
...
...
@@ -209,14 +209,13 @@ public class FtpControl extends Thread {
break
;
case
'P'
:
if
(
"PWD"
.
equals
(
command
))
{
reply
(
257
,
"\""
+
currentDir
+
"\" directory"
);
// TODO quote (" > "")
reply
(
257
,
StringUtils
.
quoteIdentifier
(
currentDir
)
+
" directory"
);
}
else
if
(
"PASV"
.
equals
(
command
))
{
ServerSocket
dataSocket
=
server
.
createDataSocket
();
data
=
new
FtpData
(
server
,
control
.
getInetAddress
(),
dataSocket
);
data
.
start
();
int
port
=
dataSocket
.
getLocalPort
();
reply
(
227
,
"Passive Mode ("
+
serverIpAddress
+
","
+
(
port
>>
8
)
+
","
+
(
port
&
255
)
+
")"
);
// reply(501, ne.getMessage());
}
break
;
case
'R'
:
...
...
@@ -261,8 +260,7 @@ public class FtpControl extends Thread {
}
restart
=
0
;
}
else
{
processList
(
param
,
true
);
// Firefox compatibility (still
// not good)
processList
(
param
,
true
);
// Firefox compatibility (still not good)
// reply(426, "Not a file");
}
}
else
if
(
"RMD"
.
equals
(
command
))
{
...
...
@@ -355,8 +353,7 @@ public class FtpControl extends Thread {
String
list
=
server
.
getDirectoryListing
(
directory
,
directories
);
reply
(
150
,
"Starting transfer"
);
server
.
log
(
list
);
// need to use the current locale (UTF-8 would be wrong for the Windows
// Explorer)
// need to use the current locale (UTF-8 would be wrong for the Windows Explorer)
data
.
send
(
list
.
getBytes
());
reply
(
226
,
"Done"
);
}
...
...
h2/src/main/org/h2/store/DataPage.java
浏览文件 @
7c19e7bc
...
...
@@ -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
)
{
this
.
handler
=
handler
;
this
.
data
=
data
;
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
7c19e7bc
...
...
@@ -79,6 +79,7 @@ import org.h2.test.unit.TestExit;
import
org.h2.test.unit.TestFile
;
import
org.h2.test.unit.TestFileLock
;
import
org.h2.test.unit.TestFileSystem
;
import
org.h2.test.unit.TestFtp
;
import
org.h2.test.unit.TestIntArray
;
import
org.h2.test.unit.TestIntIntHashMap
;
import
org.h2.test.unit.TestMultiThreadedKernel
;
...
...
@@ -134,6 +135,7 @@ java org.h2.test.TestAll timer
public
boolean
jdk14
=
true
;
private
Server
server
;
public
boolean
cache2Q
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
long
time
=
System
.
currentTimeMillis
();
...
...
@@ -142,6 +144,10 @@ java org.h2.test.TestAll timer
/*
unit tests for ftp
start writing javadocs for jdbcx package
replicating file system
background thread writing file system (all writes)
...
...
@@ -276,6 +282,12 @@ write tests using the PostgreSQL JDBC driver
// 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
(
"crash"
.
equals
(
args
[
0
]))
{
new
TestCrashAPI
().
runTest
(
test
);
...
...
@@ -381,6 +393,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
cipher
=
null
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
diskUndo
=
false
;
...
...
@@ -395,6 +408,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
cipher
=
null
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
big
=
false
;
...
...
@@ -411,6 +425,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
cipher
=
null
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
diskUndo
=
true
;
...
...
@@ -425,6 +440,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
1
;
cipher
=
"XTEA"
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
diskUndo
=
false
;
...
...
@@ -442,6 +458,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
cipher
=
null
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
big
=
true
;
...
...
@@ -458,6 +475,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
cipher
=
null
;
mvcc
=
false
;
cache2Q
=
true
;
testAll
();
big
=
true
;
...
...
@@ -474,6 +492,7 @@ write tests using the PostgreSQL JDBC driver
throttle
=
0
;
cipher
=
"AES"
;
mvcc
=
false
;
cache2Q
=
false
;
testAll
();
smallLog
=
big
=
networked
=
memory
=
ssl
=
textStorage
=
diskResult
=
deleteIndex
=
traceSystemOut
=
false
;
...
...
@@ -481,6 +500,7 @@ write tests using the PostgreSQL JDBC driver
logMode
=
1
;
cipher
=
null
;
mvcc
=
true
;
cache2Q
=
false
;
testAll
();
}
...
...
@@ -499,6 +519,7 @@ write tests using the PostgreSQL JDBC driver
new
TestExit
().
runTest
(
this
);
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFtp
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
new
TestIntIntHashMap
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
7c19e7bc
...
...
@@ -138,6 +138,9 @@ public abstract class TestBase {
if
(
config
.
mvcc
)
{
url
+=
";MVCC=TRUE"
;
}
if
(
config
.
cache2Q
)
{
url
+=
";CACHE_TYPE=TQ"
;
}
if
(
config
.
diskResult
&&
admin
)
{
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;
* The class used at runtime to measure the code usage and performance.
*/
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
TRACE
=
false
;
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.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.net.InetAddress
;
import
java.net.Socket
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.engine.Constants
;
import
org.h2.util.IOUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.StringUtils
;
public
class
FtpClient
{
private
Socket
socket
;
...
...
@@ -20,6 +23,9 @@ public class FtpClient {
private
PrintWriter
writer
;
private
int
code
;
private
String
message
;
private
Socket
socketData
;
private
InputStream
inData
;
private
OutputStream
outData
;
public
static
FtpClient
open
(
String
url
)
throws
SQLException
,
IOException
{
FtpClient
client
=
new
FtpClient
();
...
...
@@ -46,6 +52,7 @@ public class FtpClient {
code
=
0
;
}
else
{
code
=
Integer
.
parseInt
(
message
.
substring
(
0
,
idx
));
message
=
message
.
substring
(
idx
+
1
);
}
}
...
...
@@ -61,60 +68,164 @@ public class FtpClient {
writer
.
flush
();
}
public
void
sendUser
(
String
userName
)
throws
IOException
{
public
void
login
(
String
userName
,
String
password
)
throws
IOException
{
send
(
"USER "
+
userName
);
readCode
(
331
);
}
public
void
sendQuit
()
throws
IOException
{
send
(
"QUIT"
);
readCode
(
221
);
}
public
void
sendPassword
(
String
password
)
throws
IOException
{
send
(
"PASS "
+
password
);
readCode
(
230
);
send
(
"SYST"
);
readCode
(
215
);
send
(
"SITE"
);
readCode
(
500
);
send
(
"STRU F"
);
readCode
(
200
);
send
(
"TYPE I"
);
readCode
(
200
);
}
public
void
sendChangeWorkingDirectory
(
String
dir
)
throws
IOException
{
public
void
close
()
throws
IOException
{
if
(
socket
!=
null
)
{
send
(
"QUIT"
);
readCode
(
221
);
socket
.
close
();
}
}
public
void
changeWorkingDirectory
(
String
dir
)
throws
IOException
{
send
(
"CWD "
+
dir
);
readCode
(
250
);
}
public
void
sendC
hangeDirectoryUp
()
throws
IOException
{
public
void
c
hangeDirectoryUp
()
throws
IOException
{
send
(
"CDUP"
);
readCode
(
250
);
}
public
void
sendD
elete
(
String
fileName
)
throws
IOException
{
public
void
d
elete
(
String
fileName
)
throws
IOException
{
send
(
"DELE "
+
fileName
);
readCode
(
250
);
}
public
void
sendMakeDirectory
(
String
dir
)
throws
IOException
{
public
void
makeDirectory
(
String
dir
)
throws
IOException
{
send
(
"MKD "
+
dir
);
readCode
(
257
);
}
public
void
sendMode
(
String
dir
)
throws
IOException
{
public
void
mode
(
String
mode
)
throws
IOException
{
send
(
"MODE "
+
mode
);
readCode
(
200
);
}
public
void
sendModifiedTime
(
String
dir
)
throws
IOException
{
public
void
modificationTime
(
String
fileName
)
throws
IOException
{
send
(
"MDTM "
+
fileName
);
readCode
(
213
);
}
public
void
sendNameList
(
String
dir
)
throws
IOException
{
public
void
noOperation
()
throws
IOException
{
send
(
"NOOP"
);
readCode
(
200
);
}
public
void
sendRenameFrom
(
String
dir
)
throws
IOException
{
public
String
printWorkingDirectory
()
throws
IOException
{
send
(
"PWD"
);
readCode
(
257
);
return
unquote
();
}
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
();
}
private
void
passive
()
throws
IOException
,
SQLException
{
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
);
}
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
String
[]
sendList
(
String
dir
)
throws
IOException
{
send
(
"
LIST
"
+
dir
);
public
void
removeDirectory
(
String
dir
)
throws
IOException
{
send
(
"
RMD
"
+
dir
);
readCode
(
250
);
ArrayList
list
=
new
ArrayList
();
String
[]
result
=
new
String
[
list
.
size
()];
list
.
toArray
(
result
);
return
result
;
}
public
long
size
(
String
fileName
)
throws
IOException
{
send
(
"SIZE "
+
fileName
);
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;
public
class
TestFileSystem
extends
TestBase
{
public
void
test
()
throws
Exception
{
testFileSystem
(
FileSystem
.
getInstance
(
FileSystemMemory
.
MEMORY_PREFIX
));
testFileSystem
(
FileSystem
.
getInstance
(
baseDir
+
"/fs"
));
testFileSystem
(
FileSystem
.
getInstance
(
FileSystemMemory
.
MEMORY_PREFIX_LZF
));
testFileSystem
(
FileSystemMemory
.
MEMORY_PREFIX
);
testFileSystem
(
baseDir
+
"/fs"
);
testFileSystem
(
FileSystemMemory
.
MEMORY_PREFIX_LZF
);
int
test
;
// testFileSystem("jdbc:h2:mem:fs;TRACE_LEVEL_FILE=0/");
}
private
void
testFileSystem
(
FileSystem
fs
)
throws
Exception
{
testTempFile
(
fs
);
testRandomAccess
(
fs
);
private
void
testFileSystem
(
String
fsBase
)
throws
Exception
{
testTempFile
(
fs
Base
);
testRandomAccess
(
fs
Base
);
}
private
void
testRandomAccess
(
FileSystem
fs
)
throws
Exception
{
String
s
=
fs
.
createTempFile
(
"temp"
,
"tmp"
,
false
,
false
);
File
file
=
new
File
(
baseDir
+
"temp"
);
private
void
testRandomAccess
(
String
fsBase
)
throws
Exception
{
FileSystem
fs
=
FileSystem
.
getInstance
(
fsBase
);
String
s
=
fs
.
createTempFile
(
fsBase
+
"/temp"
,
".tmp"
,
false
,
false
);
File
file
=
new
File
(
baseDir
+
"/temp"
);
file
.
delete
();
RandomAccessFile
ra
=
new
RandomAccessFile
(
file
,
"rw"
);
fs
.
delete
(
s
);
...
...
@@ -100,8 +103,9 @@ public class TestFileSystem extends TestBase {
ra
.
close
();
}
private
void
testTempFile
(
FileSystem
fs
)
throws
Exception
{
String
s
=
fs
.
createTempFile
(
"temp"
,
"tmp"
,
false
,
false
);
private
void
testTempFile
(
String
fsBase
)
throws
Exception
{
FileSystem
fs
=
FileSystem
.
getInstance
(
fsBase
);
String
s
=
fs
.
createTempFile
(
fsBase
+
"/temp"
,
".tmp"
,
false
,
false
);
OutputStream
out
=
fs
.
openFileOutputStream
(
s
,
false
);
byte
[]
buffer
=
new
byte
[
10000
];
out
.
write
(
buffer
);
...
...
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
7c19e7bc
package
org
.
h2
.
test
.
unit
;
import
java.sql.SQLException
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
...
...
@@ -11,9 +9,18 @@ public class TestFtp extends TestBase {
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
();
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
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论