From 856bebd5f8bf46293edc083aa1a1e9fadab25e70 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 4 May 2011 00:20:02 +0000 Subject: Add support for Query controller and timeouts; remove vestigial support for interrupts. --- .../java/com/amazon/carbonado/TestStorables.java | 63 +++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'src/test/java/com/amazon/carbonado/TestStorables.java') diff --git a/src/test/java/com/amazon/carbonado/TestStorables.java b/src/test/java/com/amazon/carbonado/TestStorables.java index ab78a41..20f640d 100644 --- a/src/test/java/com/amazon/carbonado/TestStorables.java +++ b/src/test/java/com/amazon/carbonado/TestStorables.java @@ -233,7 +233,6 @@ public class TestStorables extends TestCase { catch (UniqueConstraintException e) { } - Storage storageMPK = getRepository().storageFor(StorableTestMultiPK.class); StorableTestMultiPK smpk = storageMPK.prepare(); @@ -250,7 +249,6 @@ public class TestStorables extends TestCase { } public void test_storableStorableStates() throws Exception { - Storage storageMinimal = getRepository().storageFor(StorableTestKeyValue.class); @@ -3454,6 +3452,67 @@ public class TestStorables extends TestCase { assertNull(order); } + public void test_countTimeout() throws Exception { + Storage storage = + getRepository().storageFor(StorableTestMinimal.class); + + Transaction txn = getRepository().enterTransaction(); + try { + for (int i=0; i<100000; i++) { + StorableTestMinimal min = storage.prepare(); + min.setId(i); + min.insert(); + if (i % 100 == 0) { + txn.commit(); + } + } + txn.commit(); + } finally { + txn.exit(); + } + + try { + // Use filter to bypass optimizations. + storage.query("id >= ?").with(0).count(Query.Timeout.millis(1)); + fail(); + } catch (FetchInterruptedException e) { + } + } + + public void test_fetchTimeout() throws Exception { + Storage storage = + getRepository().storageFor(StorableTestBasic.class); + + Transaction txn = getRepository().enterTransaction(); + try { + for (int i=0; i<100000; i++) { + StorableTestBasic stb = storage.prepare(); + stb.setId(i); + stb.setStringProp("str " + Math.random()); + stb.setIntProp(i); + stb.setLongProp(i); + stb.setDoubleProp(i); + stb.insert(); + if (i % 100 == 0) { + txn.commit(); + } + } + txn.commit(); + } finally { + txn.exit(); + } + + try { + Cursor cursor = + storage.query().orderBy("stringProp").fetch(Query.Timeout.millis(1)); + while (cursor.hasNext()) { + cursor.next(); + } + fail(); + } catch (FetchInterruptedException e) { + } + } + private void assertUninitialized(boolean expected, Storable storable, String... properties) { for (String property : properties) { assertEquals(expected, storable.isPropertyUninitialized(property)); -- cgit v1.2.3