diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2012-02-01 04:25:23 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2012-02-01 04:25:23 +0000 |
commit | ae2ffd397026c7eac5210d343934ab15eb00bb4a (patch) | |
tree | 0216889dd61d74e7a335a6716bdacd4bb47b8390 /test | |
parent | 012405a81e1bc5a29f991ec03345803f0677d9c0 (diff) | |
download | jackcess-ae2ffd397026c7eac5210d343934ab15eb00bb4a.tar.gz jackcess-ae2ffd397026c7eac5210d343934ab15eb00bb4a.zip |
add initial support for linked tables (fixes issue 3479560)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@610 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rwxr-xr-x | test/data/V2007/linkerTestV2007.accdb | bin | 0 -> 454656 bytes | |||
-rwxr-xr-x | test/data/linkeeTest.accdb | bin | 0 -> 524288 bytes | |||
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 56 | ||||
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java | 3 |
4 files changed, 58 insertions, 1 deletions
diff --git a/test/data/V2007/linkerTestV2007.accdb b/test/data/V2007/linkerTestV2007.accdb Binary files differnew file mode 100755 index 0000000..57c6b25 --- /dev/null +++ b/test/data/V2007/linkerTestV2007.accdb diff --git a/test/data/linkeeTest.accdb b/test/data/linkeeTest.accdb Binary files differnew file mode 100755 index 0000000..a159097 --- /dev/null +++ b/test/data/linkeeTest.accdb diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 4cfd656..efda478 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -1216,6 +1216,62 @@ public class DatabaseTest extends TestCase { } } + public void testLinkedTables() throws Exception { + for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.LINKED)) { + Database db = openCopy(testDB); + + try { + db.getTable("Table2"); + fail("FileNotFoundException should have been thrown"); + } catch(FileNotFoundException e) { + // success + } + + assertTrue(db.getLinkedDatabases().isEmpty()); + + final String linkeeDbName = "Z:\\jackcess_test\\linkeeTest.accdb"; + final File linkeeFile = new File("test/data/linkeeTest.accdb"); + db.setLinkResolver(new LinkResolver() { + public Database resolveLinkedDatabase(Database linkerdb, String dbName) + throws IOException { + assertEquals(linkeeDbName, dbName); + return Database.open(linkeeFile); + } + }); + + Table t2 = db.getTable("Table2"); + + assertEquals(1, db.getLinkedDatabases().size()); + Database linkeeDb = db.getLinkedDatabases().get(linkeeDbName); + assertNotNull(linkeeDb); + assertEquals(linkeeFile, linkeeDb.getFile()); + + List<Map<String, Object>> expectedRows = + createExpectedTable( + createExpectedRow( + "ID", 1, + "Field1", "bar")); + + assertTable(expectedRows, t2); + + db.createLinkedTable("FooTable", linkeeDbName, "Table2"); + + Table t3 = db.getTable("FooTable"); + + assertEquals(1, db.getLinkedDatabases().size()); + + expectedRows = + createExpectedTable( + createExpectedRow( + "ID", 1, + "Field1", "buzz")); + + assertTable(expectedRows, t3); + + db.close(); + } + } + private void checkRawValue(String expected, Object val) { if(expected != null) { diff --git a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java index ec11dce..c5cacfb 100644 --- a/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/JetFormatTest.java @@ -43,7 +43,8 @@ public class JetFormatTest extends TestCase { INDEX_PROPERTIES("testIndexProperties"), PROMOTION("testPromotion"), COMPLEX("complexDataTest"), - UNSUPPORTED("unsupportedFieldsTest"); + UNSUPPORTED("unsupportedFieldsTest"), + LINKED("linkerTest"); private final String _basename; |