summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2012-09-23 15:39:02 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2012-09-23 15:39:02 +0000
commitfe78870364c29c07a8f4269b9c38ccd244665ed0 (patch)
tree6b2554d5e008e0f99e2337aaa393641cbc465214 /test
parent3e547e1d59bd61e8d1ad9bab945af5d0eafba061 (diff)
downloadjackcess-fe78870364c29c07a8f4269b9c38ccd244665ed0.tar.gz
jackcess-fe78870364c29c07a8f4269b9c38ccd244665ed0.zip
Added DatabaseBuilder in for more convenient and flexible Database open/create
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@641 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/CodecHandlerTest.java5
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java11
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java1
3 files changed, 10 insertions, 7 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/CodecHandlerTest.java b/test/src/java/com/healthmarketscience/jackcess/CodecHandlerTest.java
index c525efa..edcbf09 100644
--- a/test/src/java/com/healthmarketscience/jackcess/CodecHandlerTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/CodecHandlerTest.java
@@ -82,8 +82,9 @@ public class CodecHandlerTest extends TestCase
// apply encoding to file
encodeFile(dbFile, pageSize, simple);
- db = Database.open(dbFile, false, Database.DEFAULT_AUTO_SYNC, null, null,
- (simple ? SIMPLE_PROVIDER : FULL_PROVIDER));
+ db = new DatabaseBuilder(dbFile)
+ .setCodecProvider(simple ? SIMPLE_PROVIDER : FULL_PROVIDER)
+ .open();
Table t1 = new TableBuilder("test1")
.addColumn(new ColumnBuilder("id", DataType.LONG).setAutoNumber(true))
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
index efda478..51c7efd 100644
--- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -78,7 +78,8 @@ public class DatabaseTest extends TestCase {
public static Database open(FileFormat fileFormat, File file)
throws Exception
{
- final Database db = Database.open(file, true, _autoSync);
+ final Database db = new DatabaseBuilder(file).setReadOnly(true)
+ .setAutoSync(_autoSync).open();
assertEquals("Wrong JetFormat.", fileFormat.getJetFormat(),
db.getFormat());
assertEquals("Wrong FileFormat.", fileFormat, db.getFileFormat());
@@ -96,7 +97,8 @@ public class DatabaseTest extends TestCase {
public static Database create(FileFormat fileFormat, boolean keep)
throws Exception
{
- return Database.create(fileFormat, createTempFile(keep), _autoSync);
+ return new DatabaseBuilder(createTempFile(keep)).setFileFormat(fileFormat)
+ .setAutoSync(_autoSync).create();
}
@@ -122,7 +124,7 @@ public class DatabaseTest extends TestCase {
{
File tmp = createTempFile(keep);
copyFile(file, tmp);
- Database db = Database.open(tmp, false, _autoSync);
+ Database db = new DatabaseBuilder(tmp).setAutoSync(_autoSync).open();
assertEquals("Wrong JetFormat.", fileFormat.getJetFormat(),
db.getFormat());
assertEquals("Wrong FileFormat.", fileFormat, db.getFileFormat());
@@ -547,7 +549,8 @@ public class DatabaseTest extends TestCase {
File bogusFile = new File("fooby-dooby.mdb");
assertTrue(!bogusFile.exists());
try {
- Database.open(bogusFile, true, _autoSync);
+ new DatabaseBuilder(bogusFile).setReadOnly(true).
+ setAutoSync(_autoSync).open();
fail("FileNotFoundException should have been thrown");
} catch(FileNotFoundException e) {
}
diff --git a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java
index c5cacfb..9c75b6d 100644
--- a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java
@@ -139,7 +139,6 @@ public class JetFormatTest extends TestCase {
// verify that the db is the file format expected
try {
-// System.out.println("FOO checking " + testFile);
Database db = Database.open(testFile, true);
FileFormat dbFileFormat = db.getFileFormat();
db.close();