aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 0a33a99..2e5c35e 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -1031,6 +1031,54 @@ public class DatabaseTest extends TestCase
assertEquals("Row[1:1][{id=37,data=<null>}]", row.toString());
}
+ public void testIterateTableNames() throws Exception {
+ for (final TestDB testDB : SUPPORTED_DBS_TEST_FOR_READ) {
+ final Database db = open(testDB);
+
+ Set<String> names = new HashSet<>();
+ int sysCount = 0;
+ for(TableMetaData tmd : db.newTableMetaDataIterable()) {
+ if(tmd.isSystem()) {
+ ++sysCount;
+ continue;
+ }
+ assertFalse(tmd.isLinked());
+ assertNull(tmd.getLinkedTableName());
+ assertNull(tmd.getLinkedDbName());
+ names.add(tmd.getName());
+ }
+
+ assertTrue(sysCount > 4);
+ assertEquals(new HashSet<>(Arrays.asList("Table1", "Table2", "Table3",
+ "Table4")),
+ names);
+ }
+
+ for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.LINKED)) {
+ final Database db = open(testDB);
+
+ Set<String> names = new HashSet<>();
+ for(TableMetaData tmd : db.newTableMetaDataIterable()) {
+ if(tmd.isSystem()) {
+ continue;
+ }
+ if("Table1".equals(tmd.getName())) {
+ assertFalse(tmd.isLinked());
+ assertNull(tmd.getLinkedTableName());
+ assertNull(tmd.getLinkedDbName());
+ } else {
+ assertTrue(tmd.isLinked());
+ assertEquals("Table1", tmd.getLinkedTableName());
+ assertEquals("Z:\\jackcess_test\\linkeeTest.accdb", tmd.getLinkedDbName());
+ }
+ names.add(tmd.getName());
+ }
+
+ assertEquals(new HashSet<>(Arrays.asList("Table1", "Table2")),
+ names);
+ }
+ }
+
private static void checkRawValue(String expected, Object val)
{
if(expected != null) {