提交 73d5ca84 authored 作者: Thomas Mueller's avatar Thomas Mueller

The test cases don't access the file system directly. Thanks to Vince Bonfanti!

上级 df786086
...@@ -18,7 +18,9 @@ Change Log ...@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>More bugs in the server-less multi-connection mode have been fixed. <ul><li>The test cases don't access the file system directly, this simplifies GAE for Java testing.
Thanks to Vince Bonfanti.
</li><li>More bugs in the server-less multi-connection mode have been fixed.
</li><li>When running against an old database, the SCRIPT statement could generate a </li><li>When running against an old database, the SCRIPT statement could generate a
SQL script that contained duplicate indexes (PRIMARY_KEY_E). SQL script that contained duplicate indexes (PRIMARY_KEY_E).
</li><li>JdbcConnectionPool.getConnection() could throw a NullPointerException. </li><li>JdbcConnectionPool.getConnection() could throw a NullPointerException.
......
...@@ -47,13 +47,14 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -47,13 +47,14 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Full outer joins </li><li>Full outer joins
</li><li>Implement INSTEAD OF trigger (for views, tables, metadata tables). </li><li>Implement INSTEAD OF trigger (for views, tables, metadata tables).
</li><li>Support triggers for INFORMATION_SCHEMA tables (to better support PostgreSQL catalog: rebuild after creating new tables) </li><li>Support triggers for INFORMATION_SCHEMA tables (to better support PostgreSQL catalog: rebuild after creating new tables)
</li><li>Support mixed clustering mode (one embedded, others in server mode)
</li><li>Use triggers for metadata tables; use for PostgreSQL catalog </li><li>Use triggers for metadata tables; use for PostgreSQL catalog
</li><li>Test very large databases and LOBs (up to 256 GB) </li><li>Test very large databases and LOBs (up to 256 GB)
</li><li>Support alter table add column if table has views defined </li><li>Support alter table add column if table has views defined
</li><li>Support hints for the optimizer (which index to use, enforce the join order). </li><li>Support hints for the optimizer (which index to use, enforce the join order).
</li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file) </li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file)
</li><li>Clustering: recovery needs to becomes fully automatic. Global write lock feature. </li><li>Clustering: recovery needs to becomes fully automatic. Global write lock feature.
</li><li>Support mixed clustering mode (one embedded, others in server mode) </li><li>Clustering: reads should be randomly distributed (optional) or to a designated database on RAM (parameter: READ_FROM=3)
</li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CYCLE </li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CYCLE
</li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED) </li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED)
</li><li>Groovy Stored Procedures (http://groovy.codehaus.org/Groovy+SQL) </li><li>Groovy Stored Procedures (http://groovy.codehaus.org/Groovy+SQL)
...@@ -76,7 +77,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -76,7 +77,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Pluggable data type (for streaming, hashing, compression, validation, conversion, encryption) </li><li>Pluggable data type (for streaming, hashing, compression, validation, conversion, encryption)
</li><li>CHECK: find out what makes CHECK=TRUE slow, move to CHECK2 </li><li>CHECK: find out what makes CHECK=TRUE slow, move to CHECK2
</li><li>Index usage for (ID, NAME)=(1, 'Hi'); document </li><li>Index usage for (ID, NAME)=(1, 'Hi'); document
</li><li>Clustering: reads should be randomly distributed (optional) or to a designated database on RAM
</li><li>Make DDL (Data Definition) operations transactional </li><li>Make DDL (Data Definition) operations transactional
</li><li>RANK() and DENSE_RANK(), Partition using OVER() </li><li>RANK() and DENSE_RANK(), Partition using OVER()
</li><li>Set a connection read only (Connection.setReadOnly) or using a connection parameter </li><li>Set a connection read only (Connection.setReadOnly) or using a connection parameter
......
...@@ -271,7 +271,7 @@ public class TestCases extends TestBase { ...@@ -271,7 +271,7 @@ public class TestCases extends TestBase {
} }
private void testUpperCaseLowerCaseDatabase() throws SQLException { private void testUpperCaseLowerCaseDatabase() throws SQLException {
if (File.separatorChar != '\\') { if (File.separatorChar != '\\' || config.googleAppEngine) {
return; return;
} }
deleteDb("cases"); deleteDb("cases");
...@@ -633,7 +633,7 @@ public class TestCases extends TestBase { ...@@ -633,7 +633,7 @@ public class TestCases extends TestBase {
} }
private void testDoubleRecovery() throws SQLException { private void testDoubleRecovery() throws SQLException {
if (config.networked) { if (config.networked || config.googleAppEngine) {
return; return;
} }
trace("testDoubleRecovery"); trace("testDoubleRecovery");
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
package org.h2.test.db; package org.h2.test.db;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -18,6 +17,8 @@ import java.sql.Statement; ...@@ -18,6 +17,8 @@ import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import org.h2.store.fs.FileObject;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.Csv; import org.h2.tools.Csv;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
...@@ -81,16 +82,18 @@ public class TestCsv extends TestBase { ...@@ -81,16 +82,18 @@ public class TestCsv extends TestBase {
private void testNull() throws Exception { private void testNull() throws Exception {
deleteDb("csv"); deleteDb("csv");
File f = new File(baseDir + "/testNull.csv"); String fileName = baseDir + "/testNull.csv";
FileUtils.delete(f.getAbsolutePath()); FileSystem fs = FileSystem.getInstance(fileName);
fs.delete(fileName);
RandomAccessFile file = new RandomAccessFile(f, "rw");
FileObject file = fs.openFileObject(fileName, "rw");
String csvContent = "\"A\",\"B\",\"C\",\"D\"\n\\N,\"\",\"\\N\","; String csvContent = "\"A\",\"B\",\"C\",\"D\"\n\\N,\"\",\"\\N\",";
file.write(csvContent.getBytes("UTF-8")); byte[] b = csvContent.getBytes("UTF-8");
file.write(b, 0, b.length);
file.close(); file.close();
Csv csv = Csv.getInstance(); Csv csv = Csv.getInstance();
csv.setNullString("\\N"); csv.setNullString("\\N");
ResultSet rs = csv.read(f.getPath(), null, "UTF8"); ResultSet rs = csv.read(file.getName(), null, "UTF8");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
assertEquals(4, meta.getColumnCount()); assertEquals(4, meta.getColumnCount());
assertEquals("A", meta.getColumnLabel(1)); assertEquals("A", meta.getColumnLabel(1));
...@@ -108,15 +111,15 @@ public class TestCsv extends TestBase { ...@@ -108,15 +111,15 @@ public class TestCsv extends TestBase {
Connection conn = getConnection("csv"); Connection conn = getConnection("csv");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("call csvwrite('" + f.getPath() + "', 'select NULL as a, '''' as b, ''\\N'' as c, NULL as d', 'UTF8', ',', '\"', NULL, '\\N', '\n')"); stat.execute("call csvwrite('" + file.getName() + "', 'select NULL as a, '''' as b, ''\\N'' as c, NULL as d', 'UTF8', ',', '\"', NULL, '\\N', '\n')");
FileReader reader = new FileReader(f); InputStreamReader reader = new InputStreamReader(fs.openFileInputStream(fileName));
// on read, an empty string is treated like null, // on read, an empty string is treated like null,
// but on write a null is always written with the nullString // but on write a null is always written with the nullString
String data = IOUtils.readStringAndClose(reader, -1); String data = IOUtils.readStringAndClose(reader, -1);
assertEquals(csvContent + "\\N", data.trim()); assertEquals(csvContent + "\\N", data.trim());
conn.close(); conn.close();
FileUtils.delete(f.getAbsolutePath()); fs.delete(fileName);
} }
private void testRandomData() throws SQLException { private void testRandomData() throws SQLException {
...@@ -166,16 +169,16 @@ public class TestCsv extends TestBase { ...@@ -166,16 +169,16 @@ public class TestCsv extends TestBase {
} }
private void testEmptyFieldDelimiter() throws Exception { private void testEmptyFieldDelimiter() throws Exception {
File f = new File(baseDir + "/test.csv"); String fileName = baseDir + "/test.csv";
f.delete(); FileUtils.delete(fileName);
Connection conn = getConnection("csv"); Connection conn = getConnection("csv");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("call csvwrite('"+baseDir+"/test.csv', 'select 1 id, ''Hello'' name', null, '|', '', null, null, chr(10))"); stat.execute("call csvwrite('"+fileName+"', 'select 1 id, ''Hello'' name', null, '|', '', null, null, chr(10))");
FileReader reader = new FileReader(baseDir + "/test.csv"); InputStreamReader reader = new InputStreamReader(FileUtils.openFileInputStream(fileName));
String text = IOUtils.readStringAndClose(reader, -1).trim(); String text = IOUtils.readStringAndClose(reader, -1).trim();
text = StringUtils.replaceAll(text, "\n", " "); text = StringUtils.replaceAll(text, "\n", " ");
assertEquals("ID|NAME 1|Hello", text); assertEquals("ID|NAME 1|Hello", text);
ResultSet rs = stat.executeQuery("select * from csvread('" + baseDir + "/test.csv', null, null, '|', '')"); ResultSet rs = stat.executeQuery("select * from csvread('" + fileName + "', null, null, '|', '')");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
assertEquals(2, meta.getColumnCount()); assertEquals(2, meta.getColumnCount());
assertEquals("ID", meta.getColumnLabel(1)); assertEquals("ID", meta.getColumnLabel(1));
...@@ -185,18 +188,21 @@ public class TestCsv extends TestBase { ...@@ -185,18 +188,21 @@ public class TestCsv extends TestBase {
assertEquals("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
assertFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
FileUtils.delete(baseDir + "/test.csv"); FileUtils.delete(fileName);
} }
private void testFieldDelimiter() throws Exception { private void testFieldDelimiter() throws Exception {
File f = new File(baseDir + "/test.csv"); String fileName = baseDir + "/test.csv";
f.delete(); String fileName2 = baseDir + "/test2.csv";
RandomAccessFile file = new RandomAccessFile(f, "rw"); FileSystem fs = FileSystem.getInstance(fileName);
file.write("'A'; 'B'\n\'It\\'s nice\'; '\nHello\\*\n'".getBytes()); fs.delete(fileName);
FileObject file = fs.openFileObject(fileName, "rw");
byte[] b = "'A'; 'B'\n\'It\\'s nice\'; '\nHello\\*\n'".getBytes();
file.write(b, 0, b.length);
file.close(); file.close();
Connection conn = getConnection("csv"); Connection conn = getConnection("csv");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * from csvread('" + baseDir + "/test.csv', null, null, ';', '''', '\\')"); ResultSet rs = stat.executeQuery("select * from csvread('" + fileName + "', null, null, ';', '''', '\\')");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
assertEquals(2, meta.getColumnCount()); assertEquals(2, meta.getColumnCount());
assertEquals("A", meta.getColumnLabel(1)); assertEquals("A", meta.getColumnLabel(1));
...@@ -205,8 +211,8 @@ public class TestCsv extends TestBase { ...@@ -205,8 +211,8 @@ public class TestCsv extends TestBase {
assertEquals("It's nice", rs.getString(1)); assertEquals("It's nice", rs.getString(1));
assertEquals("\nHello*\n", rs.getString(2)); assertEquals("\nHello*\n", rs.getString(2));
assertFalse(rs.next()); assertFalse(rs.next());
stat.execute("call csvwrite('" + baseDir + "/test2.csv', 'select * from csvread(''" + baseDir + "/test.csv'', null, null, '';'', '''''''', ''\\'')', null, '+', '*', '#')"); stat.execute("call csvwrite('" + fileName2 + "', 'select * from csvread(''" + fileName + "'', null, null, '';'', '''''''', ''\\'')', null, '+', '*', '#')");
rs = stat.executeQuery("select * from csvread('" + baseDir + "/test2.csv', null, null, '+', '*', '#')"); rs = stat.executeQuery("select * from csvread('" + fileName2 + "', null, null, '+', '*', '#')");
meta = rs.getMetaData(); meta = rs.getMetaData();
assertEquals(2, meta.getColumnCount()); assertEquals(2, meta.getColumnCount());
assertEquals("A", meta.getColumnLabel(1)); assertEquals("A", meta.getColumnLabel(1));
...@@ -216,8 +222,8 @@ public class TestCsv extends TestBase { ...@@ -216,8 +222,8 @@ public class TestCsv extends TestBase {
assertEquals("\nHello*\n", rs.getString(2)); assertEquals("\nHello*\n", rs.getString(2));
assertFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
FileUtils.delete(baseDir + "/test.csv"); fs.delete(fileName);
FileUtils.delete(baseDir + "/test2.csv"); fs.delete(fileName2);
} }
private void testPipe() throws SQLException { private void testPipe() throws SQLException {
...@@ -262,12 +268,14 @@ public class TestCsv extends TestBase { ...@@ -262,12 +268,14 @@ public class TestCsv extends TestBase {
} }
private void testRead() throws Exception { private void testRead() throws Exception {
File f = new File(baseDir + "/test.csv"); String fileName = baseDir + "/test.csv";
f.delete(); FileSystem fs = FileSystem.getInstance(fileName);
RandomAccessFile file = new RandomAccessFile(f, "rw"); fs.delete(fileName);
file.write("a,b,c,d\n201,-2,0,18\n, \"abc\"\"\" ,,\"\"\n 1 ,2 , 3, 4 \n5, 6, 7, 8".getBytes()); FileObject file = fs.openFileObject(fileName, "rw");
byte[] b = "a,b,c,d\n201,-2,0,18\n, \"abc\"\"\" ,,\"\"\n 1 ,2 , 3, 4 \n5, 6, 7, 8".getBytes();
file.write(b, 0, b.length);
file.close(); file.close();
ResultSet rs = Csv.getInstance().read(baseDir + "/test.csv", null, "UTF8"); ResultSet rs = Csv.getInstance().read(fileName, null, "UTF8");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
assertEquals(4, meta.getColumnCount()); assertEquals(4, meta.getColumnCount());
assertEquals("a", meta.getColumnLabel(1)); assertEquals("a", meta.getColumnLabel(1));
...@@ -303,7 +311,7 @@ public class TestCsv extends TestBase { ...@@ -303,7 +311,7 @@ public class TestCsv extends TestBase {
// 201,2,0,18 // 201,2,0,18
// 201,2,0,18 // 201,2,0,18
// 201,2,0,18 // 201,2,0,18
FileUtils.delete(baseDir + "/test.csv"); fs.delete(fileName);
} }
private void testWriteRead() throws SQLException { private void testWriteRead() throws SQLException {
......
...@@ -31,8 +31,8 @@ public class TestEncryptedDb extends TestBase { ...@@ -31,8 +31,8 @@ public class TestEncryptedDb extends TestBase {
if (config.memory || config.cipher != null) { if (config.memory || config.cipher != null) {
return; return;
} }
deleteDb("exclusive"); deleteDb("encrypted");
Connection conn = getConnection("exclusive;CIPHER=AES", "sa", "123 123"); Connection conn = getConnection("encrypted;CIPHER=AES", "sa", "123 123");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT)"); stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
...@@ -46,13 +46,13 @@ public class TestEncryptedDb extends TestBase { ...@@ -46,13 +46,13 @@ public class TestEncryptedDb extends TestBase {
} }
try { try {
getConnection("exclusive;CIPHER=AES", "sa", "1234 1234"); getConnection("encrypted;CIPHER=AES", "sa", "1234 1234");
fail(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
conn = getConnection("exclusive;CIPHER=AES", "sa", "123 123"); conn = getConnection("encrypted;CIPHER=AES", "sa", "123 123");
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -60,7 +60,7 @@ public class TestEncryptedDb extends TestBase { ...@@ -60,7 +60,7 @@ public class TestEncryptedDb extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
deleteDb("exclusive"); deleteDb("encrypted");
} }
} }
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
package org.h2.test.db; package org.h2.test.db;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
...@@ -27,6 +26,7 @@ import java.util.UUID; ...@@ -27,6 +26,7 @@ import java.util.UUID;
import org.h2.api.AggregateFunction; import org.h2.api.AggregateFunction;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.New; import org.h2.util.New;
...@@ -224,26 +224,26 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -224,26 +224,26 @@ public class TestFunctions extends TestBase implements AggregateFunction {
private void testFileRead() throws Exception { private void testFileRead() throws Exception {
Connection conn = getConnection("functions"); Connection conn = getConnection("functions");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
File f = new File(baseDir + "/test.txt"); String fileName = baseDir + "/test.txt";
Properties prop = System.getProperties(); Properties prop = System.getProperties();
FileOutputStream out = new FileOutputStream(f); OutputStream out = FileUtils.openFileOutputStream(fileName, false);
prop.store(out, ""); prop.store(out, "");
out.close(); out.close();
ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + baseDir + "/test.txt')) LEN"); ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + fileName + "')) LEN");
rs.next(); rs.next();
assertEquals(f.length(), rs.getInt(1)); assertEquals(FileUtils.length(fileName), rs.getInt(1));
rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt') PROP"); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "') PROP");
rs.next(); rs.next();
Properties p2 = new Properties(); Properties p2 = new Properties();
p2.load(rs.getBinaryStream(1)); p2.load(rs.getBinaryStream(1));
assertEquals(prop.size(), p2.size()); assertEquals(prop.size(), p2.size());
rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt', NULL) PROP"); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "', NULL) PROP");
rs.next(); rs.next();
String ps = rs.getString(1); String ps = rs.getString(1);
FileReader r = new FileReader(f); InputStreamReader r = new InputStreamReader(FileUtils.openFileInputStream(fileName));
String ps2 = IOUtils.readStringAndClose(r, -1); String ps2 = IOUtils.readStringAndClose(r, -1);
assertEquals(ps, ps2); assertEquals(ps, ps2);
f.delete(); FileUtils.delete(fileName);
conn.close(); conn.close();
} }
......
...@@ -586,7 +586,7 @@ public class TestLinkedTable extends TestBase { ...@@ -586,7 +586,7 @@ public class TestLinkedTable extends TestBase {
} }
private void testLinkedTableInReadOnlyDb() throws SQLException { private void testLinkedTableInReadOnlyDb() throws SQLException {
if (config.memory || config.networked) { if (config.memory || config.networked || config.googleAppEngine) {
return; return;
} }
......
...@@ -8,7 +8,6 @@ package org.h2.test.db; ...@@ -8,7 +8,6 @@ package org.h2.test.db;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.CharArrayReader; import java.io.CharArrayReader;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
...@@ -27,6 +26,7 @@ import org.h2.constant.SysProperties; ...@@ -27,6 +26,7 @@ import org.h2.constant.SysProperties;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -114,10 +114,10 @@ public class TestLob extends TestBase { ...@@ -114,10 +114,10 @@ public class TestLob extends TestBase {
Connection conn = getConnection("lob"); Connection conn = getConnection("lob");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(data clob) as select space(100000) from dual"); stat.execute("create table test(data clob) as select space(100000) from dual");
assertEquals(1, new File(baseDir + "/lob.lobs.db").listFiles().length); assertEquals(1, FileUtils.listFiles(baseDir + "/lob.lobs.db").length);
stat.execute("delete from test"); stat.execute("delete from test");
conn.close(); conn.close();
assertEquals(0, new File(baseDir + "/lob.lobs.db").listFiles().length); assertEquals(0, FileUtils.listFiles(baseDir + "/lob.lobs.db").length);
} }
private void testLobServerMemory() throws SQLException { private void testLobServerMemory() throws SQLException {
......
...@@ -16,6 +16,7 @@ import java.util.ArrayList; ...@@ -16,6 +16,7 @@ import java.util.ArrayList;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.FileUtils;
/** /**
* Tests the database transaction log file. * Tests the database transaction log file.
...@@ -75,10 +76,10 @@ public class TestLogFile extends TestBase { ...@@ -75,10 +76,10 @@ public class TestLogFile extends TestBase {
deleteDb("logfile"); deleteDb("logfile");
} }
private void checkLogSize() { private void checkLogSize() throws SQLException {
for (String name : new File(getTestDir("")).list()) { for (String name : FileUtils.listFiles(getTestDir(""))) {
if (name.startsWith("logfile") && name.endsWith(".log.db")) { if (name.startsWith("logfile") && name.endsWith(".log.db")) {
long length = new File(name).length(); long length = FileUtils.length(name);
assertSmaller(length, MAX_LOG_SIZE * 1024 * 1024 * 2); assertSmaller(length, MAX_LOG_SIZE * 1024 * 1024 * 2);
} }
} }
......
...@@ -129,7 +129,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -129,7 +129,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
} }
private void testConcurrentOpen() throws Exception { private void testConcurrentOpen() throws Exception {
if (config.memory) { if (config.memory || config.googleAppEngine) {
return; return;
} }
deleteDb("multiConn"); deleteDb("multiConn");
......
...@@ -46,7 +46,7 @@ public class TestPowerOff extends TestBase { ...@@ -46,7 +46,7 @@ public class TestPowerOff extends TestBase {
if (config.memory || config.logMode == 0) { if (config.memory || config.logMode == 0) {
return; return;
} }
if (config.big) { if (config.big || config.googleAppEngine) {
dir = baseDir; dir = baseDir;
} else { } else {
dir = "memFS:"; dir = "memFS:";
......
...@@ -37,7 +37,9 @@ public class TestReadOnly extends TestBase { ...@@ -37,7 +37,9 @@ public class TestReadOnly extends TestBase {
return; return;
} }
testReadOnlyDbCreate(); testReadOnlyDbCreate();
testReadOnlyFiles(true); if (!config.googleAppEngine) {
testReadOnlyFiles(true);
}
if (!config.deleteIndex) { if (!config.deleteIndex) {
testReadOnlyFiles(false); testReadOnlyFiles(false);
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
package org.h2.test.jdbc; package org.h2.test.jdbc;
import java.io.File;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -15,6 +14,8 @@ import java.sql.Statement; ...@@ -15,6 +14,8 @@ import java.sql.Statement;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.jdbc.JdbcStatement; import org.h2.jdbc.JdbcStatement;
import org.h2.store.fs.FileObject;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
...@@ -33,7 +34,7 @@ public class TestStatement extends TestBase { ...@@ -33,7 +34,7 @@ public class TestStatement extends TestBase {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
public void test() throws SQLException { public void test() throws Exception {
deleteDb("statement"); deleteDb("statement");
conn = getConnection("statement"); conn = getConnection("statement");
testTraceError(); testTraceError();
...@@ -50,12 +51,13 @@ public class TestStatement extends TestBase { ...@@ -50,12 +51,13 @@ public class TestStatement extends TestBase {
deleteDb("statement"); deleteDb("statement");
} }
private void testTraceError() throws SQLException { private void testTraceError() throws Exception {
if (config.memory || config.networked || config.traceLevelFile != 0) { if (config.memory || config.networked || config.traceLevelFile != 0) {
return; return;
} }
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
File trace = new File(baseDir + "/statement.trace.db"); String fileName = baseDir + "/statement.trace.db";
FileObject trace = FileSystem.getInstance(fileName).openFileObject(fileName, "r");
stat.execute("DROP TABLE TEST IF EXISTS"); stat.execute("DROP TABLE TEST IF EXISTS");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
stat.execute("INSERT INTO TEST VALUES(1)"); stat.execute("INSERT INTO TEST VALUES(1)");
......
...@@ -129,7 +129,7 @@ public class TestFile extends TestBase implements DataHandler { ...@@ -129,7 +129,7 @@ public class TestFile extends TestBase implements DataHandler {
mem.close(); mem.close();
file.close(); file.close();
} }
FileUtils.delete("inmemory:test"); FileUtils.delete(prefix + "test");
FileUtils.delete("~/testFile"); FileUtils.delete("~/testFile");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论