Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1975: add example for Cassandra module #2210

Merged
merged 1 commit into from Mar 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/modules/databases/cassandra.md
@@ -1,5 +1,38 @@
# Cassandra Module

## Usage example

This example connects to the Cassandra Cluster, creates a keyspaces and asserts that is has been created.

```java tab="JUnit 4 example"
public class SomeTest {

@Rule
public CassandraContainer cassandra = new CassandraContainer();


@Test
public void test(){
Cluster cluster = cassandra.getCluster();

try(Session session = cluster.connect()) {

session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH replication = \n" +
"{'class':'SimpleStrategy','replication_factor':'1'};");

List<KeyspaceMetadata> keyspaces = session.getCluster().getMetadata().getKeyspaces();
List<KeyspaceMetadata> filteredKeyspaces = keyspaces
.stream()
.filter(km -> km.getName().equals("test"))
.collect(Collectors.toList());

assertEquals(1, filteredKeyspaces.size());
}
}

}
```

## Adding this module to your project dependencies

Add the following dependency to your `pom.xml`/`build.gradle` file:
Expand Down