summaryrefslogtreecommitdiffstats
path: root/test/src/java/com/healthmarketscience/jackcess
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2009-11-16 13:08:01 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2009-11-16 13:08:01 +0000
commita49de754bce849d94719a473567e78b595fbdc9a (patch)
tree5cbd0752d5395558fd9e8ecb729a9be62bf81dd2 /test/src/java/com/healthmarketscience/jackcess
parentdf8fc3e6d7f317b30d577d34a347bf14bfda3a6f (diff)
downloadjackcess-a49de754bce849d94719a473567e78b595fbdc9a.tar.gz
jackcess-a49de754bce849d94719a473567e78b595fbdc9a.zip
initial update row support
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@409 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test/src/java/com/healthmarketscience/jackcess')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java61
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/TableTest.java2
2 files changed, 61 insertions, 2 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 9055ed8..fac88f3 100644
--- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -184,7 +184,7 @@ public class DatabaseTest extends TestCase {
public void testGetNextRow() throws Exception {
Database db = open();
- assertEquals(3, db.getTableNames().size());
+ assertEquals(4, db.getTableNames().size());
Table table = db.getTable("Table1");
Map<String, Object> row = table.getNextRow();
@@ -913,6 +913,65 @@ public class DatabaseTest extends TestCase {
db.close();
}
+
+ public void testUpdateRow() throws Exception
+ {
+ Database db = create();
+
+ Table t = new TableBuilder("test")
+ .addColumn(new ColumnBuilder("name", DataType.TEXT).toColumn())
+ .addColumn(new ColumnBuilder("id", DataType.LONG)
+ .setAutoNumber(true).toColumn())
+ .addColumn(new ColumnBuilder("data", DataType.TEXT)
+ .setLength(JetFormat.TEXT_FIELD_MAX_LENGTH).toColumn())
+ .toTable(db);
+
+ for(int i = 0; i < 10; ++i) {
+ t.addRow("row" + i, Column.AUTO_NUMBER, "initial data");
+ }
+
+ t.reset();
+ t.getNextRow();
+ Map<String,Object> row = t.getNextRow();
+
+ assertEquals(createExpectedRow("name", "row1",
+ "id", 2,
+ "data", "initial data"),
+ row);
+
+ t.updateCurrentRow(Column.KEEP_VALUE, Column.AUTO_NUMBER, "new data");
+
+ t.getNextRow();
+ t.getNextRow();
+ row = t.getNextRow();
+
+ assertEquals(createExpectedRow("name", "row4",
+ "id", 5,
+ "data", "initial data"),
+ row);
+
+ t.updateCurrentRow(Column.KEEP_VALUE, Column.AUTO_NUMBER, "a larger amount of new data");
+
+ t.reset();
+ t.getNextRow();
+ row = t.getNextRow();
+
+ assertEquals(createExpectedRow("name", "row1",
+ "id", 2,
+ "data", "new data"),
+ row);
+
+ t.getNextRow();
+ t.getNextRow();
+ row = t.getNextRow();
+
+ assertEquals(createExpectedRow("name", "row4",
+ "id", 5,
+ "data", "a larger amount of new data"),
+ row);
+
+ db.close();
+ }
static Object[] createTestRow(String col1Val) {
return new Object[] {col1Val, "R", "McCune", 1234, (byte) 0xad, 555.66d,
diff --git a/test/src/java/com/healthmarketscience/jackcess/TableTest.java b/test/src/java/com/healthmarketscience/jackcess/TableTest.java
index 3190846..54c819a 100644
--- a/test/src/java/com/healthmarketscience/jackcess/TableTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/TableTest.java
@@ -119,7 +119,7 @@ public class TableTest extends TestCase {
{
return _testTable.createRow(
row, _testTable.getFormat().MAX_ROW_SIZE,
- _testTable.getPageChannel().createPageBuffer());
+ _testTable.getPageChannel().createPageBuffer(), false, 0);
}
private ByteBuffer[] encodeColumns(Object... row)