Repository: camel
Updated Branches:
  refs/heads/master 3e6e9d6c4 -> 541114c17


Skip tests on CI


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/541114c1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/541114c1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/541114c1

Branch: refs/heads/master
Commit: 541114c17cd6ba1e87c644cc65a86ffc7bc48cbd
Parents: 3e6e9d6
Author: Claus Ibsen <davscl...@apache.org>
Authored: Mon Sep 19 10:10:26 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Sep 19 10:10:26 2016 +0200

----------------------------------------------------------------------
 .../component/cassandra/BaseCassandraTest.java  | 49 +++++++++++
 .../CassandraComponentBeanRefTest.java          | 42 ++++------
 .../CassandraComponentConsumerTest.java         | 34 +++-----
 .../CassandraComponentProducerTest.java         | 52 +++++++-----
 ...assandraComponentProducerUnpreparedTest.java | 21 +----
 .../CassandraAggregationRepositoryTest.java     | 81 +++++++++++-------
 ...ssandraAggregationSerializedHeadersTest.java |  1 -
 .../cassandra/CassandraAggregationTest.java     | 46 ++++++-----
 ...NamedCassandraAggregationRepositoryTest.java | 86 ++++++++++++--------
 .../CassandraIdempotentRepositoryTest.java      | 69 +++++++++-------
 .../cassandra/CassandraIdempotentTest.java      | 36 ++++----
 .../NamedCassandraIdempotentRepositoryTest.java | 72 +++++++++-------
 12 files changed, 342 insertions(+), 247 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/BaseCassandraTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/BaseCassandraTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/BaseCassandraTest.java
new file mode 100644
index 0000000..53a7432
--- /dev/null
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/BaseCassandraTest.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.camel.component.cassandra;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public abstract class BaseCassandraTest extends CamelTestSupport {
+
+    public static boolean canTest() {
+        // we cannot test on CI
+        return System.getenv("BUILD_ID") == null;
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        if (canTest()) {
+            CassandraUnitUtils.startEmbeddedCassandra();
+        }
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        if (canTest()) {
+            try {
+                CassandraUnitUtils.cleanEmbeddedCassandra();
+            } catch (Throwable e) {
+                // ignore shutdown errors
+            }
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
index e263fb8..3839525 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
@@ -21,16 +21,11 @@ import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.cassandraunit.CassandraCQLUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assume.assumeTrue;
-
-public class CassandraComponentBeanRefTest extends CamelTestSupport {
+public class CassandraComponentBeanRefTest extends BaseCassandraTest {
     public static final String CQL = "insert into camel_user(login, 
first_name, last_name) values (?, ?, ?)";
     public static final String SESSION_URI = 
"cql:bean:cassandraSession?cql=#insertCql";
     public static final String CLUSTER_URI = 
"cql:bean:cassandraCluster/camel_ks?cql=#insertCql";
@@ -41,30 +36,17 @@ public class CassandraComponentBeanRefTest extends 
CamelTestSupport {
     @Rule
     public CassandraCQLUnit cassandra = CassandraUnitUtils.cassandraCQLUnit();
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
-        }
-    }
-
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
-        Cluster cluster = Cluster.builder()
-                .addContactPoint("localhost")
-                .build();
-        registry.bind("cassandraCluster", cluster);
-        registry.bind("cassandraSession", cluster.connect("camel_ks"));
-        registry.bind("insertCql", CQL);
+        if (canTest()) {
+            Cluster cluster = Cluster.builder()
+                    .addContactPoint("localhost")
+                    .build();
+            registry.bind("cassandraCluster", cluster);
+            registry.bind("cassandraSession", cluster.connect("camel_ks"));
+            registry.bind("insertCql", CQL);
+        }
         return registry;
     }
 
@@ -82,6 +64,9 @@ public class CassandraComponentBeanRefTest extends 
CamelTestSupport {
 
     @Test
     public void testSession() throws Exception {
+        if (!canTest()) {
+            return;
+        }
         CassandraEndpoint endpoint = getMandatoryEndpoint(SESSION_URI, 
CassandraEndpoint.class);
 
         assertEquals("camel_ks", endpoint.getKeyspace());
@@ -90,6 +75,9 @@ public class CassandraComponentBeanRefTest extends 
CamelTestSupport {
 
     @Test
     public void testCluster() throws Exception {
+        if (!canTest()) {
+            return;
+        }
         CassandraEndpoint endpoint = getMandatoryEndpoint(CLUSTER_URI, 
CassandraEndpoint.class);
 
         assertEquals("camel_ks", endpoint.getKeyspace());

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
index 8e85be5..8978051 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
@@ -24,39 +24,23 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.cassandraunit.CassandraCQLUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assume.assumeTrue;
-
-public class CassandraComponentConsumerTest extends CamelTestSupport {
+public class CassandraComponentConsumerTest extends BaseCassandraTest {
 
     private static final String CQL = "select login, first_name, last_name 
from camel_user";
 
     @Rule
     public CassandraCQLUnit cassandra = CassandraUnitUtils.cassandraCQLUnit();
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
-        }
-    }
-
     @Test
     public void testConsumeAll() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         MockEndpoint mock = getMockEndpoint("mock:resultAll");
         mock.expectedMinimumMessageCount(1);
         mock.whenAnyExchangeReceived(new Processor() {
@@ -72,6 +56,10 @@ public class CassandraComponentConsumerTest extends 
CamelTestSupport {
 
     @Test
     public void testConsumeUnprepared() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         MockEndpoint mock = getMockEndpoint("mock:resultUnprepared");
         mock.expectedMinimumMessageCount(1);
         mock.whenAnyExchangeReceived(new Processor() {
@@ -87,6 +75,10 @@ public class CassandraComponentConsumerTest extends 
CamelTestSupport {
 
     @Test
     public void testConsumeOne() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         MockEndpoint mock = getMockEndpoint("mock:resultOne");
         mock.expectedMinimumMessageCount(1);
         mock.whenAnyExchangeReceived(new Processor() {

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
index 390ba0f..1578982 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
@@ -29,10 +29,7 @@ import com.datastax.driver.core.querybuilder.Update;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.cassandraunit.CassandraCQLUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -40,9 +37,8 @@ import static 
com.datastax.driver.core.querybuilder.QueryBuilder.bindMarker;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
-import static org.junit.Assume.assumeTrue;
 
-public class CassandraComponentProducerTest extends CamelTestSupport {
+public class CassandraComponentProducerTest extends BaseCassandraTest {
 
     private static final String CQL = "insert into camel_user(login, 
first_name, last_name) values (?, ?, ?)";
     private static final String NO_PARAMETER_CQL = "select login, first_name, 
last_name from camel_user";
@@ -66,21 +62,6 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
     @Produce(uri = "direct:inputNoEndpointCql")
     ProducerTemplate producerTemplateNoEndpointCql;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
-        }
-    }
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -102,6 +83,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testRequestUriCql() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Object response = 
producerTemplate.requestBody(Arrays.asList("w_jiang", "Willem", "Jiang"));
 
         Cluster cluster = CassandraUnitUtils.cassandraCluster();
@@ -117,6 +102,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testRequestNoParameterNull() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Object response = noParameterProducerTemplate.requestBody(null);
 
         assertNotNull(response);
@@ -126,6 +115,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testRequestNoParameterEmpty() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Object response = 
noParameterProducerTemplate.requestBody(Collections.emptyList());
 
         assertNotNull(response);
@@ -135,6 +128,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testRequestMessageCql() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Object response = producerTemplate.requestBodyAndHeader(new 
Object[]{"Claus 2", "Ibsen 2", "c_ibsen"},
                 CassandraConstants.CQL_QUERY, "update camel_user set 
first_name=?, last_name=? where login=?");
 
@@ -151,6 +148,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testLoadBalancing() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Object response = loadBalancingPolicyTemplate.requestBodyAndHeader(new 
Object[]{"Claus 2", "Ibsen 2", "c_ibsen"},
                 CassandraConstants.CQL_QUERY, "update camel_user set 
first_name=?, last_name=? where login=?");
 
@@ -170,6 +171,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
      */
     @Test
     public void testRequestMessageStatement() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Update.Where update = update("camel_user")
                 .with(set("first_name", bindMarker()))
                 .and(set("last_name", bindMarker()))
@@ -193,6 +198,10 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
      */
     @Test
     public void testEndpointNoCqlParameter() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         Update.Where updateFirstName = update("camel_user")
                 .with(set("first_name", bindMarker()))
                 .where(eq("login", bindMarker()));
@@ -227,6 +236,9 @@ public class CassandraComponentProducerTest extends 
CamelTestSupport {
 
     @Test
     public void testRequestNotConsistent() throws Exception {
+        if (!canTest()) {
+            return;
+        }
 
         CassandraEndpoint endpoint = getMandatoryEndpoint(NOT_CONSISTENT_URI, 
CassandraEndpoint.class);
         assertEquals(ConsistencyLevel.ANY, endpoint.getConsistencyLevel());

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerUnpreparedTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerUnpreparedTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerUnpreparedTest.java
index dcdef72..348b6a4 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerUnpreparedTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerUnpreparedTest.java
@@ -27,19 +27,15 @@ import com.datastax.driver.core.querybuilder.Update;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.cassandraunit.CassandraCQLUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
 import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
-import static org.junit.Assume.assumeTrue;
 
-public class CassandraComponentProducerUnpreparedTest extends CamelTestSupport 
{
+public class CassandraComponentProducerUnpreparedTest extends 
BaseCassandraTest {
 
     private static final String CQL = "insert into camel_user(login, 
first_name, last_name) values (?, ?, ?)";
     private static final String NO_PARAMETER_CQL = "select login, first_name, 
last_name from camel_user";
@@ -53,21 +49,6 @@ public class CassandraComponentProducerUnpreparedTest 
extends CamelTestSupport {
     @Produce(uri = "direct:inputNoParameter")
     ProducerTemplate noParameterProducerTemplate;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
-        }
-    }
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
index f7ab788..c248371 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
@@ -22,28 +22,21 @@ import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.component.cassandra.BaseCassandraTest;
 import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unite test for {@link CassandraAggregationRepository}
  */
-public class CassandraAggregationRepositoryTest {
+public class CassandraAggregationRepositoryTest extends BaseCassandraTest {
+
     @Rule
     public CassandraCQLUnit cassandraRule = 
CassandraUnitUtils.cassandraCQLUnit("AggregationDataSet.cql");
 
@@ -52,34 +45,24 @@ public class CassandraAggregationRepositoryTest {
     private CassandraAggregationRepository aggregationRepository;
     private CamelContext camelContext;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
     @Before
     public void setUp() throws Exception {
         camelContext = new DefaultCamelContext();
-        cluster = CassandraUnitUtils.cassandraCluster();
-        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
-        aggregationRepository = new CassandraAggregationRepository(session);
-        aggregationRepository.start();
+
+        if (canTest()) {
+            cluster = CassandraUnitUtils.cassandraCluster();
+            session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+            aggregationRepository = new 
CassandraAggregationRepository(session);
+            aggregationRepository.start();
+        }
     }
 
     @After
     public void tearDown() throws Exception {
-        aggregationRepository.stop();
-        session.close();
-        cluster.close();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            aggregationRepository.stop();
+            session.close();
+            cluster.close();
         }
     }
 
@@ -103,6 +86,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testGetExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Get_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -117,6 +104,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testGetNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Get_NotExists";
         assertFalse(exists(key));
@@ -128,6 +119,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testRemoveExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -141,6 +136,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testRemoveNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "RemoveNotExists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -153,6 +152,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testGetKeys() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"GetKeys1", "GetKeys2"};
         addExchanges(keys);
@@ -166,6 +169,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testConfirmExist() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         for (int i = 1; i < 4; i++) {
             String key = "Confirm_" + i;
@@ -184,6 +191,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testConfirmNotExist() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = new String[3];
         for (int i = 1; i < 4; i++) {
@@ -211,6 +222,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testScan() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"Scan1", "Scan2"};
         addExchanges(keys);
@@ -224,6 +239,10 @@ public class CassandraAggregationRepositoryTest {
 
     @Test
     public void testRecover() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"Recover1", "Recover2"};
         addExchanges(keys);

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationSerializedHeadersTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationSerializedHeadersTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationSerializedHeadersTest.java
index b6893dc..3231b4f 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationSerializedHeadersTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationSerializedHeadersTest.java
@@ -25,7 +25,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.processor.aggregate.util.HeaderDto;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.AfterClass;
 import org.junit.Test;
 
 import static org.junit.Assume.assumeTrue;

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
index 13fe47e..907087c 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
@@ -24,11 +24,8 @@ import 
org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.AfterClass;
 import org.junit.Test;
 
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unite test for {@link CassandraAggregationRepository}
  */
@@ -36,29 +33,37 @@ public class CassandraAggregationTest extends 
CamelTestSupport {
     private Cluster cluster;
     private CassandraAggregationRepository aggregationRepository;
 
+    public static boolean canTest() {
+        // we cannot test on CI
+        return System.getenv("BUILD_ID") == null;
+    }
+
     @Override
     protected void doPreSetup() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-        cluster = CassandraUnitUtils.cassandraCluster();
-        Session rootSession = cluster.connect();
-        CassandraUnitUtils.loadCQLDataSet(rootSession, 
"NamedAggregationDataSet.cql");
-        rootSession.close();
-        aggregationRepository = new 
NamedCassandraAggregationRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
-        aggregationRepository.setTable("NAMED_CAMEL_AGGREGATION");
-        aggregationRepository.start();
+        if (canTest()) {
+            CassandraUnitUtils.startEmbeddedCassandra();
+            cluster = CassandraUnitUtils.cassandraCluster();
+            Session rootSession = cluster.connect();
+            CassandraUnitUtils.loadCQLDataSet(rootSession, 
"NamedAggregationDataSet.cql");
+            rootSession.close();
+            aggregationRepository = new 
NamedCassandraAggregationRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
+            aggregationRepository.setTable("NAMED_CAMEL_AGGREGATION");
+            aggregationRepository.start();
+        }
         super.doPreSetup();
     }
 
     @Override
     public void tearDown() throws Exception {
         super.tearDown();
-        aggregationRepository.stop();
-        cluster.close();
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            aggregationRepository.stop();
+            cluster.close();
+            try {
+                CassandraUnitUtils.cleanEmbeddedCassandra();
+            } catch (Throwable e) {
+                // ignore shutdown errors
+            }
         }
     }
 
@@ -94,6 +99,10 @@ public class CassandraAggregationTest extends 
CamelTestSupport {
 
     @Test
     public void testAggregationRoute() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         MockEndpoint mockOutput = getMockEndpoint("mock:output");
         mockOutput.expectedMessageCount(2);
@@ -106,6 +115,5 @@ public class CassandraAggregationTest extends 
CamelTestSupport {
         send("1", "E");
         // Then
         mockOutput.assertIsSatisfied(4000L);
-
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepositoryTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepositoryTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepositoryTest.java
index d9e3bca..ea34732 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepositoryTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepositoryTest.java
@@ -22,28 +22,21 @@ import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.component.cassandra.BaseCassandraTest;
 import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unite test for {@link CassandraAggregationRepository}
  */
-public class NamedCassandraAggregationRepositoryTest {
+public class NamedCassandraAggregationRepositoryTest extends BaseCassandraTest 
{
+
     @Rule
     public CassandraCQLUnit cassandraRule = 
CassandraUnitUtils.cassandraCQLUnit("NamedAggregationDataSet.cql");
 
@@ -52,35 +45,24 @@ public class NamedCassandraAggregationRepositoryTest {
     private CassandraAggregationRepository aggregationRepository;
     private CamelContext camelContext;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
     @Before
     public void setUp() throws Exception {
         camelContext = new DefaultCamelContext();
-        cluster = CassandraUnitUtils.cassandraCluster();
-        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
-        aggregationRepository = new 
NamedCassandraAggregationRepository(session, "ID");
-        aggregationRepository.setTable("NAMED_CAMEL_AGGREGATION");
-        aggregationRepository.start();
+        if (canTest()) {
+            cluster = CassandraUnitUtils.cassandraCluster();
+            session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+            aggregationRepository = new 
NamedCassandraAggregationRepository(session, "ID");
+            aggregationRepository.setTable("NAMED_CAMEL_AGGREGATION");
+            aggregationRepository.start();
+        }
     }
 
     @After
     public void tearDown() throws Exception {
-        aggregationRepository.stop();
-        session.close();
-        cluster.close();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            aggregationRepository.stop();
+            session.close();
+            cluster.close();
         }
     }
 
@@ -92,6 +74,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testAdd() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Add";
         assertFalse(exists(key));
@@ -104,6 +90,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testGetExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Get_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -118,6 +108,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testGetNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Get_NotExists";
         assertFalse(exists(key));
@@ -129,6 +123,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testRemoveExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -142,6 +140,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testRemoveNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "RemoveNotExists";
         Exchange exchange = new DefaultExchange(camelContext);
@@ -154,6 +156,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testGetKeys() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"GetKeys1", "GetKeys2"};
         addExchanges(keys);
@@ -167,6 +173,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testConfirmExist() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         for (int i = 1; i < 4; i++) {
             String key = "Confirm_" + i;
@@ -185,6 +195,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testConfirmNotExist() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = new String[3];
         for (int i = 1; i < 4; i++) {
@@ -212,6 +226,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testScan() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"Scan1", "Scan2"};
         addExchanges(keys);
@@ -225,6 +243,10 @@ public class NamedCassandraAggregationRepositoryTest {
 
     @Test
     public void testRecover() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String[] keys = {"Recover1", "Recover2"};
         addExchanges(keys);

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
index be4e4cb..5bd044f 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
@@ -18,23 +18,19 @@ package org.apache.camel.processor.idempotent.cassandra;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
+import org.apache.camel.component.cassandra.BaseCassandraTest;
 import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unit test for {@link CassandraIdempotentRepository}
  */
-public class CassandraIdempotentRepositoryTest {
+public class CassandraIdempotentRepositoryTest extends BaseCassandraTest {
+
     @Rule
     public CassandraCQLUnit cassandraRule = 
CassandraUnitUtils.cassandraCQLUnit("IdempotentDataSet.cql");
 
@@ -42,33 +38,22 @@ public class CassandraIdempotentRepositoryTest {
     private Session session;
     private CassandraIdempotentRepository<String> idempotentRepository;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
     @Before
     public void setUp() throws Exception {
-        cluster = CassandraUnitUtils.cassandraCluster();
-        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
-        idempotentRepository = new 
CassandraIdempotentRepository<String>(session);
-        idempotentRepository.start();
+        if (canTest()) {
+            cluster = CassandraUnitUtils.cassandraCluster();
+            session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+            idempotentRepository = new 
CassandraIdempotentRepository<String>(session);
+            idempotentRepository.start();
+        }
     }
 
     @After
     public void tearDown() throws Exception {
-        idempotentRepository.stop();
-        session.close();
-        cluster.close();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            idempotentRepository.stop();
+            session.close();
+            cluster.close();
         }
     }
 
@@ -80,6 +65,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testAddNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Add_NotExists";
         assertFalse(exists(key));
@@ -92,6 +81,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testAddExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Add_Exists";
         assertTrue(exists(key));
@@ -104,6 +97,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testContainsNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Contains_NotExists";
         assertFalse(exists(key));
@@ -115,6 +112,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testContainsExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Contains_Exists";
         assertTrue(exists(key));
@@ -126,6 +127,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testRemoveNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_NotExists";
         assertFalse(exists(key));
@@ -137,6 +142,10 @@ public class CassandraIdempotentRepositoryTest {
 
     @Test
     public void testRemoveExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         assertTrue(exists(key));
@@ -148,6 +157,10 @@ public class CassandraIdempotentRepositoryTest {
     
     @Test
     public void testClear() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         assertTrue(exists(key));

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
index 134ddad..618f592 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
@@ -19,42 +19,38 @@ package org.apache.camel.processor.idempotent.cassandra;
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cassandra.BaseCassandraTest;
 import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unite test for {@link CassandraIdempotentRepository}
  */
-public class CassandraIdempotentTest extends CamelTestSupport {
+public class CassandraIdempotentTest extends BaseCassandraTest {
+
     private Cluster cluster;
     private CassandraIdempotentRepository idempotentRepository;
 
     @Override
     protected void doPreSetup() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-        cluster = CassandraUnitUtils.cassandraCluster();
-        Session rootSession = cluster.connect();
-        CassandraUnitUtils.loadCQLDataSet(rootSession, 
"NamedIdempotentDataSet.cql");
-        rootSession.close();
-        idempotentRepository = new NamedCassandraIdempotentRepository(cluster, 
CassandraUnitUtils.KEYSPACE, "ID");
-        idempotentRepository.setTable("NAMED_CAMEL_IDEMPOTENT");
-        idempotentRepository.start();
+        if (canTest()) {
+            cluster = CassandraUnitUtils.cassandraCluster();
+            Session rootSession = cluster.connect();
+            CassandraUnitUtils.loadCQLDataSet(rootSession, 
"NamedIdempotentDataSet.cql");
+            rootSession.close();
+            idempotentRepository = new 
NamedCassandraIdempotentRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
+            idempotentRepository.setTable("NAMED_CAMEL_IDEMPOTENT");
+            idempotentRepository.start();
+        }
         super.doPreSetup();
     }
 
     @Override
     public void tearDown() throws Exception {
         super.tearDown();
-        idempotentRepository.stop();
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            idempotentRepository.stop();
         }
     }
 
@@ -76,6 +72,10 @@ public class CassandraIdempotentTest extends 
CamelTestSupport {
 
     @Test
     public void testIdempotentRoute() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         MockEndpoint mockOutput = getMockEndpoint("mock:output");
         mockOutput.expectedMessageCount(2);

http://git-wip-us.apache.org/repos/asf/camel/blob/541114c1/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepositoryTest.java
 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepositoryTest.java
index fbd62af..199f366 100644
--- 
a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepositoryTest.java
+++ 
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepositoryTest.java
@@ -18,24 +18,19 @@ package org.apache.camel.processor.idempotent.cassandra;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
-
+import org.apache.camel.component.cassandra.BaseCassandraTest;
 import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
 /**
  * Unit test for {@link CassandraIdempotentRepository}
  */
-public class NamedCassandraIdempotentRepositoryTest {
+public class NamedCassandraIdempotentRepositoryTest extends BaseCassandraTest {
+
     @Rule
     public CassandraCQLUnit cassandraRule = 
CassandraUnitUtils.cassandraCQLUnit("NamedIdempotentDataSet.cql");
 
@@ -43,34 +38,23 @@ public class NamedCassandraIdempotentRepositoryTest {
     private Session session;
     private CassandraIdempotentRepository<String> idempotentRepository;
 
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        assumeTrue("Skipping test running in CI server - Fails sometimes on CI 
server with address already in use", System.getenv("BUILD_ID") == null);
-        CassandraUnitUtils.startEmbeddedCassandra();
-    }
-
     @Before
     public void setUp() throws Exception {
-        cluster = CassandraUnitUtils.cassandraCluster();
-        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
-        idempotentRepository = new 
NamedCassandraIdempotentRepository<String>(session, "ID");
-        idempotentRepository.setTable("NAMED_CAMEL_IDEMPOTENT");
-        idempotentRepository.start();
+        if (canTest()) {
+            cluster = CassandraUnitUtils.cassandraCluster();
+            session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+            idempotentRepository = new 
NamedCassandraIdempotentRepository<String>(session, "ID");
+            idempotentRepository.setTable("NAMED_CAMEL_IDEMPOTENT");
+            idempotentRepository.start();
+        }
     }
 
     @After
     public void tearDown() throws Exception {
-        idempotentRepository.stop();
-        session.close();
-        cluster.close();
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-        try {
-            CassandraUnitUtils.cleanEmbeddedCassandra();
-        } catch (Throwable e) {
-            // ignore shutdown errors
+        if (canTest()) {
+            idempotentRepository.stop();
+            session.close();
+            cluster.close();
         }
     }
 
@@ -82,6 +66,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testAddNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Add_NotExists";
         assertFalse(exists(key));
@@ -94,6 +82,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testAddExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Add_Exists";
         assertTrue(exists(key));
@@ -106,6 +98,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testContainsNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Contains_NotExists";
         assertFalse(exists(key));
@@ -117,6 +113,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testContainsExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Contains_Exists";
         assertTrue(exists(key));
@@ -128,6 +128,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testRemoveNotExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_NotExists";
         assertFalse(exists(key));
@@ -139,6 +143,10 @@ public class NamedCassandraIdempotentRepositoryTest {
 
     @Test
     public void testRemoveExists() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         assertTrue(exists(key));
@@ -150,6 +158,10 @@ public class NamedCassandraIdempotentRepositoryTest {
     
     @Test
     public void testClear() {
+        if (!canTest()) {
+            return;
+        }
+
         // Given
         String key = "Remove_Exists";
         assertTrue(exists(key));

Reply via email to