summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-03-06 18:44:38 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-03-06 18:44:38 +0000
commit3bbc8a0eefba7199e5402d45c86ffe5dbb3da1ad (patch)
tree33a1e836fa7ae75ea21fd7e23e1f70877ee9be39 /test
parent5d47aef5200dc251302c01b9c2cb4753ea786dbf (diff)
downloadjackcess-3bbc8a0eefba7199e5402d45c86ffe5dbb3da1ad.tar.gz
jackcess-3bbc8a0eefba7199e5402d45c86ffe5dbb3da1ad.zip
More fixes for index parsing. Believe index names are now correctly
matched up with indexes. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@249 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/IndexTest.java42
1 files changed, 41 insertions, 1 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
index 6017488..51b5da4 100644
--- a/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/IndexTest.java
@@ -104,16 +104,36 @@ public class IndexTest extends TestCase {
Database mdb = Database.open(new File("test/data/indexTest.mdb"));
Table table = mdb.getTable("Table1");
+ for(Index idx : table.getIndexes()) {
+ idx.initialize();
+ }
assertEquals(4, table.getIndexes().size());
assertEquals(4, table.getIndexSlotCount());
-
+ checkIndexColumns(table,
+ "id", "id",
+ "PrimaryKey", "id",
+ "Table2Table1", "otherfk1",
+ "Table3Table1", "otherfk2");
+
table = mdb.getTable("Table2");
+ for(Index idx : table.getIndexes()) {
+ idx.initialize();
+ }
assertEquals(2, table.getIndexes().size());
assertEquals(3, table.getIndexSlotCount());
+ checkIndexColumns(table,
+ "id", "id",
+ "PrimaryKey", "id");
table = mdb.getTable("Table3");
+ for(Index idx : table.getIndexes()) {
+ idx.initialize();
+ }
assertEquals(2, table.getIndexes().size());
assertEquals(3, table.getIndexSlotCount());
+ checkIndexColumns(table,
+ "id", "id",
+ "PrimaryKey", "id");
}
public void testComplexIndex() throws Exception
@@ -186,5 +206,25 @@ public class IndexTest extends TestCase {
assertEquals(8, index.getEntryCount());
}
}
+
+ private void checkIndexColumns(Table table, String... idxInfo)
+ throws Exception
+ {
+ Map<String, String> expectedIndexes = new HashMap<String, String>();
+ for(int i = 0; i < idxInfo.length; i+=2) {
+ expectedIndexes.put(idxInfo[i], idxInfo[i+1]);
+ }
+
+ for(Index idx : table.getIndexes()) {
+ String colName = expectedIndexes.get(idx.getName());
+ assertEquals(1, idx.getColumns().size());
+ assertEquals(colName, idx.getColumns().get(0).getName());
+ if("PrimaryKey".equals(idx.getName())) {
+ assertTrue(idx.isPrimaryKey());
+ } else {
+ assertFalse(idx.isPrimaryKey());
+ }
+ }
+ }
}