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. */
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<TestRecord> getKey (int recordId)
@@ -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);