diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2007-11-29 16:12:26 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2007-11-29 16:12:26 +0000 |
commit | 34b536c894ff35270905026db1087ecbdf205880 (patch) | |
tree | 7658c5d1dd2cc71e682284b7bb576cd56b4f1921 /test | |
parent | ff8135d7a347bace914dbb4b8a7d4393d00b2bbf (diff) | |
download | jackcess-34b536c894ff35270905026db1087ecbdf205880.tar.gz jackcess-34b536c894ff35270905026db1087ecbdf205880.zip |
more minor tweaks and enhanced cursor tests
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@191 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/CursorTest.java | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java index c87b29e..f6b829d 100644 --- a/test/src/java/com/healthmarketscience/jackcess/CursorTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/CursorTest.java @@ -142,6 +142,15 @@ public class CursorTest extends TestCase { assertEquals(3, cursor.moveNextRows(3)); assertFalse(cursor.isBeforeFirst()); assertFalse(cursor.isAfterLast()); + + Map<String,Object> expectedRow = cursor.getCurrentRow(); + Cursor.Savepoint savepoint = cursor.getSavepoint(); + assertEquals(2, cursor.movePreviousRows(2)); + assertEquals(2, cursor.moveNextRows(2)); + assertTrue(cursor.moveToNextRow()); + assertTrue(cursor.moveToPreviousRow()); + assertEquals(expectedRow, cursor.getCurrentRow()); + while(cursor.moveToNextRow()) { foundRows.add(cursor.getCurrentRow()); } @@ -150,6 +159,17 @@ public class CursorTest extends TestCase { assertTrue(cursor.isAfterLast()); assertEquals(0, cursor.moveNextRows(3)); + + cursor.beforeFirst(); + assertTrue(cursor.isBeforeFirst()); + assertFalse(cursor.isAfterLast()); + + cursor.afterLast(); + assertFalse(cursor.isBeforeFirst()); + assertTrue(cursor.isAfterLast()); + + cursor.restoreSavepoint(savepoint); + assertEquals(expectedRow, cursor.getCurrentRow()); } public void testSearch() throws Exception { @@ -157,14 +177,14 @@ public class CursorTest extends TestCase { Table table = db.getTable("test"); Cursor cursor = Cursor.createCursor(table); - doTestSearch(table, cursor); + doTestSearch(table, cursor, null); db.close(); } - private void doTestSearch(Table table, Cursor cursor) throws Exception { - List<Map<String,Object>> expectedRows = createTestTableData(); - + private void doTestSearch(Table table, Cursor cursor, Index index) + throws Exception + { assertTrue(cursor.findRow(table.getColumn("id"), 3)); assertEquals(createExpectedRow("id", 3, "value", "data" + 3), @@ -178,16 +198,42 @@ public class CursorTest extends TestCase { cursor.getCurrentRow()); assertFalse(cursor.findRow(createExpectedRow( - "id", 13, - "value", "data" + 8))); + "id", 8, + "value", "data" + 13))); + assertFalse(cursor.findRow(table.getColumn("id"), 13)); assertEquals(createExpectedRow("id", 6, "value", "data" + 6), cursor.getCurrentRow()); + + assertTrue(cursor.findRow(createExpectedRow( + "value", "data" + 7))); + assertEquals(createExpectedRow("id", 7, + "value", "data" + 7), + cursor.getCurrentRow()); + + assertTrue(cursor.findRow(table.getColumn("value"), "data" + 2)); + assertEquals(createExpectedRow("id", 2, + "value", "data" + 2), + cursor.getCurrentRow()); assertEquals("data" + 9, Cursor.findValue(table, table.getColumn("value"), table.getColumn("id"), 9)); + assertEquals(createExpectedRow("id", 9, + "value", "data" + 9), + Cursor.findRow(table, + createExpectedRow("id", 9))); + if(index != null) { + assertEquals("data" + 9, + Cursor.findValue(table, index, + table.getColumn("value"), + table.getColumn("id"), 9)); + assertEquals(createExpectedRow("id", 9, + "value", "data" + 9), + Cursor.findRow(table, index, + createExpectedRow("id", 9))); + } } public void testReverse() throws Exception { @@ -343,7 +389,7 @@ public class CursorTest extends TestCase { Table table = db.getTable("test"); Index idx = table.getIndexes().get(0); Cursor cursor = Cursor.createIndexCursor(table, idx); - doTestSearch(table, cursor); + doTestSearch(table, cursor, idx); db.close(); } |