public class CassandraTestDB extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected com.datastax.driver.core.Session |
session |
| Constructor and Description |
|---|
CassandraTestDB(CassandraSessionFactory sessionFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Cleanup strategy to that truncates known tables.
|
void |
close()
Shuts down DataStax Java driver Session and Cluster objects safely
|
Long |
count(String table)
count on a given table.
|
static CassandraTestDB |
create()
Factory method for CassandraTestDB using default ConfigFinderImpl
|
static CassandraTestDB |
create(ConfigFinder configFinder)
Factory method for CassandraTestDB with optional ConfigFinder override.
|
void |
createTestKeyspace(String keyspaceName)
creates a simple keyspace for testing purposes with SimpleStrategy and replication factor of 1
will blow it away on test teardown
|
void |
deleteTestKeyspaceIfExists(String keyspaceName)
drops the keyspace if it doesn't exist.
|
com.datastax.driver.core.ResultSet |
execute(com.datastax.driver.core.Statement statement)
session.execute wrapper
|
com.datastax.driver.core.Session |
getSession()
Just returns the internal session object.
|
protected void |
markForCleanUp(FullTableName fullTableName) |
void |
markForCleanUp(String table)
assumes keyspace is already wired up
|
void |
markForCleanUp(String keyspace,
String tableName)
Mark table for cleanup.
|
boolean |
tableExists(String keyspaceName,
String tableName)
simple utility check to see if table exists, does mark table for cleanup if it does
|
public CassandraTestDB(CassandraSessionFactory sessionFactory)
sessionFactory - owns the session object and responsible for setupprotected void markForCleanUp(FullTableName fullTableName)
public static CassandraTestDB create() throws IOException
IOExceptionpublic static CassandraTestDB create(ConfigFinder configFinder) throws IOException
IOException - when config file not found.public void cleanUp()
public void markForCleanUp(String keyspace, String tableName)
keyspace - keyspace where the table livestableName - table to truncatepublic void markForCleanUp(String table)
table - table to mark for cleanuppublic com.datastax.driver.core.Session getSession()
public void createTestKeyspace(String keyspaceName)
keyspaceName - public boolean tableExists(String keyspaceName, String tableName)
keyspaceName - tableName - public void deleteTestKeyspaceIfExists(String keyspaceName)
keyspaceName - public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic com.datastax.driver.core.ResultSet execute(com.datastax.driver.core.Statement statement)
statement - statement to executeCopyright © 2015. All rights reserved.