aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com/healthmarketscience/jackcess
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-11-29 03:44:56 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-11-29 03:44:56 +0000
commit6626d6b28f21d550e5bde637ed3b9cea1806ab40 (patch)
tree198b2ce6cc87e8a164762c6265788909388f1f49 /src/test/java/com/healthmarketscience/jackcess
parent322126f37d55e77c83ba233c17945acbbf2d4686 (diff)
downloadjackcess-6626d6b28f21d550e5bde637ed3b9cea1806ab40.tar.gz
jackcess-6626d6b28f21d550e5bde637ed3b9cea1806ab40.zip
add support for Path
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jdk8@1233 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java/com/healthmarketscience/jackcess')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java59
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/TestUtil.java2
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java33
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/util/CustomLinkResolverTest.java12
4 files changed, 54 insertions, 52 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 025e180..2ce343b 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -51,7 +51,7 @@ import static com.healthmarketscience.jackcess.TestUtil.*;
/**
* @author Tim McCune
*/
-public class DatabaseTest extends TestCase
+public class DatabaseTest extends TestCase
{
public DatabaseTest(String name) throws Exception {
super(name);
@@ -114,7 +114,7 @@ public class DatabaseTest extends TestCase
db.close();
}
}
-
+
public void testReadDeletedRows() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.DEL, true)) {
Table table = open(testDB).getTable("Table");
@@ -122,11 +122,11 @@ public class DatabaseTest extends TestCase
while (table.getNextRow() != null) {
rows++;
}
- assertEquals(2, rows);
+ assertEquals(2, rows);
table.getDatabase().close();
}
}
-
+
public void testGetColumns() throws Exception {
for (final TestDB testDB : SUPPORTED_DBS_TEST_FOR_READ) {
@@ -143,9 +143,9 @@ public class DatabaseTest extends TestCase
checkColumn(columns, 8, "I", DataType.BOOLEAN);
}
}
-
+
private static void checkColumn(
- List<? extends Column> columns, int columnNumber, String name,
+ List<? extends Column> columns, int columnNumber, String name,
DataType dataType)
throws Exception
{
@@ -153,7 +153,7 @@ public class DatabaseTest extends TestCase
assertEquals(name, column.getName());
assertEquals(dataType, column.getType());
}
-
+
public void testGetNextRow() throws Exception {
for (final TestDB testDB : SUPPORTED_DBS_TEST_FOR_READ) {
final Database db = open(testDB);
@@ -183,7 +183,7 @@ public class DatabaseTest extends TestCase
db.close();
}
}
-
+
public void testDeleteCurrentRow() throws Exception {
// make sure correct row is deleted
@@ -269,7 +269,7 @@ public class DatabaseTest extends TestCase
table.reset();
List<Row> rows = RowFilterTest.toList(table);
-
+
Row r1 = rows.remove(7);
Row r2 = rows.remove(3);
assertEquals(8, rows.size());
@@ -282,10 +282,10 @@ public class DatabaseTest extends TestCase
table.deleteRow(r2);
table.deleteRow(r1);
- assertTable(rows, table);
+ assertTable(rows, table);
}
}
-
+
public void testMissingFile() throws Exception {
File bogusFile = new File("fooby-dooby.mdb");
assertTrue(!bogusFile.exists());
@@ -326,7 +326,7 @@ public class DatabaseTest extends TestCase
}
rowNum++;
}
-
+
table.getDatabase().close();
}
}
@@ -508,7 +508,7 @@ public class DatabaseTest extends TestCase
db.close();
}
- }
+ }
public void testMultiPageTableDef() throws Exception
{
@@ -580,7 +580,7 @@ public class DatabaseTest extends TestCase
db.close();
}
- }
+ }
public void testLargeTableDef() throws Exception {
@@ -685,8 +685,8 @@ public class DatabaseTest extends TestCase
TimeZone tz = TimeZone.getTimeZone("America/New_York");
SimpleDateFormat sdf = DatabaseBuilder.createDateFormat("yyyy-MM-dd");
sdf.getCalendar().setTimeZone(tz);
-
- List<String> dates = Arrays.asList("1582-10-15", "1582-10-14",
+
+ List<String> dates = Arrays.asList("1582-10-15", "1582-10-14",
"1492-01-10", "1392-01-10");
@@ -703,7 +703,7 @@ public class DatabaseTest extends TestCase
Date d = sdf.parse(dateStr);
table.addRow("row " + dateStr, d);
}
-
+
List<String> foundDates = new ArrayList<String>();
for(Row row : table) {
foundDates.add(sdf.format(row.getDate("date")));
@@ -741,7 +741,7 @@ public class DatabaseTest extends TestCase
sysTables.addAll(
Arrays.asList("MSysObjects", "MSysQueries", "MSysACES",
"MSysRelationships"));
-
+
if (fileFormat == FileFormat.GENERIC_JET4) {
assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects"));
} else if (fileFormat.ordinal() < FileFormat.V2003.ordinal()) {
@@ -766,11 +766,11 @@ public class DatabaseTest extends TestCase
if(fileFormat.ordinal() >= FileFormat.V2010.ordinal()) {
sysTables.add("f_12D7448B56564D8AAE333BCC9B3718E5_Data");
sysTables.add("MSysResources");
- }
+ }
}
assertEquals(sysTables, db.getSystemTableNames());
-
+
assertNotNull(db.getSystemTable("MSysObjects"));
assertNotNull(db.getSystemTable("MSysQueries"));
assertNotNull(db.getSystemTable("MSysACES"));
@@ -782,7 +782,7 @@ public class DatabaseTest extends TestCase
assertEquals("MSysObjects", tmd.getName());
assertFalse(tmd.isLinked());
assertTrue(tmd.isSystem());
-
+
db.close();
}
}
@@ -839,7 +839,7 @@ public class DatabaseTest extends TestCase
"RawData[(12) FF FE 6F 74 68 65 72 20 64 61 74 61]",
null);
List<String> fixVals = Arrays.asList("RawData[(4) 37 00 00 00]",
- "RawData[(4) F3 FF FF FF]",
+ "RawData[(4) F3 FF FF FF]",
"RawData[(4) 02 00 00 00]");
int idx = 0;
@@ -891,7 +891,8 @@ public class DatabaseTest extends TestCase
Database linkeeDb = db.getLinkedDatabases().get(linkeeDbName);
assertNotNull(linkeeDb);
assertEquals(linkeeFile, linkeeDb.getFile());
-
+ assertEquals("linkeeTest.accdb", ((DatabaseImpl)linkeeDb).getName());
+
List<? extends Map<String, Object>> expectedRows =
createExpectedTable(
createExpectedRow(
@@ -900,7 +901,7 @@ public class DatabaseTest extends TestCase
assertTable(expectedRows, t2);
- db.createLinkedTable("FooTable", linkeeDbName, "Table2");
+ db.createLinkedTable("FooTable", linkeeDbName, "Table2");
tmd = db.getTableMetaData("FooTable");
assertEquals("FooTable", tmd.getName());
@@ -929,7 +930,7 @@ public class DatabaseTest extends TestCase
assertNull(tmd.getLinkedDbName());
Table t1 = tmd.open(db);
-
+
assertFalse(db.isLinkedTable(null));
assertTrue(db.isLinkedTable(t2));
assertTrue(db.isLinkedTable(t3));
@@ -941,21 +942,21 @@ public class DatabaseTest extends TestCase
assertTrue(tables.contains(t2));
assertTrue(tables.contains(t3));
assertFalse(tables.contains(((DatabaseImpl)db).getSystemCatalog()));
-
+
tables = getTables(db.newIterable().setIncludeNormalTables(false));
assertEquals(2, tables.size());
assertFalse(tables.contains(t1));
assertTrue(tables.contains(t2));
assertTrue(tables.contains(t3));
assertFalse(tables.contains(((DatabaseImpl)db).getSystemCatalog()));
-
+
tables = getTables(db.newIterable().withLocalUserTablesOnly());
assertEquals(1, tables.size());
assertTrue(tables.contains(t1));
assertFalse(tables.contains(t2));
assertFalse(tables.contains(t3));
assertFalse(tables.contains(((DatabaseImpl)db).getSystemCatalog()));
-
+
tables = getTables(db.newIterable().withSystemTablesOnly());
assertTrue(tables.size() > 5);
assertFalse(tables.contains(t1));
@@ -975,7 +976,7 @@ public class DatabaseTest extends TestCase
}
return tableList;
}
-
+
public void testTimeZone() throws Exception
{
TimeZone tz = TimeZone.getTimeZone("America/New_York");
diff --git a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
index 7680fb3..0bef2e0 100644
--- a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
+++ b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
@@ -86,7 +86,7 @@ public class TestUtil
throws Exception
{
FileChannel channel = (inMem ? MemFileChannel.newChannel(
- file, DatabaseImpl.RW_CHANNEL_MODE)
+ file, MemFileChannel.RW_CHANNEL_MODE)
: null);
final Database db = new DatabaseBuilder(file).setReadOnly(true)
.setAutoSync(getTestAutoSync()).setChannel(channel).open();
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java
index 1ed17b7..36ab9bd 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java
@@ -98,7 +98,7 @@ public class JetFormatTest extends TestCase {
}
SUPPORTED_FILEFORMATS = supported.toArray(new FileFormat[0]);
- SUPPORTED_FILEFORMATS_FOR_READ =
+ SUPPORTED_FILEFORMATS_FOR_READ =
supportedForRead.toArray(new FileFormat[0]);
}
@@ -110,7 +110,7 @@ public class JetFormatTest extends TestCase {
private final File dbFile;
private final FileFormat expectedFileFormat;
- private TestDB(File databaseFile,
+ private TestDB(File databaseFile,
FileFormat expectedDBFileFormat) {
dbFile = databaseFile;
@@ -119,12 +119,12 @@ public class JetFormatTest extends TestCase {
public final File getFile() { return dbFile; }
- public final FileFormat getExpectedFileFormat() {
- return expectedFileFormat;
+ public final FileFormat getExpectedFileFormat() {
+ return expectedFileFormat;
}
- public final JetFormat getExpectedFormat() {
- return DatabaseImpl.getFileFormatDetails(expectedFileFormat).getFormat();
+ public final JetFormat getExpectedFormat() {
+ return DatabaseImpl.getFileFormatDetails(expectedFileFormat).getFormat();
}
@Override
@@ -141,14 +141,14 @@ public class JetFormatTest extends TestCase {
boolean readOnly) {
List<TestDB> supportedTestDBs = new ArrayList<TestDB>();
- for (FileFormat fileFormat :
+ for (FileFormat fileFormat :
(readOnly ? SUPPORTED_FILEFORMATS_FOR_READ :
SUPPORTED_FILEFORMATS)) {
File testFile = getFileForBasename(basename, fileFormat);
if(!testFile.exists()) {
continue;
}
-
+
// verify that the db is the file format expected
try {
Database db = new DatabaseBuilder(testFile).setReadOnly(true).open();
@@ -170,16 +170,16 @@ public class JetFormatTest extends TestCase {
private static File getFileForBasename(
Basename basename, FileFormat fileFormat) {
- return new File(DIR_TEST_DATA,
+ return new File(DIR_TEST_DATA,
fileFormat.name() + File.separator +
- basename + fileFormat.name() +
+ basename + fileFormat.name() +
fileFormat.getFileExtension());
}
}
- public static final List<TestDB> SUPPORTED_DBS_TEST =
+ public static final List<TestDB> SUPPORTED_DBS_TEST =
TestDB.getSupportedForBasename(Basename.TEST);
- public static final List<TestDB> SUPPORTED_DBS_TEST_FOR_READ =
+ public static final List<TestDB> SUPPORTED_DBS_TEST_FOR_READ =
TestDB.getSupportedForBasename(Basename.TEST, true);
@@ -193,11 +193,12 @@ public class JetFormatTest extends TestCase {
for (final TestDB testDB : SUPPORTED_DBS_TEST_FOR_READ) {
- final FileChannel channel = DatabaseImpl.openChannel(testDB.dbFile, false);
+ final FileChannel channel = DatabaseImpl.openChannel(
+ testDB.dbFile.toPath(), false);
try {
JetFormat fmtActual = JetFormat.getFormat(channel);
- assertEquals("Unexpected JetFormat for dbFile: " +
+ assertEquals("Unexpected JetFormat for dbFile: " +
testDB.dbFile.getAbsolutePath(),
testDB.getExpectedFormat(), fmtActual);
@@ -221,7 +222,7 @@ public class JetFormatTest extends TestCase {
PropertyMap props = db.getUserDefinedProperties();
props.put("foo", "bar");
props.save();
- }
+ }
} catch(Exception e) {
failure = e;
@@ -268,7 +269,7 @@ public class JetFormatTest extends TestCase {
}
public void testSqlTypes() throws Exception {
-
+
JetFormat v2000 = JetFormat.VERSION_4;
for(DataType dt : DataType.values()) {
if(v2000.isSupportedDataType(dt)) {
diff --git a/src/test/java/com/healthmarketscience/jackcess/util/CustomLinkResolverTest.java b/src/test/java/com/healthmarketscience/jackcess/util/CustomLinkResolverTest.java
index 31a8853..b2dfc06 100644
--- a/src/test/java/com/healthmarketscience/jackcess/util/CustomLinkResolverTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/util/CustomLinkResolverTest.java
@@ -16,9 +16,9 @@ limitations under the License.
package com.healthmarketscience.jackcess.util;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.Path;
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.DataType;
@@ -55,7 +55,7 @@ public class CustomLinkResolverTest extends TestCase
Table t1 = db.getTable("Table1");
assertNotNull(t1);
assertNotSame(db, t1.getDatabase());
-
+
assertTable(createExpectedTable(createExpectedRow("id", 0,
"data1", "row0"),
createExpectedRow("id", 1,
@@ -101,7 +101,7 @@ public class CustomLinkResolverTest extends TestCase
Database linkerDb, String linkeeFileName) throws IOException
{
return (("testFile1.txt".equals(linkeeFileName) ||
- "testFile2.txt".equals(linkeeFileName)) ?
+ "testFile2.txt".equals(linkeeFileName)) ?
linkeeFileName : null);
}
@@ -121,7 +121,7 @@ public class CustomLinkResolverTest extends TestCase
for(int i = 0; i < 3; ++i) {
t.addRow(i, "row" + i);
}
-
+
return true;
} else if("OtherTable2".equals(tableName)) {
@@ -135,7 +135,7 @@ public class CustomLinkResolverTest extends TestCase
for(int i = 3; i < 6; ++i) {
t.addRow(i, "row" + i);
}
-
+
return true;
} else if("Table4".equals(tableName)) {
@@ -149,7 +149,7 @@ public class CustomLinkResolverTest extends TestCase
@Override
protected Database createTempDb(Object customFile, FileFormat format,
- boolean inMemory, File tempDir)
+ boolean inMemory, Path tempDir)
throws IOException
{
inMemory = "testFile1.txt".equals(customFile);