From: James Ahlborn Date: Thu, 13 Mar 2008 03:28:03 +0000 (+0000) Subject: use readOnly dbs for unit tests X-Git-Tag: rel_1_1_13~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d4113e1b68d70f20ab1ef56669d28554213e5e22;p=jackcess.git use readOnly dbs for unit tests git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@268 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index faf1d07..d77f54a 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -64,7 +64,11 @@ public class DatabaseTest extends TestCase { } static Database open() throws Exception { - return Database.open(new File("test/data/test.mdb")); + return open(new File("test/data/test.mdb")); + } + + static Database open(File file) throws Exception { + return Database.open(file, true, Database.DEFAULT_AUTO_SYNC); } static Database create() throws Exception { @@ -143,7 +147,7 @@ public class DatabaseTest extends TestCase { } public void testReadDeletedRows() throws Exception { - Table table = Database.open(new File("test/data/delTest.mdb")).getTable("Table"); + Table table = open(new File("test/data/delTest.mdb")).getTable("Table"); int rows = 0; while (table.getNextRow() != null) { rows++; @@ -332,7 +336,7 @@ public class DatabaseTest extends TestCase { public void testReadLongValue() throws Exception { - Database db = Database.open(new File("test/data/test2.mdb")); + Database db = open(new File("test/data/test2.mdb")); Table table = db.getTable("MSP_PROJECTS"); Map 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")); @@ -398,7 +402,7 @@ public class DatabaseTest extends TestCase { File bogusFile = new File("fooby-dooby.mdb"); assertTrue(!bogusFile.exists()); try { - Database db = Database.open(bogusFile); + Database db = open(bogusFile); fail("FileNotFoundException should have been thrown"); } catch(FileNotFoundException e) { } @@ -406,7 +410,7 @@ public class DatabaseTest extends TestCase { } public void testReadWithDeletedCols() throws Exception { - Table table = Database.open(new File("test/data/delColTest.mdb")).getTable("Table1"); + Table table = open(new File("test/data/delColTest.mdb")).getTable("Table1"); Map expectedRow0 = new LinkedHashMap(); expectedRow0.put("id", 0); @@ -624,7 +628,7 @@ public class DatabaseTest extends TestCase { public void testOverflow() throws Exception { - Database mdb = Database.open(new File("test/data/overflowTest.mdb")); + Database mdb = open(new File("test/data/overflowTest.mdb")); Table table = mdb.getTable("Table1"); // 7 rows, 3 and 5 are overflow diff --git a/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java b/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java index c057656..f54109e 100644 --- a/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java @@ -67,7 +67,7 @@ public class IndexCodesTest extends TestCase { public void testIndexCodes() throws Exception { - Database db = Database.open(new File("test/data/testIndexCodes.mdb")); + Database db = open(new File("test/data/testIndexCodes.mdb")); for(Table t : db) { for(Index index : t.getIndexes()) { @@ -182,10 +182,10 @@ public class IndexCodesTest extends TestCase { public void x_testReadIsoMdb() throws Exception { -// Database db = Database.open(new File("/tmp/test_ind.mdb")); -// Database db = Database.open(new File("/tmp/test_ind2.mdb")); - Database db = Database.open(new File("/tmp/test_ind3.mdb")); -// Database db = Database.open(new File("/tmp/test_ind4.mdb")); +// Database db = open(new File("/tmp/test_ind.mdb")); +// Database db = open(new File("/tmp/test_ind2.mdb")); + Database db = open(new File("/tmp/test_ind3.mdb")); +// Database db = open(new File("/tmp/test_ind4.mdb")); Table t = db.getTable("Table1"); Index index = t.getIndex("B"); @@ -204,11 +204,11 @@ public class IndexCodesTest extends TestCase { public void x_testReverseIsoMdb() throws Exception { -// Database db = Database.open(new File("/tmp/test_ind.mdb")); - Database db = Database.open(new File("/tmp/test_ind2.mdb")); -// Database db = Database.open(new File("/tmp/databaseTest14366_ind.mdb")); -// Database db = Database.open(new File("/tmp/databaseTest56165_ind.mdb")); -// Database db = Database.open(new File("/tmp/databaseTest53970_ind.mdb")); +// Database db = open(new File("/tmp/test_ind.mdb")); + Database db = open(new File("/tmp/test_ind2.mdb")); +// Database db = open(new File("/tmp/databaseTest14366_ind.mdb")); +// Database db = open(new File("/tmp/databaseTest56165_ind.mdb")); +// Database db = open(new File("/tmp/databaseTest53970_ind.mdb")); Table t = db.getTable("Table1"); Index index = t.getIndex("B"); diff --git a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java index bb3b7f1..4b21af3 100644 --- a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java @@ -102,7 +102,7 @@ public class IndexTest extends TestCase { public void testIndexSlots() throws Exception { - Database mdb = Database.open(new File("test/data/indexTest.mdb")); + Database mdb = open(new File("test/data/indexTest.mdb")); Table table = mdb.getTable("Table1"); for(Index idx : table.getIndexes()) { @@ -141,7 +141,7 @@ public class IndexTest extends TestCase { { // this file has an index with "compressed" entries and node pages File origFile = new File("test/data/compIndexTest.mdb"); - Database db = Database.open(origFile); + Database db = open(origFile); Table t = db.getTable("Table1"); Index index = t.getIndexes().get(0); assertFalse(index.isInitialized());