Browse Source

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
tags/jackcess-2.1.7
James Ahlborn 7 years ago
parent
commit
54972c4de5

+ 1
- 8
pom.xml View File

@@ -127,10 +127,6 @@
<name>log4j.configuration</name>
<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>
@@ -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>

+ 4
- 0
src/changes/changes.xml View File

@@ -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"

+ 1
- 1
src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java View File

@@ -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);

+ 3
- 1
src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java View File

@@ -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 {

+ 6
- 1
src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java View File

@@ -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)

+ 26
- 1
src/test/java/com/healthmarketscience/jackcess/TestUtil.java View File

@@ -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();
}



+ 7
- 0
src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java View File

@@ -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);
}
}

BIN
src/test/resources/emptyJet4.mdb View File


Loading…
Cancel
Save