提交 7c19e7bc authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 ad13cf0d
...@@ -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>
......
...@@ -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, newer version or compatible software works too. Newer version or compatible software works too.
</p> </p>
<ul> <ul>
<li>Windows XP <li>Windows XP
......
...@@ -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;
}
} }
...@@ -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;
......
...@@ -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;
} }
......
...@@ -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;
......
...@@ -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;
} }
......
...@@ -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);
......
...@@ -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;
} }
......
...@@ -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
......
...@@ -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);
......
...@@ -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);
......
...@@ -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;
} }
......
...@@ -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");
} }
......
...@@ -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;
......
...@@ -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);
......
...@@ -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";
} }
......
...@@ -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 = true; public static final boolean LIST_UNVISITED = false;
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();
......
package org.h2.tools.ftp; package org.h2.test.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 sendChangeWorkingDirectory(String dir) throws IOException { public void changeWorkingDirectory(String dir) throws IOException {
send("CWD " + dir); send("CWD " + dir);
readCode(250); readCode(250);
} }
public void sendChangeDirectoryUp() throws IOException { public void changeDirectoryUp() throws IOException {
send("CDUP"); send("CDUP");
readCode(250); readCode(250);
} }
public void sendDelete(String fileName) throws IOException { public void delete(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);
} }
} }
...@@ -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(fsBase);
testRandomAccess(fs); testRandomAccess(fsBase);
} }
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);
......
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 SQLException { 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论