From 4ffcf30a2a07d0ff79e68e40210f850110694eee Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 23 Feb 2015 04:08:54 +0000 Subject: fix linked table test; add unit tests for new table iteration methods git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@917 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../healthmarketscience/jackcess/DatabaseTest.java | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java index 254901a..e2751cb 100644 --- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -1442,14 +1442,56 @@ public class DatabaseTest extends TestCase assertTable(expectedRows, t3); + Table t1 = db.getTable("Table1"); + assertFalse(db.isLinkedTable(null)); - assertFalse(db.isLinkedTable(t2)); + assertTrue(db.isLinkedTable(t2)); assertTrue(db.isLinkedTable(t3)); + assertFalse(db.isLinkedTable(t1)); + + List tables = getTables(db.newIterable()); + assertEquals(3, tables.size()); + assertTrue(tables.contains(t1)); + 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().setIncludeLinkedTables(false)); + 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().setIncludeLinkedTables(false) + .setIncludeNormalTables(false) + .setIncludeSystemTables(true)); + assertTrue(tables.size() > 5); + assertFalse(tables.contains(t1)); + assertFalse(tables.contains(t2)); + assertFalse(tables.contains(t3)); + assertTrue(tables.contains(((DatabaseImpl)db).getSystemCatalog())); db.close(); } } + private static List
getTables(Iterable
tableIter) + { + List
tableList = new ArrayList
(); + for(Table t : tableIter) { + tableList.add(t); + } + return tableList; + } + public void testTimeZone() throws Exception { TimeZone tz = TimeZone.getTimeZone("America/New_York"); -- cgit v1.2.3