summaryrefslogtreecommitdiff
path: root/src/test/java/com/amazon
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-10-15 22:06:16 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-10-15 22:06:16 +0000
commitb54d6189eda207cf6f2970908ff9e19619a4fc51 (patch)
tree0bc9c35a59133c290ffb92708209aa62abc61188 /src/test/java/com/amazon
parent191fe6d768549dca8b81515351f983dd89017574 (diff)
Generated readFrom method sets properties states at the end, to ensure that adapted properties in the primary key can be always set.
Diffstat (limited to 'src/test/java/com/amazon')
-rw-r--r--src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java22
-rw-r--r--src/test/java/com/amazon/carbonado/stored/StorableDatePk.java39
2 files changed, 61 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 883b84a..7e51fa6 100644
--- a/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java
+++ b/src/test/java/com/amazon/carbonado/gen/TestStorableSerializer.java
@@ -82,6 +82,28 @@ public class TestStorableSerializer extends TestCase {
stb2.readFrom(din);
assertEquals(stb, stb2);
+ assertEquals(stb.toString(), stb2.toString());
+ }
+
+ public void testReadAndWrite2() throws Exception {
+ Storage<StorableDatePk> storage = mRepository.storageFor(StorableDatePk.class);
+ StorableDatePk s = storage.prepare();
+ s.setId(50);
+ s.setOrderDate(new org.joda.time.DateTime());
+
+ // This should not interfere with date property being set when deserialized.
+ s.markAllPropertiesClean();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ s.writeTo(bout);
+ byte[] bytes = bout.toByteArray();
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+ StorableDatePk s2 = storage.prepare();
+ s2.readFrom(bin);
+
+ assertEquals(s, s2);
+ assertEquals(s.toString(), s2.toString());
}
/*
diff --git a/src/test/java/com/amazon/carbonado/stored/StorableDatePk.java b/src/test/java/com/amazon/carbonado/stored/StorableDatePk.java
new file mode 100644
index 0000000..0a53cb8
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/StorableDatePk.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.amazon.carbonado.stored;
+
+import org.joda.time.DateTime;
+
+
+import com.amazon.carbonado.PrimaryKey;
+import com.amazon.carbonado.Storable;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("orderDate")
+public interface StorableDatePk extends Storable {
+ int getId();
+ void setId(int id);
+
+ DateTime getOrderDate();
+ void setOrderDate(DateTime date);
+}