Skip to content

Instantly share code, notes, and snippets.

@jsevellec
Last active December 18, 2015 22:59
Show Gist options
  • Save jsevellec/5858799 to your computer and use it in GitHub Desktop.
Save jsevellec/5858799 to your computer and use it in GitHub Desktop.
a cassandra-unit test example using CQL3 script
package org.cassandraunit.test.cql;
import com.datastax.driver.core.ResultSet;
import org.cassandraunit.CassandraCQLUnit;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.Rule;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class CQLScriptLoadTest {
@Rule
public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(
new ClassPathCQLDataSet("simple.cql","keyspaceNameToCreate"));
@Test
public void should_have_started_and_execute_cql_script() throws Exception {
ResultSet result = cassandraCQLUnit.session.execute("select * from mytable WHERE id='myKey01'");
assertThat(result.iterator().next().getString("value"), is("myValue01"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment