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 | |
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
-rw-r--r-- | pom.xml | 9 | ||||
-rw-r--r-- | src/changes/changes.xml | 4 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java | 2 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java | 4 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java | 7 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/TestUtil.java | 27 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java | 7 | ||||
-rw-r--r-- | src/test/resources/emptyJet4.mdb | bin | 0 -> 77824 bytes |
8 files changed, 48 insertions, 12 deletions
@@ -128,10 +128,6 @@ <value>log4j_test.properties</value> </property> <property> - <name>com.healthmarketscience.jackcess.bigIndex</name> - <value>${jackcess.bigIndex}</value> - </property> - <property> <name>com.healthmarketscience.jackcess.testFormats</name> <value>${jackcess.testFormats}</value> </property> @@ -247,6 +243,7 @@ <issueLinkTemplatePerSystem> <SourceForge2Features>http://sourceforge.net/p/jackcess/feature-requests/%ISSUE%</SourceForge2Features> <SourceForge2Patches>http://sourceforge.net/p/jackcess/patches/%ISSUE%</SourceForge2Patches> + <GitHubPullRequests>https://github.com/jahlborn/jackcess/pull/%ISSUE%</GitHubPullRequests> </issueLinkTemplatePerSystem> </configuration> </plugin> @@ -312,8 +309,4 @@ <url>scp://shell.sourceforge.net/home/project-web/jackcess/htdocs</url> </site> </distributionManagement> - <properties> - <jackcess.bigIndex>true</jackcess.bigIndex> - <jackcess.testFormats>V1997,V2000,V2003,V2007,V2010</jackcess.testFormats> - </properties> </project> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a172b92..8b237bf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -10,6 +10,10 @@ lookups can now be done with multi-column indexes using only some of the columns in the index. </action> + <action dev="jahlborn" type="update" system="GitHubPullRequests" + issue="2"> + Cover the GENERIC_JET4 format in unit tests, thanks to Gord Thompson. + </action> </release> <release version="2.1.6" date="2016-11-29"> <action dev="jahlborn" type="update" system="SourceForge2Features" diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java index ac253fb..17741a5 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java @@ -1951,7 +1951,7 @@ public class DatabaseImpl implements Database * Copies the given InputStream to the given channel using the most * efficient means possible. */ - private static void transferFrom(FileChannel channel, InputStream in) + static void transferFrom(FileChannel channel, InputStream in) throws IOException { ReadableByteChannel readChannel = Channels.newChannel(in); 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); + } } diff --git a/src/test/resources/emptyJet4.mdb b/src/test/resources/emptyJet4.mdb Binary files differnew file mode 100644 index 0000000..7367d01 --- /dev/null +++ b/src/test/resources/emptyJet4.mdb |