From 57108a9faae53d36c97b688ea512063bd2d1cedd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 17 Oct 2016 15:28:50 +0100 Subject: [PATCH] Try to make the tests for the Cassandra sample more robust Cassandra sometimes takes a long time when dropping the test keyspace. This results in the test failing due to an exception being thrown. This commit attempts to make the tests more robust by catching and logging any exceptions thrown during server cleanup. --- .../OrderedCassandraTestExecutionListener.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spring-boot-samples/spring-boot-sample-data-cassandra/src/test/java/sample/data/cassandra/OrderedCassandraTestExecutionListener.java b/spring-boot-samples/spring-boot-sample-data-cassandra/src/test/java/sample/data/cassandra/OrderedCassandraTestExecutionListener.java index 86f9458408d..128b6b6e42d 100644 --- a/spring-boot-samples/spring-boot-sample-data-cassandra/src/test/java/sample/data/cassandra/OrderedCassandraTestExecutionListener.java +++ b/spring-boot-samples/spring-boot-sample-data-cassandra/src/test/java/sample/data/cassandra/OrderedCassandraTestExecutionListener.java @@ -17,15 +17,30 @@ package sample.data.cassandra; import org.cassandraunit.spring.CassandraUnitDependencyInjectionTestExecutionListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.Ordered; public class OrderedCassandraTestExecutionListener extends CassandraUnitDependencyInjectionTestExecutionListener { + private static final Logger logger = LoggerFactory + .getLogger(OrderedCassandraTestExecutionListener.class); + @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } + @Override + protected void cleanServer() { + try { + super.cleanServer(); + } + catch (Exception ex) { + logger.warn("Failure during server cleanup", ex); + } + } + }