diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-01-14 15:31:23 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-01-14 15:31:23 +0000 |
commit | 1ac730c1df7fc870ae1e3d379bbe924495caa5a1 (patch) | |
tree | ec6c2d65dfb1765c45d3df0c48f40b25f095ee03 | |
parent | cfffb8887d9f5c08d8e9279bd3e08bc7628345cb (diff) | |
download | jackcess-1ac730c1df7fc870ae1e3d379bbe924495caa5a1.tar.gz jackcess-1ac730c1df7fc870ae1e3d379bbe924495caa5a1.zip |
add openCopy utility method
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@213 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 5cabc9f..091daf4 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -69,15 +69,19 @@ public class DatabaseTest extends TestCase { } static Database create(boolean keep) throws Exception { - File tmp = File.createTempFile("databaseTest", ".mdb"); - if(keep) { - System.out.println("Created " + tmp); - } else { - tmp.deleteOnExit(); - } - return Database.create(tmp); + return Database.create(createTempFile(keep)); } + static Database openCopy(File srcFile) throws Exception { + return openCopy(srcFile, false); + } + + static Database openCopy(File srcFile, boolean keep) throws Exception { + File tmp = createTempFile(keep); + copyFile(srcFile, tmp); + return Database.open(tmp); + } + public void testInvalidTableDefs() throws Exception { Database db = create(); @@ -555,12 +559,7 @@ public class DatabaseTest extends TestCase { public void testFixedNumeric() throws Exception { - File srcFile = new File("test/data/fixedNumericTest.mdb"); - File dbFile = File.createTempFile("databaseTest", ".mdb"); - dbFile.deleteOnExit(); - copyFile(srcFile, dbFile); - - Database db = Database.open(dbFile); + Database db = openCopy(new File("test/data/fixedNumericTest.mdb")); Table t = db.getTable("test"); boolean first = true; @@ -668,12 +667,7 @@ public class DatabaseTest extends TestCase { public void testUsageMapPromotion() throws Exception { - File srcFile = new File("test/data/testPromotion.mdb"); - File dbFile = File.createTempFile("databaseTest", ".mdb"); - dbFile.deleteOnExit(); - copyFile(srcFile, dbFile); - - Database db = Database.open(dbFile); + Database db = openCopy(new File("test/data/testPromotion.mdb")); Table t = db.getTable("jobDB1"); String lval = createString(255); // "--255 chars long text--"; @@ -931,6 +925,16 @@ public class DatabaseTest extends TestCase { } } + static File createTempFile(boolean keep) throws Exception { + File tmp = File.createTempFile("databaseTest", ".mdb"); + if(keep) { + System.out.println("Created " + tmp); + } else { + tmp.deleteOnExit(); + } + return tmp; + } + static byte[] toByteArray(File file) throws IOException { |