diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2016-02-16 00:13:01 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2016-02-16 00:13:01 +0000 |
commit | 4e5fe7ec04eff9ea4e64a8c6d1e3f7fd51257e06 (patch) | |
tree | d858366ec674ddc1e8dadaca27d8451a39e4385b /src/test/java | |
parent | afdc6f96fe5d662e76567ee2230a3a5d5a859169 (diff) | |
download | jackcess-4e5fe7ec04eff9ea4e64a8c6d1e3f7fd51257e06.tar.gz jackcess-4e5fe7ec04eff9ea4e64a8c6d1e3f7fd51257e06.zip |
Add Database.getTableMetaData method to enable getting basic info about a Table (by name) without actually loading it. fixes feature request #33
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@979 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java index 5b0aff6..60e8bea 100644 --- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -777,6 +777,10 @@ public class DatabaseTest extends TestCase assertNull(db.getSystemTable("MSysBogus")); + TableMetaData tmd = db.getTableMetaData("MSysObjects"); + assertEquals("MSysObjects", tmd.getName()); + assertFalse(tmd.isLinked()); + assertTrue(tmd.isSystem()); db.close(); } @@ -858,6 +862,16 @@ public class DatabaseTest extends TestCase // success } + TableMetaData tmd = db.getTableMetaData("Table2"); + assertEquals("Table2", tmd.getName()); + assertTrue(tmd.isLinked()); + assertFalse(tmd.isSystem()); + assertEquals("Table1", tmd.getLinkedTableName()); + assertEquals("Z:\\jackcess_test\\linkeeTest.accdb", tmd.getLinkedDbName()); + + tmd = db.getTableMetaData("FooTable"); + assertNull(tmd); + assertTrue(db.getLinkedDatabases().isEmpty()); final String linkeeDbName = "Z:\\jackcess_test\\linkeeTest.accdb"; @@ -887,6 +901,13 @@ public class DatabaseTest extends TestCase db.createLinkedTable("FooTable", linkeeDbName, "Table2"); + tmd = db.getTableMetaData("FooTable"); + assertEquals("FooTable", tmd.getName()); + assertTrue(tmd.isLinked()); + assertFalse(tmd.isSystem()); + assertEquals("Table2", tmd.getLinkedTableName()); + assertEquals("Z:\\jackcess_test\\linkeeTest.accdb", tmd.getLinkedDbName()); + Table t3 = db.getTable("FooTable"); assertEquals(1, db.getLinkedDatabases().size()); @@ -899,7 +920,14 @@ public class DatabaseTest extends TestCase assertTable(expectedRows, t3); - Table t1 = db.getTable("Table1"); + tmd = db.getTableMetaData("Table1"); + assertEquals("Table1", tmd.getName()); + assertFalse(tmd.isLinked()); + assertFalse(tmd.isSystem()); + assertNull(tmd.getLinkedTableName()); + assertNull(tmd.getLinkedDbName()); + + Table t1 = tmd.open(db); assertFalse(db.isLinkedTable(null)); assertTrue(db.isLinkedTable(t2)); @@ -933,7 +961,7 @@ public class DatabaseTest extends TestCase assertFalse(tables.contains(t2)); assertFalse(tables.contains(t3)); assertTrue(tables.contains(((DatabaseImpl)db).getSystemCatalog())); - + db.close(); } } |