summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/java/com/amazon/carbonado/TestStorables.java21
-rw-r--r--src/test/java/com/amazon/carbonado/stored/StorableIndependent.java43
2 files changed, 64 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/TestStorables.java b/src/test/java/com/amazon/carbonado/TestStorables.java
index 4704cdc..3e18fa7 100644
--- a/src/test/java/com/amazon/carbonado/TestStorables.java
+++ b/src/test/java/com/amazon/carbonado/TestStorables.java
@@ -655,6 +655,27 @@ public class TestStorables extends TestCase {
}
}
+ public void test_independent() throws Exception {
+ // Just make sure that no check is performed for unset independent property.
+ Storage<StorableIndependent> storage =
+ getRepository().storageFor(StorableIndependent.class);
+ StorableIndependent s = storage.prepare();
+ s.setID(100);
+ try {
+ s.insert();
+ fail();
+ } catch (ConstraintException e) {
+ // Din't set name.
+ }
+
+ s.setValue("value");
+ // Should not check unset independent property, name.
+ s.insert();
+
+ s.setName("bob");
+ s.update();
+ }
+
public void test_nonDestructiveUpdate() throws Exception {
Storage<StorableTestBasic> storage = getRepository().storageFor(StorableTestBasic.class);
StorableTestBasic s = storage.prepare();
diff --git a/src/test/java/com/amazon/carbonado/stored/StorableIndependent.java b/src/test/java/com/amazon/carbonado/stored/StorableIndependent.java
new file mode 100644
index 0000000..e81e37e
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/StorableIndependent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009 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 com.amazon.carbonado.Independent;
+import com.amazon.carbonado.Nullable;
+import com.amazon.carbonado.Storable;
+import com.amazon.carbonado.PrimaryKey;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public interface StorableIndependent extends Storable {
+ int getID();
+ void setID(int id);
+
+ String getValue();
+ void setValue(String value);
+
+ @Independent
+ @Nullable
+ String getName();
+ void setName(String name);
+}