-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathCQLScriptLoadWithNativeApproachTest.java
More file actions
35 lines (28 loc) · 1.21 KB
/
Copy pathCQLScriptLoadWithNativeApproachTest.java
File metadata and controls
35 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.cassandraunit.test.cql;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.Row;
import org.cassandraunit.CQLDataLoader;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* No rule, no base class: start the server and load the dataset by hand.
* {@code startEmbeddedCassandra()} is idempotent, so every test class in a fork can call it.
*/
public class CQLScriptLoadWithNativeApproachTest {
private CqlSession session;
@Before
public void setUp() throws Exception {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
session = EmbeddedCassandraServerHelper.getSession();
new CQLDataLoader(session).load(new ClassPathCQLDataSet("simple.cql", "keyspaceNameToCreate"));
}
@Test
public void should_have_started_and_execute_cql_script() {
Row row = session.execute("select value from mytable where id = 'myKey01'").one();
assertThat(row).isNotNull();
assertThat(row.getString("value")).isEqualTo("myValue01");
}
}