diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2017-05-03 01:30:57 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2017-05-03 01:30:57 +0000 |
commit | 54972c4de58d2e92f818a8adb8f772513a590d19 (patch) | |
tree | b078aeb2842cad3a220e98d2d699f38a33c97016 /src/test/java/com | |
parent | 1f28e955e5dd655950ef8c3903439d70eb4d375d (diff) | |
download | jackcess-54972c4de58d2e92f818a8adb8f772513a590d19.tar.gz jackcess-54972c4de58d2e92f818a8adb8f772513a590d19.zip |
Cover the GENERIC_JET4 format in unit tests, thanks to Gord Thompson
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1093 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java/com')
4 files changed, 42 insertions, 3 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java index 6a6fd34..025e180 100644 --- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -742,7 +742,9 @@ public class DatabaseTest extends TestCase Arrays.asList("MSysObjects", "MSysQueries", "MSysACES", "MSysRelationships")); - if (fileFormat.ordinal() < FileFormat.V2003.ordinal()) { + if (fileFormat == FileFormat.GENERIC_JET4) { + assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); + } else if (fileFormat.ordinal() < FileFormat.V2003.ordinal()) { assertNotNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); sysTables.add("MSysAccessObjects"); } else { diff --git a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java index a5ec859..89ab4c4 100644 --- a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.UUID; import static com.healthmarketscience.jackcess.Database.*; -import static com.healthmarketscience.jackcess.DatabaseTest.*; import com.healthmarketscience.jackcess.impl.DatabaseImpl; import static com.healthmarketscience.jackcess.impl.JetFormatTest.*; import com.healthmarketscience.jackcess.impl.PropertyMapImpl; @@ -349,6 +348,12 @@ public class PropertiesTest extends TestCase public void testCreateDbProperties() throws Exception { for(FileFormat ff : SUPPORTED_FILEFORMATS) { + + if(ff == FileFormat.GENERIC_JET4) { + // weirdo format, no properties + continue; + } + File file = TestUtil.createTempFile(false); Database db = new DatabaseBuilder(file) .setFileFormat(ff) diff --git a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java index c6856bc..ab3a8d4 100644 --- a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java +++ b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java @@ -41,6 +41,7 @@ import com.healthmarketscience.jackcess.impl.ByteUtil; import com.healthmarketscience.jackcess.impl.DatabaseImpl; import com.healthmarketscience.jackcess.impl.IndexData; import com.healthmarketscience.jackcess.impl.IndexImpl; +import com.healthmarketscience.jackcess.impl.JetFormatTest; import com.healthmarketscience.jackcess.impl.JetFormatTest.TestDB; import com.healthmarketscience.jackcess.impl.RowIdImpl; import com.healthmarketscience.jackcess.impl.RowImpl; @@ -122,8 +123,32 @@ public class TestUtil throws Exception { FileChannel channel = (inMem ? MemFileChannel.newChannel() : null); + + if (fileFormat == FileFormat.GENERIC_JET4) { + // while we don't support creating GENERIC_JET4 as a jackcess feature, + // we do want to be able to test these types of dbs + InputStream inStream = null; + OutputStream outStream = null; + try { + inStream = TestUtil.class.getClassLoader() + .getResourceAsStream("emptyJet4.mdb"); + File f = createTempFile(keep); + if (channel != null) { + JetFormatTest.transferFrom(channel, inStream); + } else { + ByteUtil.copy(inStream, outStream = new FileOutputStream(f)); + outStream.close(); + } + return new DatabaseBuilder(f) + .setAutoSync(getTestAutoSync()).setChannel(channel).open(); + } finally { + ByteUtil.closeQuietly(inStream); + ByteUtil.closeQuietly(outStream); + } + } + return new DatabaseBuilder(createTempFile(keep)).setFileFormat(fileFormat) - .setAutoSync(getTestAutoSync()).setChannel(channel).create(); + .setAutoSync(getTestAutoSync()).setChannel(channel).create(); } diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java index 4efbd60..d2ebd41 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java @@ -1,6 +1,8 @@ package com.healthmarketscience.jackcess.impl; import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.nio.channels.FileChannel; import java.nio.channels.NonWritableChannelException; import java.util.ArrayList; @@ -263,4 +265,9 @@ public class JetFormatTest extends TestCase { } } + public static void transferFrom(FileChannel channel, InputStream in) + throws IOException + { + DatabaseImpl.transferFrom(channel, in); + } } |