use of org.h2.test.unit.TestFileSystem in project h2database by h2database.
the class TestAll method testUnit.
private void testUnit() {
// mv store
addTest(new TestCacheConcurrentLIRS());
addTest(new TestCacheLIRS());
addTest(new TestCacheLongKeyLIRS());
addTest(new TestConcurrentLinkedList());
addTest(new TestDataUtils());
addTest(new TestFreeSpace());
addTest(new TestKillProcessWhileWriting());
addTest(new TestMVRTree());
addTest(new TestMVStore());
addTest(new TestMVStoreBenchmark());
addTest(new TestMVStoreStopCompact());
addTest(new TestMVStoreTool());
addTest(new TestMVTableEngine());
addTest(new TestObjectDataType());
addTest(new TestRandomMapOps());
addTest(new TestSpinLock());
addTest(new TestStreamStore());
addTest(new TestTransactionStore());
// unit
addTest(new TestAnsCompression());
addTest(new TestAutoReconnect());
addTest(new TestBinaryArithmeticStream());
addTest(new TestBitStream());
addTest(new TestBnf());
addTest(new TestCache());
addTest(new TestCharsetCollator());
addTest(new TestClearReferences());
addTest(new TestCollation());
addTest(new TestCompress());
addTest(new TestConnectionInfo());
addTest(new TestDataPage());
addTest(new TestDateIso8601());
addTest(new TestExit());
addTest(new TestFile());
addTest(new TestFileLock());
addTest(new TestFtp());
addTest(new TestIntArray());
addTest(new TestIntIntHashMap());
addTest(new TestIntPerfectHash());
addTest(new TestJmx());
addTest(new TestMathUtils());
addTest(new TestMode());
addTest(new TestModifyOnWrite());
addTest(new TestOldVersion());
addTest(new TestObjectDeserialization());
addTest(new TestMultiThreadedKernel());
addTest(new TestOverflow());
addTest(new TestPageStore());
addTest(new TestPageStoreCoverage());
addTest(new TestPerfectHash());
addTest(new TestPgServer());
addTest(new TestReader());
addTest(new TestRecovery());
addTest(new TestScriptReader());
addTest(new RecoverLobTest());
addTest(createTest("org.h2.test.unit.TestServlet"));
addTest(new TestSecurity());
addTest(new TestShell());
addTest(new TestSort());
addTest(new TestStreams());
addTest(new TestStringUtils());
addTest(new TestTimeStampWithTimeZone());
addTest(new TestTraceSystem());
addTest(new TestUpgrade());
addTest(new TestUsingIndex());
addTest(new TestUtils());
addTest(new TestValue());
addTest(new TestValueHashMap());
addTest(new TestWeb());
runAddedTests();
// serial
addTest(new TestDate());
addTest(new TestDateTimeUtils());
addTest(new TestCluster());
addTest(new TestConcurrent());
addTest(new TestFileLockSerialized());
addTest(new TestFileLockProcess());
addTest(new TestFileSystem());
addTest(new TestNetUtils());
addTest(new TestPattern());
addTest(new TestTools());
addTest(new TestSampleApps());
addTest(new TestStringCache());
addTest(new TestValueMemory());
runAddedTests(1);
}
use of org.h2.test.unit.TestFileSystem in project h2database by h2database.
the class TestReorderWrites method testFileSystem.
private void testFileSystem() throws IOException {
FilePathReorderWrites fs = FilePathReorderWrites.register();
// disable this for now, still bug(s) in our code
FilePathReorderWrites.setPartialWrites(false);
String fileName = "reorder:memFS:test";
final ByteBuffer empty = ByteBuffer.allocate(1024);
Random r = new Random(1);
long minSize = Long.MAX_VALUE;
long maxSize = 0;
int minWritten = Integer.MAX_VALUE;
int maxWritten = 0;
for (int i = 0; i < 100; i++) {
fs.setPowerOffCountdown(100, i);
FileUtils.delete(fileName);
FileChannel fc = FilePath.get(fileName).open("rw");
for (int j = 0; j < 20; j++) {
fc.write(empty, j * 1024);
empty.flip();
}
fs.setPowerOffCountdown(4 + r.nextInt(20), i);
int lastWritten = 0;
int lastTruncated = 0;
for (int j = 20; j >= 0; j--) {
try {
byte[] bytes = new byte[1024];
Arrays.fill(bytes, (byte) j);
ByteBuffer data = ByteBuffer.wrap(bytes);
fc.write(data, 0);
lastWritten = j;
} catch (IOException e) {
// expected
break;
}
try {
fc.truncate(j * 1024);
lastTruncated = j * 1024;
} catch (IOException e) {
// expected
break;
}
}
if (lastTruncated <= 0 || lastWritten <= 0) {
fail();
}
fs.setPowerOffCountdown(100, 0);
fc = FilePath.get(fileName).open("rw");
ByteBuffer data = ByteBuffer.allocate(1024);
fc.read(data, 0);
data.flip();
int got = data.get();
long size = fc.size();
minSize = Math.min(minSize, size);
maxSize = Math.max(minSize, size);
minWritten = Math.min(minWritten, got);
maxWritten = Math.max(maxWritten, got);
}
assertTrue(minSize < maxSize);
assertTrue(minWritten < maxWritten);
// release the static data this test generates
FileUtils.delete(fileName);
}
use of org.h2.test.unit.TestFileSystem in project h2database by h2database.
the class TestFileSystem method test.
@Override
public void test() throws Exception {
testFileSystem(getBaseDir() + "/fs");
testAbsoluteRelative();
testDirectories(getBaseDir());
testMoveTo(getBaseDir());
testUnsupportedFeatures(getBaseDir());
FilePathZip2.register();
FilePath.register(new FilePathCache());
FilePathRec.register();
testZipFileSystem("zip:");
testZipFileSystem("cache:zip:");
testZipFileSystem("zip2:");
testZipFileSystem("cache:zip2:");
testMemFsDir();
testClasspath();
FilePathDebug.register().setTrace(true);
FilePathEncrypt.register();
testSimpleExpandTruncateSize();
testSplitDatabaseInZip();
testDatabaseInMemFileSys();
testDatabaseInJar();
// set default part size to 1 << 10
String f = "split:10:" + getBaseDir() + "/fs";
FileUtils.toRealPath(f);
testFileSystem(getBaseDir() + "/fs");
testFileSystem("memFS:");
testFileSystem("memLZF:");
testFileSystem("nioMemFS:");
testFileSystem("nioMemLZF:1:");
// 12% compressLaterCache
testFileSystem("nioMemLZF:12:");
testFileSystem("rec:memFS:");
testUserHome();
try {
testFileSystem("nio:" + getBaseDir() + "/fs");
testFileSystem("cache:nio:" + getBaseDir() + "/fs");
testFileSystem("nioMapped:" + getBaseDir() + "/fs");
testFileSystem("encrypt:0007:" + getBaseDir() + "/fs");
testFileSystem("cache:encrypt:0007:" + getBaseDir() + "/fs");
if (!config.splitFileSystem) {
testFileSystem("split:" + getBaseDir() + "/fs");
testFileSystem("split:nioMapped:" + getBaseDir() + "/fs");
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} catch (Error e) {
e.printStackTrace();
throw e;
} finally {
FileUtils.delete(getBaseDir() + "/fs");
}
}
Aggregations