Test updates.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2443 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert
2008-09-23 17:18:44 +00:00
parent 4c23586e3e
commit 0950cb02cd
2 changed files with 24 additions and 7 deletions
@@ -80,9 +80,16 @@ public class TestRecord extends PersistentRecord
/** The qualified column identifier for the {@link #lastModified} field. */ /** The qualified column identifier for the {@link #lastModified} field. */
public static final ColumnExp LAST_MODIFIED_C = public static final ColumnExp LAST_MODIFIED_C =
new ColumnExp(TestRecord.class, LAST_MODIFIED); 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 // AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 2; public static final int SCHEMA_VERSION = 3;
@Id @Id
public int recordId; public int recordId;
@@ -97,6 +104,8 @@ public class TestRecord extends PersistentRecord
public Timestamp lastModified; public Timestamp lastModified;
public int[] numbers;
@Override @Override
public String toString () public String toString ()
{ {
@@ -105,7 +114,7 @@ public class TestRecord extends PersistentRecord
// AUTO-GENERATED: METHODS START // 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. * with the supplied key values.
*/ */
public static Key<TestRecord> getKey (int recordId) public static Key<TestRecord> getKey (int recordId)
@@ -54,32 +54,40 @@ public class TestRepository extends DepotRepository
TestRepository repo = new TestRepository(perCtx); TestRepository repo = new TestRepository(perCtx);
repo.delete(TestRecord.class, 0); repo.delete(TestRecord.class, 1);
Date now = new Date(System.currentTimeMillis()); Date now = new Date(System.currentTimeMillis());
Timestamp tnow = new Timestamp(System.currentTimeMillis()); Timestamp tnow = new Timestamp(System.currentTimeMillis());
TestRecord record = new TestRecord(); TestRecord record = new TestRecord();
record.recordId = 1;
record.name = "Elvis"; record.name = "Elvis";
record.age = 99; record.age = 99;
record.created = now; record.created = now;
record.homeTown = "Right here"; record.homeTown = "Right here";
record.lastModified = tnow; record.lastModified = tnow;
record.numbers = new int[] { 9, 0, 2, 1, 0 };
repo.insert(record); repo.insert(record);
System.out.println(repo.load(TestRecord.class, record.recordId)); System.out.println(repo.load(TestRecord.class, record.recordId));
record.age = 25; // record.age = 25;
record.name = "Bob"; // record.name = "Bob";
repo.update(record, "age"); // 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)); 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 = new TestRecord();
record.recordId = ii; record.recordId = ii;
record.name = "Spam!"; record.name = "Spam!";
record.age = RandomUtil.getInt(150); record.age = RandomUtil.getInt(150);
record.homeTown = "Over there"; record.homeTown = "Over there";
record.numbers = new int[] { 5, 4, 3, 2, 1 };
record.created = now; record.created = now;
record.lastModified = tnow; record.lastModified = tnow;
repo.insert(record); repo.insert(record);