From 855ca3029ab4afc2a5766fd9198c3b3a93f7b594 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 26 Feb 2009 19:07:58 +0000 Subject: Don't check if independent properties are set. This fixes a regression in which independent properties did not work as advertised. --- .../java/com/amazon/carbonado/TestStorables.java | 21 +++++++++++ .../carbonado/stored/StorableIndependent.java | 43 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/test/java/com/amazon/carbonado/stored/StorableIndependent.java (limited to 'src/test/java/com') 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 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 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); +} -- cgit v1.2.3