diff options
| author | Brian S. O'Neill <bronee@gmail.com> | 2010-06-08 02:33:09 +0000 |
|---|---|---|
| committer | Brian S. O'Neill <bronee@gmail.com> | 2010-06-08 02:33:09 +0000 |
| commit | 56860f0aca32b2c69b6213ff7df2b28a62dce7d3 (patch) | |
| tree | f628f3f01f183512aaac37a978e8b774ed65ee8a /src/test/java/com/amazon | |
| parent | a403298b37dbf4cdc2d949885d18976cee3ea9c0 (diff) | |
Fix serialization of adapted primary key properties.
Diffstat (limited to 'src/test/java/com/amazon')
| -rw-r--r-- | src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java b/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java index 1574045..3a73faa 100644 --- a/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java +++ b/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java @@ -23,6 +23,8 @@ import java.io.*; import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.joda.time.DateTime;
+
import com.amazon.carbonado.*;
import com.amazon.carbonado.lob.*;
@@ -225,6 +227,38 @@ public class TestStorableSerializer extends TestCase { }
*/
+ public void testAdaptedPkProperty() throws Exception {
+ // Make sure that adapted property in pk can be read back, even if
+ // current property is clean. This is a test for a bug fix.
+ Storage<TheDate> storage = mRepository.storageFor(TheDate.class);
+ DateTime date = new DateTime();
+ TheDate d = storage.prepare();
+ d.setId(1);
+ d.setDate(date);
+ d.setValue("hello");
+ d.insert();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ DataOutputStream dout = new DataOutputStream(bout);
+
+ d.writeTo(dout);
+ dout.flush();
+
+ byte[] bytes = bout.toByteArray();
+
+ d = storage.prepare();
+ d.setId(1);
+ d.setDate(date);
+ // Properties are clean.
+ d.load();
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+ DataInputStream din = new DataInputStream(bin);
+
+ // No exception thrown.
+ d.readFrom(din);
+ }
+
@PrimaryKey("id")
public static abstract class ManyProperties implements Storable {
public abstract int getId();
@@ -380,4 +414,16 @@ public class TestStorableSerializer extends TestCase { public abstract int getProp47();
public abstract void setProp47(int v);
}
+
+ @PrimaryKey({"id", "date"})
+ public static interface TheDate extends Storable {
+ long getId();
+ void setId(long id);
+
+ DateTime getDate();
+ void setDate(DateTime date);
+
+ String getValue();
+ void setValue(String value);
+ }
}
|
