From 0950cb02cdf34249e217dd5011182acce447c819 Mon Sep 17 00:00:00 2001 From: samskivert Date: Tue, 23 Sep 2008 17:18:44 +0000 Subject: [PATCH] Test updates. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2443 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../jdbc/depot/tests/TestRecord.java | 13 +++++++++++-- .../jdbc/depot/tests/TestRepository.java | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/tests/TestRecord.java b/src/java/com/samskivert/jdbc/depot/tests/TestRecord.java index acddb7a0..ed2abbc4 100644 --- a/src/java/com/samskivert/jdbc/depot/tests/TestRecord.java +++ b/src/java/com/samskivert/jdbc/depot/tests/TestRecord.java @@ -80,9 +80,16 @@ public class TestRecord extends PersistentRecord /** The qualified column identifier for the {@link #lastModified} field. */ public static final ColumnExp LAST_MODIFIED_C = new ColumnExp(TestRecord.class, LAST_MODIFIED); + + /** The column identifier for the {@link #numbers} field. */ + public static final String NUMBERS = "numbers"; + + /** The qualified column identifier for the {@link #numbers} field. */ + public static final ColumnExp NUMBERS_C = + new ColumnExp(TestRecord.class, NUMBERS); // AUTO-GENERATED: FIELDS END - public static final int SCHEMA_VERSION = 2; + public static final int SCHEMA_VERSION = 3; @Id public int recordId; @@ -97,6 +104,8 @@ public class TestRecord extends PersistentRecord public Timestamp lastModified; + public int[] numbers; + @Override public String toString () { @@ -105,7 +114,7 @@ public class TestRecord extends PersistentRecord // AUTO-GENERATED: METHODS START /** - * Create and return a primary {@link Key} to identify a {@link #TestRecord} + * Create and return a primary {@link Key} to identify a {@link TestRecord} * with the supplied key values. */ public static Key getKey (int recordId) diff --git a/src/java/com/samskivert/jdbc/depot/tests/TestRepository.java b/src/java/com/samskivert/jdbc/depot/tests/TestRepository.java index 38f828dd..638b7718 100644 --- a/src/java/com/samskivert/jdbc/depot/tests/TestRepository.java +++ b/src/java/com/samskivert/jdbc/depot/tests/TestRepository.java @@ -54,32 +54,40 @@ public class TestRepository extends DepotRepository TestRepository repo = new TestRepository(perCtx); - repo.delete(TestRecord.class, 0); + repo.delete(TestRecord.class, 1); Date now = new Date(System.currentTimeMillis()); Timestamp tnow = new Timestamp(System.currentTimeMillis()); TestRecord record = new TestRecord(); + record.recordId = 1; record.name = "Elvis"; record.age = 99; record.created = now; record.homeTown = "Right here"; record.lastModified = tnow; + record.numbers = new int[] { 9, 0, 2, 1, 0 }; repo.insert(record); System.out.println(repo.load(TestRecord.class, record.recordId)); - record.age = 25; - record.name = "Bob"; - repo.update(record, "age"); +// record.age = 25; +// record.name = "Bob"; +// record.numbers = new int[] { 1, 2, 3, 4, 5 }; +// repo.update(record, TestRecord.AGE, TestRecord.NAME, TestRecord.NUMBERS); + + repo.updatePartial(TestRecord.class, record.recordId, + TestRecord.AGE, 25, TestRecord.NAME, "Bob", + TestRecord.NUMBERS, new int[] { 1, 2, 3, 4, 5 }); System.out.println(repo.load(TestRecord.class, record.recordId)); - for (int ii = 1; ii < CREATE_RECORDS; ii++) { + for (int ii = 2; ii < CREATE_RECORDS; ii++) { record = new TestRecord(); record.recordId = ii; record.name = "Spam!"; record.age = RandomUtil.getInt(150); record.homeTown = "Over there"; + record.numbers = new int[] { 5, 4, 3, 2, 1 }; record.created = now; record.lastModified = tnow; repo.insert(record);