public void dropTable(CassandraSessionPool.Session session) { session.execute(SchemaBuilder.dropTable(this.table).ifExists()); }
@Test(groups = "unit") public void should_drop_table() throws Exception { // When SchemaStatement statement = dropTable("test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE test"); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The keyspace name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_keyspace_name_is_a_reserved_keyword() throws Exception { dropTable("add", "test").getQueryString(); }
@Test(groups = "unit") public void should_drop_table_with_keyspace() throws Exception { // When SchemaStatement statement = dropTable("ks", "test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE ks.test"); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The table name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_table_name_is_a_reserved_keyword() throws Exception { dropTable("add").getQueryString(); } }
protected void dropTable(CassandraSessionPool.Session session) { LOG.debug("Drop table: {}", this.table()); session.execute(SchemaBuilder.dropTable(this.table()).ifExists()); }
@Test(groups = "unit") public void should_drop_table_with_keyspace_if_exists() throws Exception { // When SchemaStatement statement = dropTable("ks", "test").ifExists(); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE IF EXISTS ks.test"); }
@Override protected void dropTable(CassandraSessionPool.Session session) { session.execute(SchemaBuilder.dropTable(indexTable()).ifExists()); super.dropTable(session); }
@Override protected void dropTable(CassandraSessionPool.Session session) { session.execute(SchemaBuilder.dropTable(indexTable()).ifExists()); super.dropTable(session); }
@Test(groups = "short") public void should_drop_a_table() { // Create a table session() .execute( SchemaBuilder.createTable("ks", "DropTable").addPartitionKey("a", DataType.cint())); // Drop the table session().execute(SchemaBuilder.dropTable("ks", "DropTable")); session().execute(SchemaBuilder.dropTable("DropTable").ifExists()); ResultSet rows = session() .execute( "SELECT columnfamily_name " + "FROM system.schema_columnfamilies " + "WHERE keyspace_name='ks' AND columnfamily_name='droptable'"); if (rows.iterator().hasNext()) { fail("This table should have been deleted"); } }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The keyspace name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_keyspace_name_is_a_reserved_keyword() throws Exception { dropTable("add", "test").getQueryString(); }
@Test(groups = "unit") public void should_drop_table_with_keyspace() throws Exception { // When SchemaStatement statement = dropTable("ks", "test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE ks.test"); }
@Test( groups = "unit", expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The table name 'add' is not allowed because it is a reserved keyword") public void should_fail_if_table_name_is_a_reserved_keyword() throws Exception { dropTable("add").getQueryString(); } }
@Test(groups = "unit") public void should_drop_table() throws Exception { // When SchemaStatement statement = dropTable("test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE test"); }
@Test(groups = "unit") public void should_drop_table_with_keyspace_if_exists() throws Exception { // When SchemaStatement statement = dropTable("ks", "test").ifExists(); // Then assertThat(statement.getQueryString()).isEqualTo("DROP TABLE IF EXISTS ks.test"); }
@Override protected void dropTable(CassandraSessionPool.Session session) { session.execute(SchemaBuilder.dropTable(indexTable()).ifExists()); super.dropTable(session); }
@Override protected void dropTable(CassandraSessionPool.Session session) { session.execute(SchemaBuilder.dropTable(indexTable()).ifExists()); super.dropTable(session); }
private static void cleanCassandra(Session session) { MODULE.moduleTables().forEach(table -> session.execute(SchemaBuilder.dropTable(table.getName()))); MODULE.moduleTypes().forEach(type -> session.execute(SchemaBuilder.dropType(type.getName()))); }
@Test void initializeTableShouldCreateAllTheTables() { cassandra.getConf().execute(SchemaBuilder.dropTable(TABLE_NAME)); cassandra.getConf().execute(SchemaBuilder.dropTable(CassandraSchemaVersionTable.TABLE_NAME)); assertThat(new CassandraTableManager(MODULE, cassandra.getConf()).initializeTables()) .isEqualByComparingTo(CassandraTable.InitializationStatus.FULL); ensureTableExistence(TABLE_NAME); }
@Test void initializeTableShouldCreateAllTheMissingTable() { cassandra.getConf().execute(SchemaBuilder.dropTable(TABLE_NAME)); assertThat(new CassandraTableManager(MODULE, cassandra.getConf()).initializeTables()) .isEqualByComparingTo(CassandraTable.InitializationStatus.PARTIAL); ensureTableExistence(TABLE_NAME); }