@Test(groups = "unit") public void should_drop_keyspace() throws Exception { // When SchemaStatement statement = dropKeyspace("test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP KEYSPACE test"); }
protected void clearKeyspace() { // Drop keyspace with non-keyspace-session Statement stmt = SchemaBuilder.dropKeyspace(this.keyspace).ifExists(); LOG.debug("Drop keyspace: {}", stmt); Session session = this.cluster().connect(); try { session.execute(stmt); } finally { if (!session.isClosed()) { session.close(); } } }
@Test(groups = "unit") public void should_drop_keyspace_if_exists() throws Exception { // When SchemaStatement statement = dropKeyspace("test").ifExists(); // Then assertThat(statement.getQueryString()).isEqualTo("DROP KEYSPACE IF EXISTS test"); } }
@Override public void deleteAll() throws Exception { state.tableExistsCache.clear(); state.preparedRangeReadsPerTable.clear(); state.preparedRowReadPerTable.clear(); state.preparedWritesPerTable.clear(); session.execute(SchemaBuilder.dropKeyspace(gwNamespace).ifExists()); }
@Test(groups = "unit") public void should_drop_keyspace() throws Exception { // When SchemaStatement statement = dropKeyspace("test"); // Then assertThat(statement.getQueryString()).isEqualTo("DROP KEYSPACE test"); }
protected void clearKeyspace() { // Drop keyspace with non-keyspace-session Statement stmt = SchemaBuilder.dropKeyspace(this.keyspace).ifExists(); LOG.debug("Drop keyspace: {}", stmt); Session session = this.cluster().connect(); try { session.execute(stmt); } finally { if (!session.isClosed()) { session.close(); } } }
@Test(groups = "unit") public void should_drop_keyspace_if_exists() throws Exception { // When SchemaStatement statement = dropKeyspace("test").ifExists(); // Then assertThat(statement.getQueryString()).isEqualTo("DROP KEYSPACE IF EXISTS test"); } }
@Override public void clearStorage() throws BackendException { if (this.storageConfig.get(DROP_ON_CLEAR)) { this.session.execute(dropKeyspace(this.keyspace)); } else if (this.exists()) { final Future<Seq<ResultSet>> result = Future.sequence( Iterator.ofAll(this.cluster.getMetadata().getKeyspace(this.keyspace).getTables()) .map(table -> Future.fromJavaFuture(this.session.executeAsync(truncate(this.keyspace, table.getName()))))); result.await(); } else { LOGGER.info("Keyspace {} does not exist in the cluster", this.keyspace); } }