From 4ac4d1df29d27d9a6bce10c6bf0d46b1c5f00b46 Mon Sep 17 00:00:00 2001 From: David Webb Date: Thu, 16 Jan 2014 00:58:05 -0500 Subject: [PATCH] DATACASS-70 - Fixed Table Lifecycle test with new Unit test strategy. --- .../AbstractEmbeddedCassandraIntegrationTest.java | 4 ++++ .../generator/TableLifecycleIntegrationTest.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java index d7f62cffe..e4e6fade6 100644 --- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java +++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java @@ -81,7 +81,11 @@ public abstract class AbstractEmbeddedCassandraIntegrationTest { } public void connect() { + if (connect && !connected()) { + + log.info("Connecting to Cassandra"); + cluster = cluster(); if (keyspace() == null) { diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTest.java index 60e55c9a8..689895a81 100644 --- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTest.java +++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableLifecycleIntegrationTest.java @@ -18,6 +18,9 @@ package org.springframework.cassandra.test.integration.core.cql.generator; import static org.springframework.cassandra.test.integration.core.cql.generator.CqlTableSpecificationAssertions.assertNoTable; import static org.springframework.cassandra.test.integration.core.cql.generator.CqlTableSpecificationAssertions.assertTable; +import org.cassandraunit.CassandraCQLUnit; +import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; +import org.junit.Rule; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,6 +42,18 @@ public class TableLifecycleIntegrationTest extends AbstractEmbeddedCassandraInte CreateTableCqlGeneratorTests.MultipleOptionsTest createTableTest = new CreateTableCqlGeneratorTests.MultipleOptionsTest(); + public TableLifecycleIntegrationTest() { + super("tlit"); + clear = true; + } + + // This only ensures the keyspace exists before each test, while using a static session from the parent object. + // TODO - DW Make this better. + @Rule + public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet( + "cassandraOperationsTest-cql-dataload.cql", this.keyspace), CASSANDRA_CONFIG, CASSANDRA_HOST, + CASSANDRA_NATIVE_PORT); + @Test public void testDrop() {