aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/changes/changes.xml4
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java2
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java4
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java7
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/TestUtil.java27
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java7
-rw-r--r--src/test/resources/emptyJet4.mdbbin0 -> 77824 bytes
7 files changed, 47 insertions, 4 deletions
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
new file mode 100644
index 0000000..7367d01
--- /dev/null
+++ b/src/test/resources/emptyJet4.mdb
Binary files differ