From 0dba5d6c53f5e2047d23a5f866d90cca2f582bc9 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Mon, 16 Oct 2017 13:40:44 -0400 Subject: [PATCH] Query execution via sync and async can timeout. Formatting. --- .../schemabuilder/CreateMaterializedView.java | 8 ++++-- .../java/net/helenus/core/CommitThunk.java | 1 - .../java/net/helenus/core/SchemaUtil.java | 8 +++--- .../java/net/helenus/core/UnitOfWork.java | 1 - .../core/operation/AbstractOperation.java | 26 +++++++++++++----- .../operation/AbstractOptionalOperation.java | 23 +++++++++++----- .../operation/AbstractStatementOperation.java | 16 +++++++++++ .../operation/AbstractStreamOperation.java | 22 ++++++++++----- .../core/operation/InsertOperation.java | 3 ++- .../net/helenus/core/operation/Operation.java | 27 ++++++++++--------- .../core/operation/SelectOperation.java | 1 - .../core/operation/UpdateOperation.java | 3 ++- .../net/helenus/core/reflect/Drafted.java | 1 - .../core/collection/CollectionTest.java | 8 +++--- .../integration/core/counter/CounterTest.java | 4 ++- .../core/hierarchy/HierarchyTest.java | 6 +++-- .../core/index/SecondaryIndexTest.java | 4 ++- .../core/simple/SimpleUserTest.java | 4 ++- .../core/simple/StaticColumnTest.java | 3 ++- .../core/tuple/InnerTupleTest.java | 4 ++- .../integration/core/tuple/TupleTest.java | 6 +++-- .../core/tuplecollection/TupleKeyMapTest.java | 4 ++- .../core/tuplecollection/TupleListTest.java | 4 ++- .../core/tuplecollection/TupleMapTest.java | 4 ++- .../core/tuplecollection/TupleSetTest.java | 4 ++- .../tuplecollection/TupleValueMapTest.java | 4 ++- .../core/udtcollection/UDTKeyMapTest.java | 4 ++- .../core/udtcollection/UDTListTest.java | 4 ++- .../core/udtcollection/UDTMapTest.java | 4 ++- .../core/udtcollection/UDTSetTest.java | 4 ++- .../core/udtcollection/UDTValueMapTest.java | 4 ++- .../usertype/InnerUserDefinedTypeTest.java | 4 ++- .../core/usertype/UserDefinedTypeTest.java | 6 +++-- .../integration/core/views/CyclistsByAge.java | 1 - .../core/views/MaterializedViewTest.java | 15 ++++++----- 35 files changed, 169 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/datastax/driver/core/schemabuilder/CreateMaterializedView.java b/src/main/java/com/datastax/driver/core/schemabuilder/CreateMaterializedView.java index 919becc..d6ba093 100644 --- a/src/main/java/com/datastax/driver/core/schemabuilder/CreateMaterializedView.java +++ b/src/main/java/com/datastax/driver/core/schemabuilder/CreateMaterializedView.java @@ -11,7 +11,11 @@ public class CreateMaterializedView extends Create { private String clustering; public CreateMaterializedView( - String keyspaceName, String viewName, Select.Where selection, String primaryKey, String clustering) { + String keyspaceName, + String viewName, + Select.Where selection, + String primaryKey, + String clustering) { super(keyspaceName, viewName); this.viewName = viewName; this.selection = selection; @@ -40,7 +44,7 @@ public class CreateMaterializedView extends Create { createStatement.append(" "); createStatement.append(primaryKey); if (clustering != null) { - createStatement.append(" ").append(clustering); + createStatement.append(" ").append(clustering); } createStatement.append(";"); diff --git a/src/main/java/net/helenus/core/CommitThunk.java b/src/main/java/net/helenus/core/CommitThunk.java index ff50f4a..1ad9e05 100644 --- a/src/main/java/net/helenus/core/CommitThunk.java +++ b/src/main/java/net/helenus/core/CommitThunk.java @@ -1,6 +1,5 @@ package net.helenus.core; - @FunctionalInterface public interface CommitThunk { void apply(); diff --git a/src/main/java/net/helenus/core/SchemaUtil.java b/src/main/java/net/helenus/core/SchemaUtil.java index 5e33b3d..02fb929 100644 --- a/src/main/java/net/helenus/core/SchemaUtil.java +++ b/src/main/java/net/helenus/core/SchemaUtil.java @@ -32,7 +32,6 @@ import net.helenus.mapping.type.OptionalColumnMetadata; import net.helenus.support.CqlUtil; import net.helenus.support.HelenusMappingException; - public final class SchemaUtil { private SchemaUtil() {} @@ -191,7 +190,8 @@ public final class SchemaUtil { c.add(columnName); where = where.and(new IsNotNullClause(columnName)); - ClusteringColumn clusteringColumn = prop.getProperty().getGetterMethod().getAnnotation(ClusteringColumn.class); + ClusteringColumn clusteringColumn = + prop.getProperty().getGetterMethod().getAnnotation(ClusteringColumn.class); if (clusteringColumn != null && clusteringColumn.ordering() != null) { o.add(columnName + " " + clusteringColumn.ordering().cql()); } @@ -211,10 +211,10 @@ public final class SchemaUtil { String clustering = ""; if (o.size() > 0) { - clustering = "WITH CLUSTERING ORDER BY (" + String.join(", ", o) + ")"; + clustering = "WITH CLUSTERING ORDER BY (" + String.join(", ", o) + ")"; } return new CreateMaterializedView(keyspace, viewName, where, primaryKey, clustering) - .ifNotExists(); + .ifNotExists(); } public static SchemaStatement dropMaterializedView( diff --git a/src/main/java/net/helenus/core/UnitOfWork.java b/src/main/java/net/helenus/core/UnitOfWork.java index f27b76c..6bc630a 100644 --- a/src/main/java/net/helenus/core/UnitOfWork.java +++ b/src/main/java/net/helenus/core/UnitOfWork.java @@ -15,7 +15,6 @@ */ package net.helenus.core; - import java.util.Map; import java.util.Set; diff --git a/src/main/java/net/helenus/core/operation/AbstractOperation.java b/src/main/java/net/helenus/core/operation/AbstractOperation.java index 8eb7961..7990c5a 100644 --- a/src/main/java/net/helenus/core/operation/AbstractOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractOperation.java @@ -17,7 +17,13 @@ package net.helenus.core.operation; import com.codahale.metrics.Timer; import com.datastax.driver.core.ResultSet; + +import java.sql.Time; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.TimeoutException; + +import com.diffplug.common.base.Errors; import net.helenus.core.AbstractSessionOperations; import net.helenus.core.UnitOfWork; @@ -38,22 +44,22 @@ public abstract class AbstractOperation> return new PreparedOperation(prepareStatement(), this); } - public E sync() { + public E sync() throws TimeoutException { final Timer.Context context = requestLatency.time(); try { - ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false); + ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false); return transform(resultSet); } finally { context.stop(); } } - public E sync(UnitOfWork uow) { + public E sync(UnitOfWork uow) throws TimeoutException { if (uow == null) return sync(); final Timer.Context context = requestLatency.time(); try { - ResultSet resultSet = execute(sessionOps, uow, traceContext, showValues, true); + ResultSet resultSet = execute(sessionOps, uow, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, true); E result = transform(resultSet); return result; } finally { @@ -62,11 +68,19 @@ public abstract class AbstractOperation> } public CompletableFuture async() { - return CompletableFuture.supplyAsync(() -> sync()); + return CompletableFuture.supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } public CompletableFuture async(UnitOfWork uow) { if (uow == null) return async(); - return CompletableFuture.supplyAsync(() -> sync(uow)); + return CompletableFuture.supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } } diff --git a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java index 1d34223..fb653d1 100644 --- a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java @@ -25,6 +25,9 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.TimeoutException; + import net.helenus.core.AbstractSessionOperations; import net.helenus.core.UnitOfWork; @@ -53,17 +56,17 @@ public abstract class AbstractOptionalOperation sync() { + public Optional sync() throws TimeoutException { final Timer.Context context = requestLatency.time(); try { - ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false); + ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false); return transform(resultSet); } finally { context.stop(); } } - public Optional sync(UnitOfWork uow) { + public Optional sync(UnitOfWork uow) throws TimeoutException { if (uow == null) return sync(); final Timer.Context context = requestLatency.time(); @@ -84,7 +87,7 @@ public abstract class AbstractOptionalOperation> async() { - return CompletableFuture.>supplyAsync(() -> sync()); + return CompletableFuture.>supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } public CompletableFuture> async(UnitOfWork uow) { if (uow == null) return async(); - return CompletableFuture.>supplyAsync(() -> sync(uow)); + return CompletableFuture.>supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } } diff --git a/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java b/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java index 5177724..bba8f9b 100644 --- a/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java @@ -32,6 +32,8 @@ import net.helenus.support.HelenusException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.TimeUnit; + public abstract class AbstractStatementOperation> extends Operation { @@ -49,6 +51,8 @@ public abstract class AbstractStatementOperation sync() { + public Stream sync() throws TimeoutException { final Timer.Context context = requestLatency.time(); try { - ResultSet resultSet = this.execute(sessionOps, null, traceContext, showValues, false); + ResultSet resultSet = this.execute(sessionOps, null, traceContext, queryExecutionTimeout, queryTimeoutUnits, showValues, false); return transform(resultSet); } finally { context.stop(); } } - public Stream sync(UnitOfWork uow) { + public Stream sync(UnitOfWork uow) throws TimeoutException { if (uow == null) return sync(); final Timer.Context context = requestLatency.time(); @@ -82,7 +84,7 @@ public abstract class AbstractStreamOperation> async() { - return CompletableFuture.>supplyAsync(() -> sync()); + return CompletableFuture.>supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } public CompletableFuture> async(UnitOfWork uow) { if (uow == null) return async(); - return CompletableFuture.>supplyAsync(() -> sync(uow)); + return CompletableFuture.>supplyAsync(() -> { + try { + return sync(); + } catch (TimeoutException ex) { throw new CompletionException(ex); } + }); } } diff --git a/src/main/java/net/helenus/core/operation/InsertOperation.java b/src/main/java/net/helenus/core/operation/InsertOperation.java index 53abaee..61b883c 100644 --- a/src/main/java/net/helenus/core/operation/InsertOperation.java +++ b/src/main/java/net/helenus/core/operation/InsertOperation.java @@ -21,6 +21,7 @@ import com.datastax.driver.core.querybuilder.Insert; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.google.common.base.Joiner; import java.util.*; +import java.util.concurrent.TimeoutException; import java.util.function.Function; import net.helenus.core.AbstractSessionOperations; import net.helenus.core.Getter; @@ -257,7 +258,7 @@ public final class InsertOperation extends AbstractOperation { @@ -32,8 +36,10 @@ public abstract class Operation { AbstractSessionOperations session, UnitOfWork uow, TraceContext traceContext, + long timeout, + TimeUnit units, boolean showValues, - boolean cached) { + boolean cached) throws TimeoutException { // Start recording in a Zipkin sub-span our execution time to perform this operation. Tracer tracer = session.getZipkinTracer(); @@ -44,19 +50,14 @@ public abstract class Operation { try { - if (span != null) { - span.name("cassandra"); - span.start(); - } - - Statement statement = options(buildStatement(cached)); - ResultSetFuture futureResultSet = session.executeAsync(statement, showValues); - return futureResultSet.get(); - - } catch (InterruptedException | ExecutionException e) { - - throw new RuntimeException(e); + if (span != null) { + span.name("cassandra"); + span.start(); + } + Statement statement = options(buildStatement(cached)); + ResultSetFuture futureResultSet = session.executeAsync(statement, showValues); + return futureResultSet.getUninterruptibly(timeout, units); } finally { if (span != null) { diff --git a/src/main/java/net/helenus/core/operation/SelectOperation.java b/src/main/java/net/helenus/core/operation/SelectOperation.java index 5444262..fb7184e 100644 --- a/src/main/java/net/helenus/core/operation/SelectOperation.java +++ b/src/main/java/net/helenus/core/operation/SelectOperation.java @@ -24,7 +24,6 @@ import com.datastax.driver.core.querybuilder.Select; import com.datastax.driver.core.querybuilder.Select.Selection; import com.datastax.driver.core.querybuilder.Select.Where; import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; import java.util.*; import java.util.function.Function; import java.util.stream.Stream; diff --git a/src/main/java/net/helenus/core/operation/UpdateOperation.java b/src/main/java/net/helenus/core/operation/UpdateOperation.java index b918bc6..cf84b47 100644 --- a/src/main/java/net/helenus/core/operation/UpdateOperation.java +++ b/src/main/java/net/helenus/core/operation/UpdateOperation.java @@ -21,6 +21,7 @@ import com.datastax.driver.core.querybuilder.BuiltStatement; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.datastax.driver.core.querybuilder.Update; import java.util.*; +import java.util.concurrent.TimeoutException; import java.util.function.Function; import net.helenus.core.*; import net.helenus.core.reflect.HelenusPropertyNode; @@ -578,7 +579,7 @@ public final class UpdateOperation extends AbstractFilterOperation extends MapExportable { diff --git a/src/test/java/net/helenus/test/integration/core/collection/CollectionTest.java b/src/test/java/net/helenus/test/integration/core/collection/CollectionTest.java index e838ad3..2c1cb1f 100644 --- a/src/test/java/net/helenus/test/integration/core/collection/CollectionTest.java +++ b/src/test/java/net/helenus/test/integration/core/collection/CollectionTest.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest; @@ -51,7 +53,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest { } @Test - public void testSetCRUID() { + public void testSetCRUID() throws TimeoutException { UUID id = UUID.randomUUID(); @@ -148,7 +150,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest { } @Test - public void testListCRUID() { + public void testListCRUID() throws TimeoutException { UUID id = UUID.randomUUID(); @@ -278,7 +280,7 @@ public class CollectionTest extends AbstractEmbeddedCassandraTest { } @Test - public void testMapCRUID() { + public void testMapCRUID() throws TimeoutException { UUID id = UUID.randomUUID(); diff --git a/src/test/java/net/helenus/test/integration/core/counter/CounterTest.java b/src/test/java/net/helenus/test/integration/core/counter/CounterTest.java index 9b8d4a2..c2cbfe0 100644 --- a/src/test/java/net/helenus/test/integration/core/counter/CounterTest.java +++ b/src/test/java/net/helenus/test/integration/core/counter/CounterTest.java @@ -24,6 +24,8 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import java.util.concurrent.TimeoutException; + public class CounterTest extends AbstractEmbeddedCassandraTest { static Page page; @@ -42,7 +44,7 @@ public class CounterTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCounter() { + public void testCounter() throws TimeoutException { boolean exists = session.select(page::hits).where(page::alias, eq("index")).sync().findFirst().isPresent(); diff --git a/src/test/java/net/helenus/test/integration/core/hierarchy/HierarchyTest.java b/src/test/java/net/helenus/test/integration/core/hierarchy/HierarchyTest.java index dce32b3..ef7fcdc 100644 --- a/src/test/java/net/helenus/test/integration/core/hierarchy/HierarchyTest.java +++ b/src/test/java/net/helenus/test/integration/core/hierarchy/HierarchyTest.java @@ -4,6 +4,8 @@ import static net.helenus.core.Query.eq; import java.util.Optional; import java.util.Random; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest; @@ -35,7 +37,7 @@ public class HierarchyTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCounter() { + public void testCounter() throws TimeoutException { session .insert() @@ -58,7 +60,7 @@ public class HierarchyTest extends AbstractEmbeddedCassandraTest { } @Test - public void testDefaultMethod() { + public void testDefaultMethod() throws TimeoutException { session .insert() .value(cat::id, rnd.nextInt()) diff --git a/src/test/java/net/helenus/test/integration/core/index/SecondaryIndexTest.java b/src/test/java/net/helenus/test/integration/core/index/SecondaryIndexTest.java index a302ba0..299523c 100644 --- a/src/test/java/net/helenus/test/integration/core/index/SecondaryIndexTest.java +++ b/src/test/java/net/helenus/test/integration/core/index/SecondaryIndexTest.java @@ -23,6 +23,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.concurrent.TimeoutException; + public class SecondaryIndexTest extends AbstractEmbeddedCassandraTest { Book book; @@ -36,7 +38,7 @@ public class SecondaryIndexTest extends AbstractEmbeddedCassandraTest { } @Test - public void test() throws Exception { + public void test() throws TimeoutException { session .insert() diff --git a/src/test/java/net/helenus/test/integration/core/simple/SimpleUserTest.java b/src/test/java/net/helenus/test/integration/core/simple/SimpleUserTest.java index da7997d..77f4252 100644 --- a/src/test/java/net/helenus/test/integration/core/simple/SimpleUserTest.java +++ b/src/test/java/net/helenus/test/integration/core/simple/SimpleUserTest.java @@ -19,6 +19,8 @@ import static net.helenus.core.Query.eq; import com.datastax.driver.core.ResultSet; import java.util.*; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.core.Operator; @@ -234,7 +236,7 @@ public class SimpleUserTest extends AbstractEmbeddedCassandraTest { Assert.assertEquals(0L, cnt); } - public void testZipkin() throws Exception { + public void testZipkin() throws TimeoutException { session .update() .set(user::name, null) diff --git a/src/test/java/net/helenus/test/integration/core/simple/StaticColumnTest.java b/src/test/java/net/helenus/test/integration/core/simple/StaticColumnTest.java index b863ace..c4bd403 100644 --- a/src/test/java/net/helenus/test/integration/core/simple/StaticColumnTest.java +++ b/src/test/java/net/helenus/test/integration/core/simple/StaticColumnTest.java @@ -17,6 +17,7 @@ package net.helenus.test.integration.core.simple; import java.util.Date; import java.util.List; +import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; @@ -82,7 +83,7 @@ public class StaticColumnTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCRUID() { + public void testCRUID() throws TimeoutException { MessageImpl msg = new MessageImpl(); msg.id = 123; diff --git a/src/test/java/net/helenus/test/integration/core/tuple/InnerTupleTest.java b/src/test/java/net/helenus/test/integration/core/tuple/InnerTupleTest.java index ac9b613..d10f1be 100644 --- a/src/test/java/net/helenus/test/integration/core/tuple/InnerTupleTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuple/InnerTupleTest.java @@ -23,6 +23,8 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import java.util.concurrent.TimeoutException; + public class InnerTupleTest extends AbstractEmbeddedCassandraTest { static PhotoAlbum photoAlbum; @@ -41,7 +43,7 @@ public class InnerTupleTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCruid() { + public void testCruid() throws TimeoutException { Photo photo = new Photo() { diff --git a/src/test/java/net/helenus/test/integration/core/tuple/TupleTest.java b/src/test/java/net/helenus/test/integration/core/tuple/TupleTest.java index ae99255..b97b7a3 100644 --- a/src/test/java/net/helenus/test/integration/core/tuple/TupleTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuple/TupleTest.java @@ -27,6 +27,8 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import java.util.concurrent.TimeoutException; + public class TupleTest extends AbstractEmbeddedCassandraTest { static Album album; @@ -46,7 +48,7 @@ public class TupleTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCruid() { + public void testCruid() throws TimeoutException { AlbumInformation info = new AlbumInformation() { @@ -119,7 +121,7 @@ public class TupleTest extends AbstractEmbeddedCassandraTest { } @Test - public void testNoMapping() { + public void testNoMapping() throws TimeoutException { TupleType tupleType = session.getMetadata().newTupleType(DataType.text(), DataType.text()); TupleValue info = tupleType.newValue(); diff --git a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleKeyMapTest.java b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleKeyMapTest.java index db84f09..d70ecf7 100644 --- a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleKeyMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleKeyMapTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class TupleKeyMapTest extends TupleCollectionTest { @Test - public void testKeyMapCRUID() { + public void testKeyMapCRUID() throws TimeoutException { int id = 888; diff --git a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleListTest.java b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleListTest.java index a47e701..96a5792 100644 --- a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleListTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleListTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class TupleListTest extends TupleCollectionTest { @Test - public void testListCRUID() { + public void testListCRUID() throws TimeoutException { int id = 777; diff --git a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleMapTest.java b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleMapTest.java index a77276d..2d72de9 100644 --- a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleMapTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class TupleMapTest extends TupleCollectionTest { @Test - public void testMapCRUID() { + public void testMapCRUID() throws TimeoutException { int id = 333; diff --git a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleSetTest.java b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleSetTest.java index 26bb3db..03345e4 100644 --- a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleSetTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleSetTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class TupleSetTest extends TupleCollectionTest { @Test - public void testSetCRUID() { + public void testSetCRUID() throws TimeoutException { int id = 555; diff --git a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleValueMapTest.java b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleValueMapTest.java index e19e472..e3fcd8c 100644 --- a/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleValueMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/tuplecollection/TupleValueMapTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.tuplecollection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class TupleValueMapTest extends TupleCollectionTest { @Test - public void testValueMapCRUID() { + public void testValueMapCRUID() throws TimeoutException { int id = 999; diff --git a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTKeyMapTest.java b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTKeyMapTest.java index a6bc35c..fb84def 100644 --- a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTKeyMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTKeyMapTest.java @@ -20,13 +20,15 @@ import static net.helenus.core.Query.get; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import org.junit.Assert; import org.junit.Test; public class UDTKeyMapTest extends UDTCollectionTest { @Test - public void testKeyMapCRUID() { + public void testKeyMapCRUID() throws TimeoutException { int id = 888; diff --git a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTListTest.java b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTListTest.java index bb42087..6c1cda2 100644 --- a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTListTest.java +++ b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTListTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class UDTListTest extends UDTCollectionTest { @Test - public void testListCRUID() { + public void testListCRUID() throws TimeoutException { int id = 777; diff --git a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTMapTest.java b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTMapTest.java index 604972c..572f2a1 100644 --- a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTMapTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class UDTMapTest extends UDTCollectionTest { @Test - public void testMapCRUID() { + public void testMapCRUID() throws TimeoutException { int id = 333; diff --git a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTSetTest.java b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTSetTest.java index 098436e..d96185b 100644 --- a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTSetTest.java +++ b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTSetTest.java @@ -17,6 +17,8 @@ package net.helenus.test.integration.core.udtcollection; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Query; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,7 @@ import org.junit.Test; public class UDTSetTest extends UDTCollectionTest { @Test - public void testSetCRUID() { + public void testSetCRUID() throws TimeoutException { int id = 555; diff --git a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTValueMapTest.java b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTValueMapTest.java index d495b3e..2bb5121 100644 --- a/src/test/java/net/helenus/test/integration/core/udtcollection/UDTValueMapTest.java +++ b/src/test/java/net/helenus/test/integration/core/udtcollection/UDTValueMapTest.java @@ -20,13 +20,15 @@ import static net.helenus.core.Query.get; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeoutException; + import org.junit.Assert; import org.junit.Test; public class UDTValueMapTest extends UDTCollectionTest { @Test - public void testValueMapCRUID() { + public void testValueMapCRUID() throws TimeoutException { int id = 999; diff --git a/src/test/java/net/helenus/test/integration/core/usertype/InnerUserDefinedTypeTest.java b/src/test/java/net/helenus/test/integration/core/usertype/InnerUserDefinedTypeTest.java index 116b08f..d0ebe47 100644 --- a/src/test/java/net/helenus/test/integration/core/usertype/InnerUserDefinedTypeTest.java +++ b/src/test/java/net/helenus/test/integration/core/usertype/InnerUserDefinedTypeTest.java @@ -18,6 +18,8 @@ package net.helenus.test.integration.core.usertype; import com.google.common.collect.Sets; import java.util.Set; import java.util.UUID; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.core.Query; @@ -56,7 +58,7 @@ public class InnerUserDefinedTypeTest extends AbstractEmbeddedCassandraTest { } @Test - public void testCrud() { + public void testCrud() throws TimeoutException { UUID id = UUID.randomUUID(); diff --git a/src/test/java/net/helenus/test/integration/core/usertype/UserDefinedTypeTest.java b/src/test/java/net/helenus/test/integration/core/usertype/UserDefinedTypeTest.java index ca65a38..d36a600 100644 --- a/src/test/java/net/helenus/test/integration/core/usertype/UserDefinedTypeTest.java +++ b/src/test/java/net/helenus/test/integration/core/usertype/UserDefinedTypeTest.java @@ -18,6 +18,8 @@ package net.helenus.test.integration.core.usertype; import com.datastax.driver.core.UDTValue; import com.datastax.driver.core.UserType; import java.util.Set; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.core.Query; @@ -103,7 +105,7 @@ public class UserDefinedTypeTest extends AbstractEmbeddedCassandraTest { } @Test - public void testMappingCRUID() { + public void testMappingCRUID() throws TimeoutException { AddressImpl addr = new AddressImpl(); addr.street = "1 st"; @@ -174,7 +176,7 @@ public class UserDefinedTypeTest extends AbstractEmbeddedCassandraTest { } @Test - public void testNoMapping() { + public void testNoMapping() throws TimeoutException { String ks = getSession().getLoggedKeyspace(); UserType addressType = diff --git a/src/test/java/net/helenus/test/integration/core/views/CyclistsByAge.java b/src/test/java/net/helenus/test/integration/core/views/CyclistsByAge.java index 02b414c..555155f 100644 --- a/src/test/java/net/helenus/test/integration/core/views/CyclistsByAge.java +++ b/src/test/java/net/helenus/test/integration/core/views/CyclistsByAge.java @@ -2,7 +2,6 @@ package net.helenus.test.integration.core.views; import java.util.Date; import java.util.UUID; - import net.helenus.mapping.OrderingDirection; import net.helenus.mapping.annotation.*; diff --git a/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java b/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java index 41c8eff..2cfb0c2 100644 --- a/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java +++ b/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java @@ -20,6 +20,8 @@ import static net.helenus.core.Query.eq; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.TimeoutException; + import net.helenus.core.Helenus; import net.helenus.core.HelenusSession; import net.helenus.test.integration.build.AbstractEmbeddedCassandraTest; @@ -56,7 +58,8 @@ public class MaterializedViewTest extends AbstractEmbeddedCassandraTest { .get(); cyclist = session.dsl(Cyclist.class); - session + try { + session .insert(cyclist) .value(cyclist::cid, UUID.randomUUID()) .value(cyclist::age, 18) @@ -64,14 +67,12 @@ public class MaterializedViewTest extends AbstractEmbeddedCassandraTest { .value(cyclist::country, "Netherlands") .value(cyclist::name, "Pascal EENKHOORN") .sync(); + } + catch (TimeoutException e) {} } @Test - public void testMv() throws Exception { - session - .select(Cyclist.class) - .from(CyclistsByAge.class) - .where(cyclist::age, eq(18)) - .sync(); + public void testMv() throws TimeoutException { + session.select(Cyclist.class).from(CyclistsByAge.class).where(cyclist::age, eq(18)).sync(); } }