diff options
| author | Brian S. O'Neill <bronee@gmail.com> | 2008-12-31 20:55:22 +0000 |
|---|---|---|
| committer | Brian S. O'Neill <bronee@gmail.com> | 2008-12-31 20:55:22 +0000 |
| commit | 3f0d660904c9ac49694a69f2c77fafca4f9af56d (patch) | |
| tree | 7153b3e9559bd43a44f35779c5e56ba6001adc52 /src/test/java/com/amazon/carbonado/TestStorables.java | |
| parent | 85489189a09a5427266dbfaa3f1cf9aefa858266 (diff) | |
Revert automatic initial version number if insert fails.
Diffstat (limited to 'src/test/java/com/amazon/carbonado/TestStorables.java')
| -rw-r--r-- | src/test/java/com/amazon/carbonado/TestStorables.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/java/com/amazon/carbonado/TestStorables.java b/src/test/java/com/amazon/carbonado/TestStorables.java index 6301c30..3570e26 100644 --- a/src/test/java/com/amazon/carbonado/TestStorables.java +++ b/src/test/java/com/amazon/carbonado/TestStorables.java @@ -737,6 +737,29 @@ public class TestStorables extends TestCase { assertTrue(s.tryUpdate()); } + public void test_versioningSideEffect() throws Exception { + Storage<StorableVersioned> storage = getRepository().storageFor(StorableVersioned.class); + + StorableVersioned s = storage.prepare(); + s.setID(500111); + s.setValue("hello"); + s.insert(); + + s = storage.prepare(); + s.setID(500111); + s.setValue("world"); + + assertEquals(false, s.tryInsert()); + // Make sure that the failed insert removes the automatic initial + // version number. + try { + s.update(); + fail(); + } catch (IllegalStateException e) { + // Caused by not setting the version. + } + } + public void test_versioningWithLong() throws Exception { Storage<StorableVersionedWithLong> storage = getRepository().storageFor(StorableVersionedWithLong.class); |
