package com.github.hiendo.tsa.db;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

// http://www.datastax.com/documentation/developer/java-driver/2.0/java-driver/quick_start/qsSimpleClientAddSession_t.html
public class AbstractDbBaseTests {
    protected String keyspace = "tsa";

    protected Session session;
    protected Cluster cluster;

    @BeforeClass
    public void setupDbBeforeClass() throws Exception {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra("embeddedDbTestCassandraConfig.yml");
        cluster = new Cluster.Builder().addContactPoints("localhost").withPort(9142).build();
        session = cluster.connect();

        CQLDataLoader dataLoader = new CQLDataLoader(session);
        dataLoader.load(new ClassPathCQLDataSet("schema.cql"));
    }

    @AfterClass
    public void cleanupDbAfterClass() {
        cluster.close();
        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
    }
}

@@ -610,47 +610,8 @@
 ts %7B
-%0A    protected String keyspace = %22tsa%22;
 %0A%0A  
@@ -630,17 +630,26 @@
 Session 
-s
+cassandraS
 ession;%0A
@@ -753,16 +753,155 @@
 ption %7B%0A
+        /**%0A         * @todo: can't use this class since it collides with server tests which brings up DB once in @BeforeSuite%0A         */%0A
         
@@ -957,43 +957,8 @@
 dra(
-%22embeddedDbTestCassandraConfig.yml%22
 );%0A 
@@ -1058,17 +1058,26 @@
         
-s
+cassandraS
 ession =
@@ -1150,17 +1150,26 @@
 aLoader(
-s
+cassandraS
 ession);

Comment on why we can't use AbstractDbBaseTests