aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2015-04-27 03:21:47 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2015-04-27 03:21:47 +0000
commitee49db8317232aff01613146e280ad989d4e34bd (patch)
tree746da066fbd3368ab703a0adef85dc1ef0100f04 /src/test/java
parent0e1f59df4df6871da91be0a554e46931a53f363f (diff)
downloadjackcess-ee49db8317232aff01613146e280ad989d4e34bd.tar.gz
jackcess-ee49db8317232aff01613146e280ad989d4e34bd.zip
more unit test speedups using in mem dbs
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@940 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/BigIndexTest.java6
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/CursorTest.java8
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java17
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/TestUtil.java2
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java8
5 files changed, 21 insertions, 20 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/BigIndexTest.java b/src/test/java/com/healthmarketscience/jackcess/BigIndexTest.java
index 0c5a222..004b3b2 100644
--- a/src/test/java/com/healthmarketscience/jackcess/BigIndexTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/BigIndexTest.java
@@ -40,7 +40,7 @@ public class BigIndexTest extends TestCase {
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.COMP_INDEX, true)) {
// this file has an index with "compressed" entries and node pages
- Database db = open(testDB);
+ Database db = openMem(testDB);
TableImpl t = (TableImpl)db.getTable("Table1");
IndexImpl index = t.getIndex("CD_AGENTE");
assertFalse(index.isInitialized());
@@ -54,7 +54,7 @@ public class BigIndexTest extends TestCase {
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.BIG_INDEX)) {
// this file has an index with "compressed" entries and node pages
- Database db = open(testDB);
+ Database db = openMem(testDB);
TableImpl t = (TableImpl)db.getTable("Table1");
IndexImpl index = t.getIndex("col1");
assertFalse(index.isInitialized());
@@ -68,7 +68,7 @@ public class BigIndexTest extends TestCase {
String extraText = " some random text to fill out the index and make it fill up pages with lots of extra bytes so i will keep typing until i think that i probably have enough text in the index entry so that i do not need to add as many entries in order";
// copy to temp file and attempt to edit
- db = openCopy(testDB);
+ db = openMem(testDB);
t = (TableImpl)db.getTable("Table1");
index = t.getIndex("col1");
diff --git a/src/test/java/com/healthmarketscience/jackcess/CursorTest.java b/src/test/java/com/healthmarketscience/jackcess/CursorTest.java
index 4ebe5f6..fca26fc 100644
--- a/src/test/java/com/healthmarketscience/jackcess/CursorTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/CursorTest.java
@@ -114,7 +114,7 @@ public class CursorTest extends TestCase {
static Database createTestIndexTable(final TestDB indexCursorDB)
throws Exception
{
- Database db = openCopy(indexCursorDB);
+ Database db = openMem(indexCursorDB);
Table table = db.getTable("test");
@@ -160,7 +160,7 @@ public class CursorTest extends TestCase {
static Database createDupeTestTable(final TestDB indexCursorDB)
throws Exception
{
- Database db = openCopy(indexCursorDB);
+ Database db = openMem(indexCursorDB);
Table table = db.getTable("test");
@@ -1096,7 +1096,7 @@ public class CursorTest extends TestCase {
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {
- Database db = openCopy(testDB);
+ Database db = openMem(testDB);
Table t1 = db.getTable("Table1");
Index idx = t1.getIndex("Table2Table1");
IndexCursor cursor = CursorBuilder.createCursor(idx);
@@ -1150,7 +1150,7 @@ public class CursorTest extends TestCase {
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {
- Database db = openCopy(testDB);
+ Database db = openMem(testDB);
Table t1 = db.getTable("Table1");
Cursor cursor = CursorBuilder.createCursor(t1);
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 4a8639a..6deb3b9 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -58,7 +58,6 @@ public class DatabaseTest extends TestCase
super(name);
}
-
public void testInvalidTableDefs() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
@@ -190,7 +189,7 @@ public class DatabaseTest extends TestCase
// make sure correct row is deleted
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
createTestTable(db);
Map<String,Object> row1 = createTestRowMap("Tim1");
Map<String,Object> row2 = createTestRowMap("Tim2");
@@ -214,8 +213,10 @@ public class DatabaseTest extends TestCase
assertEquals("Tim3", outRow.get("A"));
assertRowCount(2, table);
+ db.close();
+
// test multi row delete/add
- db = create(fileFormat);
+ db = createMem(fileFormat);
createTestTable(db);
Object[] row = createTestRow();
table = db.getTable("Test");
@@ -258,7 +259,7 @@ public class DatabaseTest extends TestCase
// make sure correct row is deleted
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
createTestTable(db);
Table table = db.getTable("Test");
for(int i = 0; i < 10; ++i) {
@@ -552,7 +553,7 @@ public class DatabaseTest extends TestCase
public void testUsageMapPromotion() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.PROMOTION)) {
- Database db = openCopy(testDB);
+ Database db = openMem(testDB);
Table t = db.getTable("jobDB1");
assertTrue(((TableImpl)t).getOwnedPagesCursor().getUsageMap().toString()
@@ -620,7 +621,7 @@ public class DatabaseTest extends TestCase
public void testAutoNumber() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
Table table = new TableBuilder("test")
.addColumn(new ColumnBuilder("a", DataType.LONG)
@@ -636,7 +637,7 @@ public class DatabaseTest extends TestCase
public void testAutoNumberPK() throws Exception {
for (final TestDB testDB : SUPPORTED_DBS_TEST) {
- Database db = openCopy(testDB);
+ Database db = openMem(testDB);
Table table = db.getTable("Table3");
@@ -696,7 +697,7 @@ public class DatabaseTest extends TestCase
public void testWriteAndReadDate() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
Table table = new TableBuilder("test")
.addColumn(new ColumnBuilder("name", DataType.TEXT))
diff --git a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
index 9935303..f7a24f0 100644
--- a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
+++ b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
@@ -84,7 +84,7 @@ public class TestUtil
public static Database open(FileFormat fileFormat, File file, boolean inMem)
throws Exception
{
- FileChannel channel = (inMem ? MemFileChannel.newChannel(file, "r")
+ FileChannel channel = (inMem ? MemFileChannel.newChannel(file, "rw")
: null);
final Database db = new DatabaseBuilder(file).setReadOnly(true)
.setAutoSync(getTestAutoSync()).setChannel(channel).open();
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
index 0fccdff..96418e6 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
@@ -50,7 +50,7 @@ public class LongValueTest extends TestCase
public void testReadLongValue() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.TEST2, true)) {
- Database db = open(testDB);
+ Database db = openMem(testDB);
Table table = db.getTable("MSP_PROJECTS");
Row row = table.getNextRow();
assertEquals("Jon Iles this is a a vawesrasoih aksdkl fas dlkjflkasjd flkjaslkdjflkajlksj dfl lkasjdf lkjaskldfj lkas dlk lkjsjdfkl; aslkdf lkasjkldjf lka skldf lka sdkjfl;kasjd falksjdfljaslkdjf laskjdfk jalskjd flkj aslkdjflkjkjasljdflkjas jf;lkasjd fjkas dasdf asd fasdf asdf asdmhf lksaiyudfoi jasodfj902384jsdf9 aw90se fisajldkfj lkasj dlkfslkd jflksjadf as", row.get("PROJ_PROP_AUTHOR"));
@@ -69,7 +69,7 @@ public class LongValueTest extends TestCase
public void testWriteLongValue() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
Table table =
new TableBuilder("test")
@@ -120,7 +120,7 @@ public class LongValueTest extends TestCase
public void testManyMemos() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
final int numColumns = 126;
TableBuilder bigTableBuilder = new TableBuilder("test");
@@ -190,7 +190,7 @@ public class LongValueTest extends TestCase
public void testLongValueAsMiddleColumn() throws Exception
{
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
- Database db = create(fileFormat);
+ Database db = createMem(fileFormat);
Table newTable = new TableBuilder("NewTable")
.addColumn(new ColumnBuilder("a").setSQLType(Types.INTEGER))
.addColumn(new ColumnBuilder("b").setSQLType(Types.LONGVARCHAR))