diff --git a/pom.xml b/pom.xml
index b6ad3dc88..1dad257bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -260,7 +260,8 @@
maven-failsafe-plugin
${failsafe.version}
- always
+ 1
+ true
-Xmx2048m -XX:MaxPermSize=512m
false
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 a9a7022e0..3315c021a 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
@@ -1,117 +1,72 @@
package org.springframework.cassandra.test.integration;
import java.io.IOException;
-import java.util.UUID;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
-import org.junit.After;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.cassandra.test.unit.support.Utils;
import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.Session;
-public abstract class AbstractEmbeddedCassandraIntegrationTest {
+/**
+ * Abstract base integration test class that starts an embedded Cassandra instance.
+ *
+ * @author Matthew T. Adams
+ */
+public class AbstractEmbeddedCassandraIntegrationTest {
- private static Logger log = LoggerFactory.getLogger(AbstractEmbeddedCassandraIntegrationTest.class);
+ static Logger log = LoggerFactory.getLogger(AbstractEmbeddedCassandraIntegrationTest.class);
- protected final static String CASSANDRA_CONFIG = "spring-cassandra.yaml";
- protected final static String CASSANDRA_HOST = "localhost";
- protected final static int CASSANDRA_NATIVE_PORT = 9042;
+ protected static final String CASSANDRA_CONFIG = "spring-cassandra.yaml";
+ protected static final String CASSANDRA_HOST = "localhost";
+ protected static final int CASSANDRA_NATIVE_PORT = 9042;
+
+ /**
+ * The session connected to the system keyspace.
+ */
+ protected static Session SYSTEM;
+ /**
+ * The {@link Cluster} that's connected to Cassandra.
+ */
+ protected static Cluster CLUSTER;
+
+ public static String randomKeyspaceName() {
+ return Utils.randomKeyspaceName();
+ }
@BeforeClass
public static void startCassandra() throws ConfigurationException, TTransportException, IOException,
InterruptedException {
- log.info("Starting Cassandra Embedded Server");
+
EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_CONFIG);
}
- public AbstractEmbeddedCassandraIntegrationTest() {
- if (session == null) {
- connect();
- }
- }
-
- public AbstractEmbeddedCassandraIntegrationTest(String keyspace) {
- this.keyspace = keyspace;
- if (session == null) {
- connect();
- }
- }
-
- /**
- * Whether to clear the cluster before the next test.
- */
- protected boolean clear = false;
- /**
- * Whether to connect to Cassandra.
- */
- protected boolean connect = true;
- /**
- * The {@link Cluster} that's connected to Cassandra.
- */
- protected Cluster cluster;
- /**
- * If not null, get a {@link Session} for the from the {@link #cluster}.
- */
- protected String keyspace = "ks" + UUID.randomUUID().toString().replace("-", "");
-
- /**
- * The {@link Session} for the {@link #keyspace} from the {@link #cluster}.
- */
- protected Session session;
-
- protected String keyspace() {
- return keyspace;
- }
-
- /**
- * Returns whether we're currently connected to the cluster.
- */
- public boolean connected() {
- return session != null;
- }
-
- public Cluster cluster() {
+ public static Cluster cluster() {
return Cluster.builder().addContactPoint(CASSANDRA_HOST).withPort(CASSANDRA_NATIVE_PORT).build();
}
- public void connect() {
+ /**
+ * Ensures that the cluster is created and that the session {@link #SYSTEM} is connected to it.
+ */
+ public static void ensureClusterConnection() {
- if (connect && !connected()) {
+ // check cluster
+ if (CLUSTER == null) {
+ CLUSTER = cluster();
+ }
- log.info("Connecting to Cassandra");
-
- cluster = cluster();
-
- if (keyspace() == null) {
- session = cluster.connect();
- } else {
-
- KeyspaceMetadata kmd = cluster.getMetadata().getKeyspace(keyspace());
- if (kmd == null) { // then create keyspace
- session = cluster.connect();
- session.execute("CREATE KEYSPACE " + keyspace()
- + " WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};");
- session.execute("USE " + keyspace() + ";");
- } else {// else keyspace already exists
- session = cluster.connect(keyspace());
- }
- }
+ // check system session connected
+ if (SYSTEM == null) {
+ SYSTEM = CLUSTER.connect();
}
}
- @After
- public void after() {
- log.info("After: clear -> " + clear + ", connected -> " + connected());
- if (clear && connected()) {
- log.info("Cleaning Cassandra");
- EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
- }
+ public AbstractEmbeddedCassandraIntegrationTest() {
+ ensureClusterConnection();
}
-
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java
new file mode 100644
index 000000000..b9e04f827
--- /dev/null
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/AbstractKeyspaceCreatingIntegrationTest.java
@@ -0,0 +1,109 @@
+package org.springframework.cassandra.test.integration;
+
+import org.junit.After;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+import com.datastax.driver.core.KeyspaceMetadata;
+import com.datastax.driver.core.Session;
+
+/**
+ * Abstract base integration test class that creates a keyspace
+ *
+ * @author Matthew T. Adams
+ */
+public abstract class AbstractKeyspaceCreatingIntegrationTest extends AbstractEmbeddedCassandraIntegrationTest {
+
+ static Logger log = LoggerFactory.getLogger(AbstractKeyspaceCreatingIntegrationTest.class);
+
+ /**
+ * The session that's connected to the keyspace used in the current instance's test.
+ */
+ protected static Session SESSION;
+
+ /**
+ * The name of the keyspace to use for this test instance.
+ */
+ protected String keyspace;
+
+ public AbstractKeyspaceCreatingIntegrationTest() {
+ this(randomKeyspaceName());
+ }
+
+ public AbstractKeyspaceCreatingIntegrationTest(String keyspace) {
+
+ this.keyspace = keyspace;
+ ensureKeyspaceAndSession();
+ }
+
+ /**
+ * Returns whether we're currently connected to the keyspace.
+ */
+ public static boolean connected() {
+ return SESSION != null;
+ }
+
+ /**
+ * Whether to drop the keyspace that was created after the test has completed. Subclasses should override and return
+ * true, since this default implementation returns false.
+ */
+ public boolean dropKeyspaceAfterTest() {
+ return false;
+ }
+
+ public void ensureKeyspaceAndSession() {
+
+ // ensure that test keyspace exists
+
+ if (!StringUtils.hasText(keyspace)) {
+ keyspace = null;
+ }
+
+ if (keyspace != null) {
+ // see if we need to create the keyspace
+ KeyspaceMetadata kmd = CLUSTER.getMetadata().getKeyspace(keyspace);
+ if (kmd == null) { // then create keyspace
+
+ String cql = "CREATE KEYSPACE " + keyspace
+ + " WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};";
+ log.info("creating keyspace {} via CQL [{}]", keyspace, cql);
+
+ SYSTEM.execute(cql);
+ }
+ }
+
+ // keyspace now exists; ensure the session is using it
+ if (SESSION == null) {
+
+ log.info("connecting to keyspace {}", keyspace == null ? "system" : keyspace + "...");
+
+ SESSION = keyspace == null ? CLUSTER.connect() : CLUSTER.connect(keyspace);
+
+ log.info("connected to keyspace {}", keyspace == null ? "system" : keyspace);
+
+ } else {
+
+ log.info("session already connected to a keyspace; attempting to change to use {}", keyspace);
+
+ String cql = "USE " + (keyspace == null ? "system" : keyspace) + ";";
+ SESSION.execute(cql);
+
+ log.info("now using keyspace " + keyspace);
+ }
+ }
+
+ @After
+ public void after() {
+ if (dropKeyspaceAfterTest() && keyspace != null) {
+
+ SESSION.execute("USE system");
+
+ log.info("dropping keyspace {} ...", keyspace);
+
+ SYSTEM.execute("DROP KEYSPACE " + keyspace);
+
+ log.info("dropped keyspace {}", keyspace);
+ }
+ }
+}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigTest.java
index 0f639ec57..fe827695c 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/java/KeyspaceCreatingJavaConfigTest.java
@@ -1,28 +1,13 @@
package org.springframework.cassandra.test.integration.config.java;
-import javax.inject.Inject;
-
import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.springframework.cassandra.test.integration.config.IntegrationTestUtils;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.datastax.driver.core.Session;
-
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = KeyspaceCreatingJavaConfig.class)
public class KeyspaceCreatingJavaConfigTest extends AbstractIntegrationTest {
- @Inject
- protected Session session;
-
- @Override
- protected String keyspace() {
- return null;
- }
-
@Test
public void test() {
Assert.assertNotNull(session);
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigTest.java
index 44ac32069..228a3c70d 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/FullySpecifiedKeyspaceCreatingXmlConfigTest.java
@@ -15,11 +15,6 @@ import com.datastax.driver.core.Session;
@ContextConfiguration
public class FullySpecifiedKeyspaceCreatingXmlConfigTest extends AbstractEmbeddedCassandraIntegrationTest {
- @Override
- protected String keyspace() {
- return null;
- }
-
@Inject
Session s;
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigTest.java
index 492605316..6759daa2c 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalKeyspaceCreatingXmlConfigTest.java
@@ -15,11 +15,6 @@ import com.datastax.driver.core.Session;
@ContextConfiguration
public class MinimalKeyspaceCreatingXmlConfigTest extends AbstractEmbeddedCassandraIntegrationTest {
- @Override
- protected String keyspace() {
- return null;
- }
-
@Inject
Session s;
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigTest.java
index 760c00192..045d9788e 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/MinimalXmlConfigTest.java
@@ -1,13 +1,13 @@
package org.springframework.cassandra.test.integration.config.xml;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.cassandra.core.CassandraOperations;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.integration.config.IntegrationTestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -16,10 +16,12 @@ import com.datastax.driver.core.Session;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class MinimalXmlConfigTest extends AbstractEmbeddedCassandraIntegrationTest {
+public class MinimalXmlConfigTest extends AbstractKeyspaceCreatingIntegrationTest {
- protected String keyspace() {
- return "minimalxmlconfigtest";
+ public static final String KEYSPACE = "minimalxmlconfigtest";
+
+ public MinimalXmlConfigTest() {
+ super(KEYSPACE);
}
@Inject
@@ -31,7 +33,7 @@ public class MinimalXmlConfigTest extends AbstractEmbeddedCassandraIntegrationTe
@Test
public void test() {
IntegrationTestUtils.assertSession(s);
- IntegrationTestUtils.assertKeyspaceExists(keyspace(), s);
+ IntegrationTestUtils.assertKeyspaceExists(KEYSPACE, s);
assertNotNull(ops);
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigTest.java
index b8eb27ea8..28300bb12 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/config/xml/XmlConfigTest.java
@@ -4,7 +4,7 @@ import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.integration.config.IntegrationTestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -13,18 +13,20 @@ import com.datastax.driver.core.Session;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class XmlConfigTest extends AbstractEmbeddedCassandraIntegrationTest {
+public class XmlConfigTest extends AbstractKeyspaceCreatingIntegrationTest {
- protected String keyspace() {
- return "xmlconfigtest";
- }
+ public static final String KEYSPACE = "xmlconfigtest";
@Inject
Session s;
+ public XmlConfigTest() {
+ super(KEYSPACE);
+ }
+
@Test
public void test() {
IntegrationTestUtils.assertSession(s);
- IntegrationTestUtils.assertKeyspaceExists(keyspace(), s);
+ IntegrationTestUtils.assertKeyspaceExists(KEYSPACE, s);
}
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java
index 5c0add73b..d9c043916 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateIndexCqlGeneratorIntegrationTests.java
@@ -6,7 +6,7 @@ import org.cassandraunit.CassandraCQLUnit;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateIndexCqlGeneratorTests.BasicTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateIndexCqlGeneratorTests.CreateIndexTest;
@@ -24,7 +24,7 @@ public class CreateIndexCqlGeneratorIntegrationTests {
*
* @param The concrete unit test class to which this integration test corresponds.
*/
- public static abstract class Base extends AbstractEmbeddedCassandraIntegrationTest {
+ public static abstract class Base extends AbstractKeyspaceCreatingIntegrationTest {
T unit;
public abstract T unit();
@@ -34,9 +34,9 @@ public class CreateIndexCqlGeneratorIntegrationTests {
unit = unit();
unit.prepare();
- session.execute(unit.cql);
+ SESSION.execute(unit.cql);
- assertIndex(unit.specification, keyspace, session);
+ assertIndex(unit.specification, keyspace, SESSION);
}
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java
index 2524e0205..d71e79f14 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateKeyspaceCqlGeneratorIntegrationTests.java
@@ -30,9 +30,9 @@ public class CreateKeyspaceCqlGeneratorIntegrationTests {
unit = unit();
unit.prepare();
- session.execute(unit.cql);
+ SYSTEM.execute(unit.cql);
- assertKeyspace(unit.specification, unit.keyspace, session);
+ assertKeyspace(unit.specification, unit.keyspace, SYSTEM);
}
}
@@ -50,5 +50,5 @@ public class CreateKeyspaceCqlGeneratorIntegrationTests {
public NetworkTopologyTest unit() {
return new NetworkTopologyTest();
}
- }
+ }
}
\ No newline at end of file
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java
index 63806cbc7..fc4de3fbf 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/CreateTableCqlGeneratorIntegrationTests.java
@@ -5,7 +5,7 @@ import static org.springframework.cassandra.test.integration.core.cql.generator.
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCqlGeneratorTests.BasicTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCqlGeneratorTests.CompositePartitionKeyTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCqlGeneratorTests.CreateTableTest;
@@ -26,7 +26,7 @@ public class CreateTableCqlGeneratorIntegrationTests {
*
* @param The concrete unit test class to which this integration test corresponds.
*/
- public static abstract class Base extends AbstractEmbeddedCassandraIntegrationTest {
+ public static abstract class Base extends AbstractKeyspaceCreatingIntegrationTest {
T unit;
public abstract T unit();
@@ -36,9 +36,9 @@ public class CreateTableCqlGeneratorIntegrationTests {
unit = unit();
unit.prepare();
- session.execute(unit.cql);
+ SESSION.execute(unit.cql);
- assertTable(unit.specification, keyspace, session);
+ assertTable(unit.specification, keyspace, SESSION);
}
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java
index 0c01fdbd0..801655677 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/IndexLifecycleCqlGeneratorIntegrationTests.java
@@ -9,7 +9,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateIndexCqlGeneratorTests;
import org.springframework.cassandra.test.unit.core.cql.generator.DropIndexCqlGeneratorTests;
@@ -18,7 +18,7 @@ import org.springframework.cassandra.test.unit.core.cql.generator.DropIndexCqlGe
*
* @author Matthew T. Adams
*/
-public class IndexLifecycleCqlGeneratorIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest {
+public class IndexLifecycleCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
Logger log = LoggerFactory.getLogger(IndexLifecycleCqlGeneratorIntegrationTests.class);
@@ -42,19 +42,19 @@ public class IndexLifecycleCqlGeneratorIntegrationTests extends AbstractEmbedded
dropIfExists.prepare();
log.info(createTest.cql);
- session.execute(createTest.cql);
+ SESSION.execute(createTest.cql);
- assertIndex(createTest.specification, keyspace, session);
+ assertIndex(createTest.specification, keyspace, SESSION);
log.info(dropTest.cql);
- session.execute(dropTest.cql);
+ SESSION.execute(dropTest.cql);
- assertNoIndex(createTest.specification, keyspace, session);
+ assertNoIndex(createTest.specification, keyspace, SESSION);
// log.info(dropIfExists.cql);
- // session.execute(dropIfExists.cql);
+ // SESSION.execute(dropIfExists.cql);
//
- // assertNoIndex(createTest.specification, keyspace, session);
+ // assertNoIndex(createTest.specification, keyspace, SESSION);
}
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 689895a81..ca836b2af 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
@@ -26,7 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator;
import org.springframework.cassandra.core.keyspace.DropTableSpecification;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.unit.core.cql.generator.AlterTableCqlGeneratorTests;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCqlGeneratorTests;
import org.springframework.cassandra.test.unit.core.cql.generator.DropTableCqlGeneratorTests;
@@ -36,7 +36,7 @@ import org.springframework.cassandra.test.unit.core.cql.generator.DropTableCqlGe
*
* @author David Webb
*/
-public class TableLifecycleIntegrationTest extends AbstractEmbeddedCassandraIntegrationTest {
+public class TableLifecycleIntegrationTest extends AbstractKeyspaceCreatingIntegrationTest {
private final static Logger log = LoggerFactory.getLogger(TableLifecycleIntegrationTest.class);
@@ -44,10 +44,14 @@ public class TableLifecycleIntegrationTest extends AbstractEmbeddedCassandraInte
public TableLifecycleIntegrationTest() {
super("tlit");
- clear = true;
}
- // This only ensures the keyspace exists before each test, while using a static session from the parent object.
+ @Override
+ public boolean dropKeyspaceAfterTest() {
+ return 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(
@@ -61,18 +65,18 @@ public class TableLifecycleIntegrationTest extends AbstractEmbeddedCassandraInte
log.info(createTableTest.cql);
- session.execute(createTableTest.cql);
+ SESSION.execute(createTableTest.cql);
- assertTable(createTableTest.specification, keyspace, session);
+ assertTable(createTableTest.specification, keyspace, SESSION);
DropTableTest dropTest = new DropTableTest();
dropTest.prepare();
log.info(dropTest.cql);
- session.execute(dropTest.cql);
+ SESSION.execute(dropTest.cql);
- assertNoTable(dropTest.specification, keyspace, session);
+ assertNoTable(dropTest.specification, keyspace, SESSION);
}
@Test
@@ -82,18 +86,18 @@ public class TableLifecycleIntegrationTest extends AbstractEmbeddedCassandraInte
log.info(createTableTest.cql);
- session.execute(createTableTest.cql);
+ SESSION.execute(createTableTest.cql);
- assertTable(createTableTest.specification, keyspace, session);
+ assertTable(createTableTest.specification, keyspace, SESSION);
AlterTableCqlGeneratorTests.MultipleOptionsTest alterTest = new AlterTableCqlGeneratorTests.MultipleOptionsTest();
alterTest.prepare();
log.info(alterTest.cql);
- session.execute(alterTest.cql);
+ SESSION.execute(alterTest.cql);
- // assertTable(alterTest.specification, keyspace, session);
+ // assertTable(alterTest.specification, keyspace, SESSION);
}
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTest.java
index b0d0bd92b..5c2e3ae25 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/cql/generator/TableOptionsIntegrationTest.java
@@ -21,6 +21,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCqlGeneratorTests;
/**
@@ -28,7 +29,7 @@ import org.springframework.cassandra.test.unit.core.cql.generator.CreateTableCql
*
* @author David Webb
*/
-public class TableOptionsIntegrationTest extends AbstractEmbeddedCassandraIntegrationTest {
+public class TableOptionsIntegrationTest extends AbstractKeyspaceCreatingIntegrationTest {
private final static Logger log = LoggerFactory.getLogger(TableOptionsIntegrationTest.class);
@@ -41,8 +42,8 @@ public class TableOptionsIntegrationTest extends AbstractEmbeddedCassandraIntegr
log.info(optionsTest.cql);
- session.execute(optionsTest.cql);
+ SESSION.execute(optionsTest.cql);
- assertTable(optionsTest.specification, keyspace, session);
+ assertTable(optionsTest.specification, keyspace, SESSION);
}
}
\ No newline at end of file
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java
index da5a4f636..3b31ecffe 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/integration/core/template/CassandraOperationsTest.java
@@ -46,7 +46,7 @@ import org.springframework.cassandra.core.RowCallbackHandler;
import org.springframework.cassandra.core.RowIterator;
import org.springframework.cassandra.core.RowMapper;
import org.springframework.cassandra.core.SessionCallback;
-import org.springframework.cassandra.test.integration.AbstractEmbeddedCassandraIntegrationTest;
+import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.dao.DataAccessException;
import org.springframework.util.CollectionUtils;
@@ -65,7 +65,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author David Webb
*
*/
-public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegrationTest {
+public class CassandraOperationsTest extends AbstractKeyspaceCreatingIntegrationTest {
private static CassandraOperations cassandraTemplate;
@@ -89,8 +89,8 @@ public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegratio
CASSANDRA_NATIVE_PORT);
public CassandraOperationsTest() {
- super("sdctest");
- clear = true;
+ super();
+ // TODO clear = true;
}
@Before
@@ -106,7 +106,7 @@ public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegratio
// "cassandraOperationsTest-cql-dataload.cql", keyspace), CASSANDRA_CONFIG, CASSANDRA_HOST,
// CASSANDRA_NATIVE_PORT);
- cassandraTemplate = new CassandraTemplate(session);
+ cassandraTemplate = new CassandraTemplate(SESSION);
}
}
@@ -160,8 +160,6 @@ public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegratio
@SuppressWarnings("unchecked")
public void ingestionTestListOfList() {
- log.info("Keyspace => " + keyspace);
-
String cql = "insert into book (isbn, title, author, pages) values (?, ?, ?, ?)";
List> values = new LinkedList>();
@@ -185,8 +183,6 @@ public class CassandraOperationsTest extends AbstractEmbeddedCassandraIntegratio
@Test
public void ingestionTestObjectArray() {
- log.info("Keyspace => " + keyspace);
-
String cql = "insert into book (isbn, title, author, pages) values (?, ?, ?, ?)";
Object[][] values = new Object[3][];
diff --git a/spring-cassandra/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java b/spring-cassandra/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java
index f54ef316e..04e8eac5e 100644
--- a/spring-cassandra/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java
+++ b/spring-cassandra/src/test/java/org/springframework/cassandra/test/unit/core/cql/generator/AlterKeyspaceCqlGeneratorTests.java
@@ -11,6 +11,7 @@ import org.springframework.cassandra.core.keyspace.AlterKeyspaceSpecification;
import org.springframework.cassandra.core.keyspace.DefaultOption;
import org.springframework.cassandra.core.keyspace.KeyspaceOption;
import org.springframework.cassandra.core.keyspace.Option;
+import org.springframework.cassandra.test.unit.support.Utils;
public class AlterKeyspaceCqlGeneratorTests {
@@ -23,8 +24,8 @@ public class AlterKeyspaceCqlGeneratorTests {
private static void assertReplicationMap(Map