@@ -22,30 +22,25 @@ import example.springdata.cassandra.util.CassandraKeyspace;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test showing the basic usage of Auditing through {@link AuditedPersonRepository}.
|
* Integration test showing the basic usage of Auditing through {@link AuditedPersonRepository}.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = BasicConfiguration.class)
|
@SpringBootTest(classes = BasicConfiguration.class)
|
||||||
public class AuditedPersonRepositoryTests {
|
@CassandraKeyspace
|
||||||
|
class AuditedPersonRepositoryTests {
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired AuditedPersonRepository repository;
|
@Autowired AuditedPersonRepository repository;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
repository.deleteAll();
|
repository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +48,7 @@ public class AuditedPersonRepositoryTests {
|
|||||||
* Saving an object using the Cassandra Repository will create a persistent representation of the object in Cassandra.
|
* Saving an object using the Cassandra Repository will create a persistent representation of the object in Cassandra.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void insertShouldSetCreatedDate() {
|
void insertShouldSetCreatedDate() {
|
||||||
|
|
||||||
AuditedPerson person = new AuditedPerson();
|
AuditedPerson person = new AuditedPerson();
|
||||||
person.setId(42L);
|
person.setId(42L);
|
||||||
@@ -73,7 +68,7 @@ public class AuditedPersonRepositoryTests {
|
|||||||
* Modifying an existing object will update the last modified fields.
|
* Modifying an existing object will update the last modified fields.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void updateShouldSetLastModifiedDate() {
|
void updateShouldSetLastModifiedDate() {
|
||||||
|
|
||||||
AuditedPerson person = new AuditedPerson();
|
AuditedPerson person = new AuditedPerson();
|
||||||
person.setId(42L);
|
person.setId(42L);
|
||||||
|
|||||||
@@ -16,20 +16,17 @@
|
|||||||
package example.springdata.cassandra.basic;
|
package example.springdata.cassandra.basic;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assume.*;
|
import static org.assertj.core.api.Assumptions.*;
|
||||||
|
|
||||||
import example.springdata.cassandra.util.CassandraKeyspace;
|
import example.springdata.cassandra.util.CassandraKeyspace;
|
||||||
import example.springdata.cassandra.util.CassandraVersion;
|
import example.springdata.cassandra.util.CassandraVersion;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.util.Version;
|
import org.springframework.data.util.Version;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.CqlSession;
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
|
|
||||||
@@ -41,20 +38,18 @@ import com.datastax.oss.driver.api.core.CqlSession;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = BasicConfiguration.class)
|
@SpringBootTest(classes = BasicConfiguration.class)
|
||||||
public class BasicUserRepositoryTests {
|
@CassandraKeyspace
|
||||||
|
class BasicUserRepositoryTests {
|
||||||
|
|
||||||
public final static Version CASSANDRA_3_4 = Version.parse("3.4");
|
private final static Version CASSANDRA_3_4 = Version.parse("3.4");
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired BasicUserRepository repository;
|
@Autowired BasicUserRepository repository;
|
||||||
@Autowired CqlSession session;
|
@Autowired CqlSession session;
|
||||||
User user;
|
private User user;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
|
|
||||||
user = new User();
|
user = new User();
|
||||||
user.setId(42L);
|
user.setId(42L);
|
||||||
@@ -67,7 +62,7 @@ public class BasicUserRepositoryTests {
|
|||||||
* Saving an object using the Cassandra Repository will create a persistent representation of the object in Cassandra.
|
* Saving an object using the Cassandra Repository will create a persistent representation of the object in Cassandra.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findSavedUserById() {
|
void findSavedUserById() {
|
||||||
|
|
||||||
user = repository.save(user);
|
user = repository.save(user);
|
||||||
|
|
||||||
@@ -78,7 +73,7 @@ public class BasicUserRepositoryTests {
|
|||||||
* Cassandra can be queries by using query methods annotated with {@link @Query}.
|
* Cassandra can be queries by using query methods annotated with {@link @Query}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findByAnnotatedQueryMethod() {
|
void findByAnnotatedQueryMethod() {
|
||||||
|
|
||||||
repository.save(user);
|
repository.save(user);
|
||||||
|
|
||||||
@@ -92,7 +87,7 @@ public class BasicUserRepositoryTests {
|
|||||||
* key requires a secondary index.
|
* key requires a secondary index.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findByDerivedQueryMethod() throws InterruptedException {
|
void findByDerivedQueryMethod() throws InterruptedException {
|
||||||
|
|
||||||
session.execute("CREATE INDEX IF NOT EXISTS user_username ON users (uname);");
|
session.execute("CREATE INDEX IF NOT EXISTS user_username ON users (uname);");
|
||||||
/*
|
/*
|
||||||
@@ -110,9 +105,9 @@ public class BasicUserRepositoryTests {
|
|||||||
* Spring Data Cassandra supports {@code LIKE} and {@code CONTAINS} query keywords to for SASI indexes.
|
* Spring Data Cassandra supports {@code LIKE} and {@code CONTAINS} query keywords to for SASI indexes.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findByDerivedQueryMethodWithSASI() throws InterruptedException {
|
void findByDerivedQueryMethodWithSASI() throws InterruptedException {
|
||||||
|
|
||||||
assumeTrue(CassandraVersion.getReleaseVersion(session).isGreaterThanOrEqualTo(CASSANDRA_3_4));
|
assumeThat(CassandraVersion.getReleaseVersion(session).isGreaterThanOrEqualTo(CASSANDRA_3_4)).isTrue();
|
||||||
|
|
||||||
session.execute("CREATE CUSTOM INDEX ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
|
session.execute("CREATE CUSTOM INDEX ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -24,17 +24,14 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.cassandra.core.AsyncCassandraTemplate;
|
import org.springframework.data.cassandra.core.AsyncCassandraTemplate;
|
||||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.util.concurrent.ListenableFuture;
|
import org.springframework.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.CqlSession;
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
@@ -47,16 +44,15 @@ import com.datastax.oss.driver.api.querybuilder.insert.Insert;
|
|||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = BasicConfiguration.class)
|
@SpringBootTest(classes = BasicConfiguration.class)
|
||||||
|
@CassandraKeyspace
|
||||||
public class CassandraOperationsIntegrationTests {
|
public class CassandraOperationsIntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired CqlSession session;
|
@Autowired CqlSession session;
|
||||||
@Autowired CassandraOperations template;
|
@Autowired CassandraOperations template;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
template.getCqlOperations().execute("TRUNCATE users");
|
template.getCqlOperations().execute("TRUNCATE users");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ package example.springdata.cassandra.convert;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.cql.Row;
|
|
||||||
import com.datastax.oss.driver.api.core.data.TupleValue;
|
|
||||||
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
|
|
||||||
import example.springdata.cassandra.util.CassandraKeyspace;
|
import example.springdata.cassandra.util.CassandraKeyspace;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -27,29 +24,29 @@ import java.util.Currency;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
import com.datastax.oss.driver.api.core.cql.Row;
|
||||||
|
import com.datastax.oss.driver.api.core.data.TupleValue;
|
||||||
|
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest(classes = ConverterConfiguration.class)
|
@SpringBootTest(classes = ConverterConfiguration.class)
|
||||||
public class ConversionIntegrationTests {
|
class ConversionIntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired CassandraOperations operations;
|
@Autowired CassandraOperations operations;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
operations.truncate(Addressbook.class);
|
operations.truncate(Addressbook.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +55,7 @@ public class ConversionIntegrationTests {
|
|||||||
* custom {@link example.springdata.cassandra.convert.ConverterConfiguration.PersonWriteConverter}.
|
* custom {@link example.springdata.cassandra.convert.ConverterConfiguration.PersonWriteConverter}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldCreateAddressbook() {
|
void shouldCreateAddressbook() {
|
||||||
|
|
||||||
Addressbook addressbook = new Addressbook();
|
Addressbook addressbook = new Addressbook();
|
||||||
addressbook.setId("private");
|
addressbook.setId("private");
|
||||||
@@ -82,7 +79,7 @@ public class ConversionIntegrationTests {
|
|||||||
* custom {@link example.springdata.cassandra.convert.ConverterConfiguration.PersonReadConverter}.
|
* custom {@link example.springdata.cassandra.convert.ConverterConfiguration.PersonReadConverter}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldReadAddressbook() {
|
void shouldReadAddressbook() {
|
||||||
|
|
||||||
Addressbook addressbook = new Addressbook();
|
Addressbook addressbook = new Addressbook();
|
||||||
addressbook.setId("private");
|
addressbook.setId("private");
|
||||||
@@ -104,7 +101,7 @@ public class ConversionIntegrationTests {
|
|||||||
* {@link example.springdata.cassandra.convert.ConverterConfiguration.CustomAddressbookReadConverter}.
|
* {@link example.springdata.cassandra.convert.ConverterConfiguration.CustomAddressbookReadConverter}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldReadCustomAddressbook() {
|
void shouldReadCustomAddressbook() {
|
||||||
|
|
||||||
Addressbook addressbook = new Addressbook();
|
Addressbook addressbook = new Addressbook();
|
||||||
addressbook.setId("private");
|
addressbook.setId("private");
|
||||||
@@ -124,7 +121,7 @@ public class ConversionIntegrationTests {
|
|||||||
* Creates and stores a new {@link Addressbook} inside of Cassandra writing map and tuple columns.
|
* Creates and stores a new {@link Addressbook} inside of Cassandra writing map and tuple columns.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldWriteConvertedMapsAndTuples() {
|
void shouldWriteConvertedMapsAndTuples() {
|
||||||
|
|
||||||
Addressbook addressbook = new Addressbook();
|
Addressbook addressbook = new Addressbook();
|
||||||
addressbook.setId("private");
|
addressbook.setId("private");
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ import example.springdata.cassandra.util.CassandraKeyspace;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||||
import org.springframework.data.cassandra.core.query.Query;
|
import org.springframework.data.cassandra.core.query.Query;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test showing differences between fetching results as {@link List} and {@link Stream streaming} results using
|
* Test showing differences between fetching results as {@link List} and {@link Stream streaming} results using
|
||||||
@@ -35,12 +33,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = BasicConfiguration.class)
|
@SpringBootTest(classes = BasicConfiguration.class)
|
||||||
|
@CassandraKeyspace
|
||||||
public class LifecycleEventsTests {
|
public class LifecycleEventsTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired CassandraOperations operations;
|
@Autowired CassandraOperations operations;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -17,12 +17,8 @@ package example.springdata.cassandra.optimisticlocking;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
import example.springdata.cassandra.util.CassandraKeyspace;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
@@ -31,23 +27,19 @@ import org.springframework.data.cassandra.core.CassandraOperations;
|
|||||||
import org.springframework.data.cassandra.core.EntityWriteResult;
|
import org.springframework.data.cassandra.core.EntityWriteResult;
|
||||||
import org.springframework.data.cassandra.core.UpdateOptions;
|
import org.springframework.data.cassandra.core.UpdateOptions;
|
||||||
import org.springframework.data.cassandra.core.query.Criteria;
|
import org.springframework.data.cassandra.core.query.Criteria;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test showing the basic usage of Optimistic Locking through {@link OptimisticPersonRepository}.
|
* Integration test showing the basic usage of Optimistic Locking through {@link OptimisticPersonRepository}.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = BasicConfiguration.class)
|
@SpringBootTest(classes = BasicConfiguration.class)
|
||||||
public class OptimisticPersonRepositoryTests {
|
public class OptimisticPersonRepositoryTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired OptimisticPersonRepository repository;
|
@Autowired OptimisticPersonRepository repository;
|
||||||
@Autowired CassandraOperations operations;
|
@Autowired CassandraOperations operations;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
repository.deleteAll();
|
repository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,32 +21,28 @@ import example.springdata.cassandra.util.CassandraKeyspace;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.projection.TargetAware;
|
import org.springframework.data.projection.TargetAware;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link CustomerRepository} to show projection capabilities.
|
* Integration tests for {@link CustomerRepository} to show projection capabilities.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringBootTest(classes = ProjectionConfiguration.class)
|
@SpringBootTest(classes = ProjectionConfiguration.class)
|
||||||
public class CustomerRepositoryIntegrationTest {
|
@CassandraKeyspace
|
||||||
|
class CustomerRepositoryIntegrationTest {
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired CustomerRepository customers;
|
@Autowired CustomerRepository customers;
|
||||||
|
|
||||||
Customer dave, carter;
|
private Customer dave, carter;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
|
|
||||||
customers.deleteAll();
|
customers.deleteAll();
|
||||||
|
|
||||||
@@ -55,7 +51,7 @@ public class CustomerRepositoryIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void projectsEntityIntoInterface() {
|
void projectsEntityIntoInterface() {
|
||||||
|
|
||||||
Collection<CustomerProjection> result = customers.findAllProjectedBy();
|
Collection<CustomerProjection> result = customers.findAllProjectedBy();
|
||||||
|
|
||||||
@@ -64,7 +60,7 @@ public class CustomerRepositoryIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void projectsDynamically() {
|
void projectsDynamically() {
|
||||||
|
|
||||||
Collection<CustomerProjection> result = customers.findById("d", CustomerProjection.class);
|
Collection<CustomerProjection> result = customers.findById("d", CustomerProjection.class);
|
||||||
|
|
||||||
@@ -73,7 +69,7 @@ public class CustomerRepositoryIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void projectsIndividualDynamically() {
|
void projectsIndividualDynamically() {
|
||||||
|
|
||||||
CustomerSummary result = customers.findProjectedById(dave.getId(), CustomerSummary.class);
|
CustomerSummary result = customers.findProjectedById(dave.getId(), CustomerSummary.class);
|
||||||
|
|
||||||
@@ -85,7 +81,7 @@ public class CustomerRepositoryIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void projectIndividualInstance() {
|
void projectIndividualInstance() {
|
||||||
|
|
||||||
CustomerProjection result = customers.findProjectedById(dave.getId());
|
CustomerProjection result = customers.findProjectedById(dave.getId());
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ import example.springdata.cassandra.util.CassandraKeyspace;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
@@ -33,7 +31,6 @@ import org.springframework.data.cassandra.config.AbstractCassandraConfiguration;
|
|||||||
import org.springframework.data.cassandra.config.SchemaAction;
|
import org.springframework.data.cassandra.config.SchemaAction;
|
||||||
import org.springframework.data.cassandra.core.CassandraAdminOperations;
|
import org.springframework.data.cassandra.core.CassandraAdminOperations;
|
||||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.data.UdtValue;
|
import com.datastax.oss.driver.api.core.data.UdtValue;
|
||||||
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
|
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
|
||||||
@@ -45,11 +42,9 @@ import com.datastax.oss.driver.api.core.type.UserDefinedType;
|
|||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class UserDefinedTypeIntegrationTest {
|
@CassandraKeyspace
|
||||||
|
class UserDefinedTypeIntegrationTest {
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends AbstractCassandraConfiguration {
|
static class Config extends AbstractCassandraConfiguration {
|
||||||
@@ -78,8 +73,8 @@ public class UserDefinedTypeIntegrationTest {
|
|||||||
@Autowired CassandraOperations operations;
|
@Autowired CassandraOperations operations;
|
||||||
@Autowired CassandraAdminOperations adminOperations;
|
@Autowired CassandraAdminOperations adminOperations;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() throws Exception {
|
void before() throws Exception {
|
||||||
operations.getCqlOperations().execute("TRUNCATE person");
|
operations.getCqlOperations().execute("TRUNCATE person");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +82,7 @@ public class UserDefinedTypeIntegrationTest {
|
|||||||
* Insert a row with a mapped User-defined type.
|
* Insert a row with a mapped User-defined type.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void insertMappedUdt() {
|
void insertMappedUdt() {
|
||||||
|
|
||||||
Person person = new Person();
|
Person person = new Person();
|
||||||
person.setId(42);
|
person.setId(42);
|
||||||
@@ -109,7 +104,7 @@ public class UserDefinedTypeIntegrationTest {
|
|||||||
* Insert a row with a raw User-defined type.
|
* Insert a row with a raw User-defined type.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void insertRawUdt() {
|
void insertRawUdt() {
|
||||||
|
|
||||||
KeyspaceMetadata keyspaceMetadata = adminOperations.getKeyspaceMetadata();
|
KeyspaceMetadata keyspaceMetadata = adminOperations.getKeyspaceMetadata();
|
||||||
UserDefinedType address = keyspaceMetadata.getUserDefinedType("address").get();
|
UserDefinedType address = keyspaceMetadata.getUserDefinedType("address").get();
|
||||||
|
|||||||
@@ -23,36 +23,30 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.util.Version;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test to show the usage of Java 8 features with Spring Data Cassandra.
|
* Integration test to show the usage of Java 8 features with Spring Data Cassandra.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest(classes = CassandraConfiguration.class)
|
@SpringBootTest(classes = CassandraConfiguration.class)
|
||||||
public class Java8IntegrationTests {
|
class Java8IntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost()
|
|
||||||
.atLeast(Version.parse("3.0"));
|
|
||||||
|
|
||||||
@Autowired PersonRepository repository;
|
@Autowired PersonRepository repository;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void setUp() throws Exception {
|
||||||
repository.deleteAll();
|
repository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void providesFindOneWithOptional() {
|
void providesFindOneWithOptional() {
|
||||||
|
|
||||||
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
||||||
|
|
||||||
@@ -61,7 +55,7 @@ public class Java8IntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokesDefaultMethod() {
|
void invokesDefaultMethod() {
|
||||||
|
|
||||||
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
||||||
Optional<Person> result = repository.findByPerson(homer);
|
Optional<Person> result = repository.findByPerson(homer);
|
||||||
@@ -75,7 +69,7 @@ public class Java8IntegrationTests {
|
|||||||
* resulting {@link Stream} contains state it needs to be closed explicitly after use!
|
* resulting {@link Stream} contains state it needs to be closed explicitly after use!
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void useJava8StreamsWithCustomQuery() {
|
void useJava8StreamsWithCustomQuery() {
|
||||||
|
|
||||||
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
Person homer = repository.save(new Person("1", "Homer", "Simpson"));
|
||||||
Person bart = repository.save(new Person("2", "Bart", "Simpson"));
|
Person bart = repository.save(new Person("2", "Bart", "Simpson"));
|
||||||
|
|||||||
@@ -22,36 +22,30 @@ import example.springdata.cassandra.util.CassandraKeyspace;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.util.Version;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test to show the usage of JSR-310 date/time types with Spring Data Cassandra.
|
* Integration test to show the usage of JSR-310 date/time types with Spring Data Cassandra.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest(classes = CassandraConfiguration.class)
|
@SpringBootTest(classes = CassandraConfiguration.class)
|
||||||
public class Jsr310IntegrationTests {
|
class Jsr310IntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost()
|
|
||||||
.atLeast(Version.parse("3.0"));
|
|
||||||
|
|
||||||
@Autowired OrderRepository repository;
|
@Autowired OrderRepository repository;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void setUp() throws Exception {
|
||||||
repository.deleteAll();
|
repository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findOneByJsr310Types() {
|
void findOneByJsr310Types() {
|
||||||
|
|
||||||
Order order = new Order("42", LocalDate.now(), ZoneId.systemDefault());
|
Order order = new Order("42", LocalDate.now(), ZoneId.systemDefault());
|
||||||
|
|
||||||
|
|||||||
@@ -18,37 +18,25 @@ package example.springdata.cassandra.kotlin
|
|||||||
import example.springdata.cassandra.util.CassandraKeyspace
|
import example.springdata.cassandra.util.CassandraKeyspace
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.junit.Before
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.ClassRule
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.boot.test.context.SpringBootTest
|
import org.springframework.boot.test.context.SpringBootTest
|
||||||
import org.springframework.dao.EmptyResultDataAccessException
|
import org.springframework.dao.EmptyResultDataAccessException
|
||||||
import org.springframework.data.util.Version
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests showing Kotlin usage of Spring Data Repositories.
|
* Tests showing Kotlin usage of Spring Data Repositories.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner::class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class RepositoryTests {
|
class RepositoryTests {
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@ClassRule
|
|
||||||
val CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost()
|
|
||||||
.atLeast(Version.parse("3.0"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
lateinit var repository: PersonRepository
|
lateinit var repository: PersonRepository
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
fun before() {
|
fun before() {
|
||||||
repository.deleteAll()
|
repository.deleteAll()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,40 +19,28 @@ import com.datastax.oss.driver.api.core.CqlIdentifier
|
|||||||
import com.datastax.oss.driver.api.querybuilder.QueryBuilder
|
import com.datastax.oss.driver.api.querybuilder.QueryBuilder
|
||||||
import example.springdata.cassandra.util.CassandraKeyspace
|
import example.springdata.cassandra.util.CassandraKeyspace
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Before
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.ClassRule
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.boot.test.context.SpringBootTest
|
import org.springframework.boot.test.context.SpringBootTest
|
||||||
import org.springframework.data.cassandra.core.*
|
import org.springframework.data.cassandra.core.*
|
||||||
import org.springframework.data.cassandra.core.query.Query.query
|
import org.springframework.data.cassandra.core.query.Query.query
|
||||||
import org.springframework.data.cassandra.core.query.isEqualTo
|
import org.springframework.data.cassandra.core.query.isEqualTo
|
||||||
import org.springframework.data.cassandra.core.query.where
|
import org.springframework.data.cassandra.core.query.where
|
||||||
import org.springframework.data.util.Version
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests showing Kotlin usage of [MongoTemplate] and its Kotlin extensions.
|
* Tests showing Kotlin usage of [MongoTemplate] and its Kotlin extensions.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner::class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class TemplateTests {
|
class TemplateTests {
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@ClassRule
|
|
||||||
val CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost()
|
|
||||||
.atLeast(Version.parse("3.0"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
lateinit var operations: CassandraOperations
|
lateinit var operations: CassandraOperations
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
fun before() {
|
fun before() {
|
||||||
operations.truncate<Person>()
|
operations.truncate<Person>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,25 +22,20 @@ import reactor.test.StepVerifier;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests showing Reactive Auditing with Cassandra in action.
|
* Integration tests showing Reactive Auditing with Cassandra in action.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@DataCassandraTest
|
@DataCassandraTest
|
||||||
public class AuditingIntegrationTests {
|
public class AuditingIntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired OrderRepository orderRepository;
|
@Autowired OrderRepository orderRepository;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -23,33 +23,29 @@ import reactor.core.publisher.Mono;
|
|||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
import rx.RxReactiveStreams;
|
import rx.RxReactiveStreams;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
|
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for {@link ReactiveCassandraTemplate}.
|
* Integration test for {@link ReactiveCassandraTemplate}.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class ReactiveCassandraTemplateIntegrationTest {
|
class ReactiveCassandraTemplateIntegrationTest {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired ReactiveCassandraTemplate template;
|
@Autowired ReactiveCassandraTemplate template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate table and insert some rows.
|
* Truncate table and insert some rows.
|
||||||
*/
|
*/
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
|
|
||||||
Flux<Person> truncateAndInsert = template.truncate(Person.class) //
|
Flux<Person> truncateAndInsert = template.truncate(Person.class) //
|
||||||
.thenMany(Flux.just(new Person("Walter", "White", 50), //
|
.thenMany(Flux.just(new Person("Walter", "White", 50), //
|
||||||
@@ -66,7 +62,7 @@ public class ReactiveCassandraTemplateIntegrationTest {
|
|||||||
* the two counts ({@code 4} and {@code 6}) to the console.
|
* the two counts ({@code 4} and {@code 6}) to the console.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldInsertAndCountData() {
|
void shouldInsertAndCountData() {
|
||||||
|
|
||||||
Mono<Long> saveAndCount = template.count(Person.class) //
|
Mono<Long> saveAndCount = template.count(Person.class) //
|
||||||
.doOnNext(System.out::println) //
|
.doOnNext(System.out::println) //
|
||||||
@@ -84,7 +80,7 @@ public class ReactiveCassandraTemplateIntegrationTest {
|
|||||||
* Note that the all object conversions are performed before the results are printed to the console.
|
* Note that the all object conversions are performed before the results are printed to the console.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void convertReactorTypesToRxJava1() throws Exception {
|
void convertReactorTypesToRxJava1() throws Exception {
|
||||||
|
|
||||||
Flux<Person> flux = template.select("SELECT * FROM person WHERE lastname = 'White'", Person.class);
|
Flux<Person> flux = template.select("SELECT * FROM person WHERE lastname = 'White'", Person.class);
|
||||||
|
|
||||||
|
|||||||
@@ -20,32 +20,28 @@ import reactor.core.publisher.Flux;
|
|||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for {@link ReactivePersonRepository} using Project Reactor types and operators.
|
* Integration test for {@link ReactivePersonRepository} using Project Reactor types and operators.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class ReactivePersonRepositoryIntegrationTest {
|
@CassandraKeyspace
|
||||||
|
class ReactivePersonRepositoryIntegrationTest {
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired ReactivePersonRepository repository;
|
@Autowired ReactivePersonRepository repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear table and insert some rows.
|
* Clear table and insert some rows.
|
||||||
*/
|
*/
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void setUp() {
|
||||||
|
|
||||||
Flux<Person> deleteAndInsert = repository.deleteAll() //
|
Flux<Person> deleteAndInsert = repository.deleteAll() //
|
||||||
.thenMany(repository.saveAll(Flux.just(new Person("Walter", "White", 50), //
|
.thenMany(repository.saveAll(Flux.just(new Person("Walter", "White", 50), //
|
||||||
@@ -60,7 +56,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* This sample performs a count, inserts data and performs a count again using reactive operator chaining.
|
* This sample performs a count, inserts data and performs a count again using reactive operator chaining.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldInsertAndCountData() {
|
void shouldInsertAndCountData() {
|
||||||
|
|
||||||
Mono<Long> saveAndCount = repository.count() //
|
Mono<Long> saveAndCount = repository.count() //
|
||||||
.doOnNext(System.out::println) //
|
.doOnNext(System.out::println) //
|
||||||
@@ -78,7 +74,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* prefetch define the amount of fetched records.
|
* prefetch define the amount of fetched records.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldPerformConversionBeforeResultProcessing() {
|
void shouldPerformConversionBeforeResultProcessing() {
|
||||||
|
|
||||||
StepVerifier.create(repository.findAll().doOnNext(System.out::println)) //
|
StepVerifier.create(repository.findAll().doOnNext(System.out::println)) //
|
||||||
.expectNextCount(4) //
|
.expectNextCount(4) //
|
||||||
@@ -89,7 +85,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* Fetch data using query derivation.
|
* Fetch data using query derivation.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldQueryDataWithQueryDerivation() {
|
void shouldQueryDataWithQueryDerivation() {
|
||||||
StepVerifier.create(repository.findByLastname("White")).expectNextCount(2).verifyComplete();
|
StepVerifier.create(repository.findByLastname("White")).expectNextCount(2).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +93,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* Fetch data using a string query.
|
* Fetch data using a string query.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldQueryDataWithStringQuery() {
|
void shouldQueryDataWithStringQuery() {
|
||||||
StepVerifier.create(repository.findByFirstnameInAndLastname("Walter", "White")).expectNextCount(1).verifyComplete();
|
StepVerifier.create(repository.findByFirstnameInAndLastname("Walter", "White")).expectNextCount(1).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +101,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* Fetch data using query derivation.
|
* Fetch data using query derivation.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldQueryDataWithDeferredQueryDerivation() {
|
void shouldQueryDataWithDeferredQueryDerivation() {
|
||||||
StepVerifier.create(repository.findByLastname(Mono.just("White"))).expectNextCount(2).verifyComplete();
|
StepVerifier.create(repository.findByLastname(Mono.just("White"))).expectNextCount(2).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +109,7 @@ public class ReactivePersonRepositoryIntegrationTest {
|
|||||||
* Fetch data using query derivation and deferred parameter resolution.
|
* Fetch data using query derivation and deferred parameter resolution.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void shouldQueryDataWithMixedDeferredQueryDerivation() {
|
void shouldQueryDataWithMixedDeferredQueryDerivation() {
|
||||||
|
|
||||||
StepVerifier.create(repository.findByFirstnameAndLastname(Mono.just("Walter"), "White")) //
|
StepVerifier.create(repository.findByFirstnameAndLastname(Mono.just("Walter"), "White")) //
|
||||||
.expectNextCount(1) //
|
.expectNextCount(1) //
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ import io.reactivex.Completable;
|
|||||||
import io.reactivex.Flowable;
|
import io.reactivex.Flowable;
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for {@link RxJava2PersonRepository} using RxJava1 types. Note that
|
* Integration test for {@link RxJava2PersonRepository} using RxJava1 types. Note that
|
||||||
@@ -36,16 +34,15 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class RxJava2PersonRepositoryIntegrationTest {
|
public class RxJava2PersonRepositoryIntegrationTest {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired RxJava2PersonRepository repository;
|
@Autowired RxJava2PersonRepository repository;
|
||||||
@Autowired ReactiveCassandraOperations operations;
|
@Autowired ReactiveCassandraOperations operations;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
||||||
Completable deleteAll = repository.deleteAll();
|
Completable deleteAll = repository.deleteAll();
|
||||||
|
|||||||
@@ -24,30 +24,25 @@ import reactor.util.context.Context;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests showing the SpEL context extension in action.
|
* Integration tests showing the SpEL context extension in action.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@CassandraKeyspace
|
||||||
@DataCassandraTest
|
@DataCassandraTest
|
||||||
public class ExpressionIntegrationTests {
|
class ExpressionIntegrationTests {
|
||||||
|
|
||||||
@ClassRule public final static CassandraKeyspace CASSANDRA_KEYSPACE = CassandraKeyspace.onLocalhost();
|
|
||||||
|
|
||||||
@Autowired EmployeeRepository employeeRepository;
|
@Autowired EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void before() {
|
||||||
|
|
||||||
employeeRepository.deleteAll().as(StepVerifier::create).verifyComplete();
|
employeeRepository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||||
|
|
||||||
@@ -60,7 +55,7 @@ public class ExpressionIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldFindByTenantIdAndName() {
|
void shouldFindByTenantIdAndName() {
|
||||||
|
|
||||||
employeeRepository.findAllByName("Walter") //
|
employeeRepository.findAllByName("Walter") //
|
||||||
.contextWrite(Context.of(Tenant.class, new Tenant("breaking-bad"))).as(StepVerifier::create) //
|
.contextWrite(Context.of(Tenant.class, new Tenant("breaking-bad"))).as(StepVerifier::create) //
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017-2018 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package example.springdata.cassandra.util;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
|
|
||||||
import org.junit.AssumptionViolatedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link org.junit.rules.TestRule} for Cassandra server use. This rule can start a Cassandra instance, reuse a running
|
|
||||||
* instance or simply require a running Cassandra server (will skip the test if Cassandra is not running).
|
|
||||||
*
|
|
||||||
* @author Mark Paluch
|
|
||||||
*/
|
|
||||||
public class Cassandra extends CassandraResource {
|
|
||||||
|
|
||||||
private final RuntimeMode runtimeMode;
|
|
||||||
|
|
||||||
private Cassandra(String host, int port, RuntimeMode runtimeMode) {
|
|
||||||
|
|
||||||
super(host, port);
|
|
||||||
this.runtimeMode = runtimeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Require a running instance on {@code host:port}. Fails with {@link AssumptionViolatedException} if Cassandra is not
|
|
||||||
* running.
|
|
||||||
*
|
|
||||||
* @param host must not be {@literal null} or empty.
|
|
||||||
* @param port must be between 0 and 65535.
|
|
||||||
* @return the {@link Cassandra} rule
|
|
||||||
*/
|
|
||||||
public static Cassandra requireRunningInstance(String host, int port) {
|
|
||||||
return new Cassandra(host, port, RuntimeMode.REQUIRE_RUNNING_INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start an embedded Cassandra instance on {@code host:port} if Cassandra is not running already.
|
|
||||||
*
|
|
||||||
* @param host must not be {@literal null} or empty.
|
|
||||||
* @param port must be between 0 and 65535.
|
|
||||||
* @return the {@link Cassandra} rule
|
|
||||||
*/
|
|
||||||
public static Cassandra embeddedIfNotRunning(String host, int port) {
|
|
||||||
return new Cassandra(host, port, RuntimeMode.EMBEDDED_IF_NOT_RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void before() throws Throwable {
|
|
||||||
|
|
||||||
if (runtimeMode == RuntimeMode.REQUIRE_RUNNING_INSTANCE) {
|
|
||||||
if (!CassandraSocket.isConnectable(getHost(), getPort())) {
|
|
||||||
throw new AssumptionViolatedException(
|
|
||||||
String.format("Cassandra is not reachable at %s:%s.", getHost(), getPort()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (runtimeMode == RuntimeMode.EMBEDDED_IF_NOT_RUNNING) {
|
|
||||||
if (CassandraSocket.isConnectable(getHost(), getPort())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("embedded-cassandra.yaml", "target/embeddedCassandra",
|
|
||||||
TimeUnit.SECONDS.toMillis(60));
|
|
||||||
super.before();
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum RuntimeMode {
|
|
||||||
REQUIRE_RUNNING_INSTANCE, EMBEDDED_IF_NOT_RUNNING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package example.springdata.cassandra.util;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
import org.junit.platform.commons.util.AnnotationUtils;
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit 5 {@link BeforeAllCallback} extension to ensure a running Cassandra server.
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @see CassandraKeyspace
|
||||||
|
*/
|
||||||
|
class CassandraExtension implements BeforeAllCallback {
|
||||||
|
|
||||||
|
private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace
|
||||||
|
.create(CassandraExtension.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeAll(ExtensionContext context) throws Exception {
|
||||||
|
|
||||||
|
ExtensionContext.Store store = context.getStore(NAMESPACE);
|
||||||
|
CassandraKeyspace cassandra = findAnnotation(context);
|
||||||
|
|
||||||
|
CassandraServer keyspace = store.getOrComputeIfAbsent(CassandraServer.class, it -> {
|
||||||
|
return CassandraServer.embeddedIfNotRunning("localhost", 9042);
|
||||||
|
}, CassandraServer.class);
|
||||||
|
|
||||||
|
keyspace.before();
|
||||||
|
|
||||||
|
CqlSession session = store.getOrComputeIfAbsent(CqlSession.class, it -> {
|
||||||
|
|
||||||
|
return CqlSession.builder().addContactPoint(new InetSocketAddress("localhost", 9042))
|
||||||
|
.withLocalDatacenter("datacenter1").build();
|
||||||
|
}, CqlSession.class);
|
||||||
|
|
||||||
|
session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s \n"
|
||||||
|
+ "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", cassandra.keyspace()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CassandraKeyspace findAnnotation(ExtensionContext context) {
|
||||||
|
|
||||||
|
Class<?> testClass = context.getRequiredTestClass();
|
||||||
|
|
||||||
|
Optional<CassandraKeyspace> annotation = AnnotationUtils.findAnnotation(testClass, CassandraKeyspace.class);
|
||||||
|
|
||||||
|
return annotation.orElseThrow(() -> new IllegalStateException("Test class not annotated with @Cassandra"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2018 the original author or authors.
|
* Copyright 2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -15,111 +15,29 @@
|
|||||||
*/
|
*/
|
||||||
package example.springdata.cassandra.util;
|
package example.springdata.cassandra.util;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import org.junit.AssumptionViolatedException;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import org.springframework.data.util.Version;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.CqlSession;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CassandraResource} to require (create or reuse) an Apache Cassandra keyspace and optionally require a specific
|
* Annotation that can activates embedded Cassandra providing a keyspace at {@link #keyspace()}
|
||||||
* Apache Cassandra version. This {@link org.junit.rules.TestRule} can be chained to depend on another
|
|
||||||
* {@link CassandraResource} rule to require a running instance/start an embedded Apache Cassandra instance.
|
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
public class CassandraKeyspace extends CassandraResource {
|
@Inherited
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
private final String keyspaceName;
|
@Target(ElementType.TYPE)
|
||||||
private final Version requiredVersion;
|
@ExtendWith(CassandraExtension.class)
|
||||||
private final CassandraResource dependency;
|
public @interface CassandraKeyspace {
|
||||||
|
|
||||||
private CassandraKeyspace(String host, int port, String keyspaceName, CassandraResource dependency,
|
|
||||||
Version requiredVersion) {
|
|
||||||
|
|
||||||
super(host, port);
|
|
||||||
|
|
||||||
this.keyspaceName = keyspaceName;
|
|
||||||
this.dependency = dependency;
|
|
||||||
this.requiredVersion = requiredVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link CassandraKeyspace} test rule to provide a running Cassandra instance on {@code localhost:9042} with
|
* Name of the desired keyspace to be provided.
|
||||||
* a keyspace {@code example}. Reuses a running Cassandra instance if available or starts an embedded instance.
|
|
||||||
*
|
*
|
||||||
* @return the {@link CassandraKeyspace} rule.
|
* @return
|
||||||
*/
|
*/
|
||||||
public static CassandraKeyspace onLocalhost() {
|
String keyspace() default "example";
|
||||||
return new CassandraKeyspace("localhost", 9042, "example", Cassandra.embeddedIfNotRunning("localhost", 9042),
|
|
||||||
new Version(0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup a dependency to an upstream {@link CassandraResource}. The dependency is activated by {@code this} test rule.
|
|
||||||
*
|
|
||||||
* @param cassandraResource must not be {@literal null}.
|
|
||||||
* @return the {@link CassandraKeyspace} rule.
|
|
||||||
*/
|
|
||||||
public CassandraKeyspace dependsOn(CassandraResource cassandraResource) {
|
|
||||||
|
|
||||||
Assert.notNull(cassandraResource, "CassandraResource must not be null!");
|
|
||||||
|
|
||||||
return new CassandraKeyspace(getHost(), getPort(), keyspaceName, cassandraResource, requiredVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup a version requirement.
|
|
||||||
*
|
|
||||||
* @param requiredVersion must not be {@literal null}.
|
|
||||||
* @return the {@link CassandraKeyspace} rule
|
|
||||||
*/
|
|
||||||
public CassandraKeyspace atLeast(Version requiredVersion) {
|
|
||||||
|
|
||||||
Assert.notNull(requiredVersion, "Required version must not be null!");
|
|
||||||
|
|
||||||
return new CassandraKeyspace(getHost(), getPort(), keyspaceName, dependency, requiredVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.junit.rules.ExternalResource#before()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void before() throws Throwable {
|
|
||||||
|
|
||||||
dependency.before();
|
|
||||||
|
|
||||||
try (CqlSession session = CqlSession.builder().addContactPoint(new InetSocketAddress(getHost(), getPort()))
|
|
||||||
.withLocalDatacenter("datacenter1").build()) {
|
|
||||||
|
|
||||||
if (requiredVersion != null) {
|
|
||||||
|
|
||||||
Version cassandraReleaseVersion = CassandraVersion.getReleaseVersion(session);
|
|
||||||
|
|
||||||
if (cassandraReleaseVersion.isLessThan(requiredVersion)) {
|
|
||||||
throw new AssumptionViolatedException(
|
|
||||||
String.format("Cassandra at %s:%s runs in Version %s but we require at least %s", getHost(), getPort(),
|
|
||||||
cassandraReleaseVersion, requiredVersion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s \n"
|
|
||||||
+ "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", keyspaceName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.junit.rules.ExternalResource#after()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void after() {
|
|
||||||
|
|
||||||
super.after();
|
|
||||||
dependency.after();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017-2018 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package example.springdata.cassandra.util;
|
|
||||||
|
|
||||||
import org.junit.rules.ExternalResource;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class to abstract contact point details for Apache Cassandra as {@link ExternalResource}.
|
|
||||||
*
|
|
||||||
* @author Mark Paluch
|
|
||||||
*/
|
|
||||||
public abstract class CassandraResource extends ExternalResource {
|
|
||||||
|
|
||||||
private final String host;
|
|
||||||
private final int port;
|
|
||||||
|
|
||||||
CassandraResource(String host, int port) {
|
|
||||||
|
|
||||||
Assert.hasText(host, "Host must not be null or empty!");
|
|
||||||
Assert.isTrue(port >= 0 && port <= 65535, "Port must be in the range of 0..65535!");
|
|
||||||
|
|
||||||
this.host = host;
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the Cassandra hostname.
|
|
||||||
*/
|
|
||||||
public String getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the Cassandra port.
|
|
||||||
*/
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.junit.rules.ExternalResource#before()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void before() throws Throwable {
|
|
||||||
super.before();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.junit.rules.ExternalResource#after()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void after() {
|
|
||||||
super.after();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017-2018 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package example.springdata.cassandra.util;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
|
||||||
|
import org.junit.jupiter.api.Assumptions;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility for Cassandra server use. This utility can start a Cassandra instance, reuse a running instance or simply
|
||||||
|
* require a running Cassandra server (will skip the test if Cassandra is not running).
|
||||||
|
*
|
||||||
|
* @author Mark Paluch
|
||||||
|
*/
|
||||||
|
class CassandraServer {
|
||||||
|
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
private final RuntimeMode runtimeMode;
|
||||||
|
|
||||||
|
private CassandraServer(String host, int port, RuntimeMode runtimeMode) {
|
||||||
|
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.runtimeMode = runtimeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Require a running instance on {@code host:port}. Fails with {@link AssumptionViolatedException} if Cassandra is not
|
||||||
|
* running.
|
||||||
|
*
|
||||||
|
* @param host must not be {@literal null} or empty.
|
||||||
|
* @param port must be between 0 and 65535.
|
||||||
|
* @return the {@link CassandraServer} rule
|
||||||
|
*/
|
||||||
|
public static CassandraServer requireRunningInstance(String host, int port) {
|
||||||
|
return new CassandraServer(host, port, RuntimeMode.REQUIRE_RUNNING_INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start an embedded Cassandra instance on {@code host:port} if Cassandra is not running already.
|
||||||
|
*
|
||||||
|
* @param host must not be {@literal null} or empty.
|
||||||
|
* @param port must be between 0 and 65535.
|
||||||
|
* @return the {@link CassandraServer} rule
|
||||||
|
*/
|
||||||
|
public static CassandraServer embeddedIfNotRunning(String host, int port) {
|
||||||
|
return new CassandraServer(host, port, RuntimeMode.EMBEDDED_IF_NOT_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param host must not be {@literal null} or empty.
|
||||||
|
* @param port
|
||||||
|
* @return {@literal true} if the TCP port accepts a connection.
|
||||||
|
*/
|
||||||
|
public static boolean isConnectable(String host, int port) {
|
||||||
|
|
||||||
|
Assert.hasText(host, "Host must not be null or empty!");
|
||||||
|
|
||||||
|
try (Socket socket = new Socket()) {
|
||||||
|
|
||||||
|
socket.setSoLinger(true, 0);
|
||||||
|
socket.connect(new InetSocketAddress(host, port), (int) TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void before() throws Exception {
|
||||||
|
|
||||||
|
if (runtimeMode == RuntimeMode.REQUIRE_RUNNING_INSTANCE) {
|
||||||
|
Assumptions.assumeTrue(isConnectable(getHost(), getPort()),
|
||||||
|
() -> String.format("Cassandra is not reachable at %s:%s.", getHost(), getPort()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runtimeMode == RuntimeMode.EMBEDDED_IF_NOT_RUNNING) {
|
||||||
|
if (isConnectable(getHost(), getPort())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EmbeddedCassandraServerHelper.startEmbeddedCassandra("embedded-cassandra.yaml", "target/embeddedCassandra",
|
||||||
|
TimeUnit.SECONDS.toMillis(60));
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum RuntimeMode {
|
||||||
|
REQUIRE_RUNNING_INSTANCE, EMBEDDED_IF_NOT_RUNNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017-2018 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package example.springdata.cassandra.util;
|
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mark Paluch
|
|
||||||
*/
|
|
||||||
@UtilityClass
|
|
||||||
class CassandraSocket {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param host must not be {@literal null} or empty.
|
|
||||||
* @param port
|
|
||||||
* @return {@literal true} if the TCP port accepts a connection.
|
|
||||||
*/
|
|
||||||
public static boolean isConnectable(String host, int port) {
|
|
||||||
|
|
||||||
Assert.hasText(host, "Host must not be null or empty!");
|
|
||||||
|
|
||||||
try (Socket socket = new Socket()) {
|
|
||||||
|
|
||||||
socket.setSoLinger(true, 0);
|
|
||||||
socket.connect(new InetSocketAddress(host, port), (int) TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
234
cassandra/util/src/main/resources/application.conf
Normal file
234
cassandra/util/src/main/resources/application.conf
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
# Configuration for the DataStax Java driver for Apache Cassandra®.
|
||||||
|
#
|
||||||
|
# Unless you use a custom mechanism to load your configuration (see
|
||||||
|
# SessionBuilder.withConfigLoader), all the values declared here will be used as defaults. You can
|
||||||
|
# place your own `application.conf` in the classpath to override them.
|
||||||
|
#
|
||||||
|
# Options are classified into two categories:
|
||||||
|
# - basic: what is most likely to be customized first when kickstarting a new application.
|
||||||
|
# - advanced: more elaborate tuning options, or "expert"-level customizations.
|
||||||
|
#
|
||||||
|
# This file is in HOCON format, see https://github.com/typesafehub/config/blob/master/HOCON.md.
|
||||||
|
datastax-java-driver {
|
||||||
|
|
||||||
|
basic.load-balancing-policy {
|
||||||
|
class = DcInferringLoadBalancingPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
basic.request {
|
||||||
|
# How long the driver waits for a request to complete. This is a global limit on the duration of
|
||||||
|
# a session.execute() call, including any internal retries the driver might do.
|
||||||
|
#
|
||||||
|
# By default, this value is set pretty high to ensure that DDL queries don't time out, in order
|
||||||
|
# to provide the best experience for new users trying the driver with the out-of-the-box
|
||||||
|
# configuration.
|
||||||
|
# For any serious deployment, we recommend that you use separate configuration profiles for DDL
|
||||||
|
# and DML; you can then set the DML timeout much lower (down to a few milliseconds if needed).
|
||||||
|
#
|
||||||
|
# Note that, because timeouts are scheduled on the driver's timer thread, the duration specified
|
||||||
|
# here must be greater than the timer tick duration defined by the
|
||||||
|
# advanced.netty.timer.tick-duration setting (see below). If that is not the case, timeouts will
|
||||||
|
# not be triggered as timely as desired.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for requests issued after the change.
|
||||||
|
# Overridable in a profile: yes
|
||||||
|
timeout = 8 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
# ADVANCED OPTIONS -------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
advanced.connection {
|
||||||
|
# The timeout to use for internal queries that run as part of the initialization process, just
|
||||||
|
# after we open a connection. If this timeout fires, the initialization of the connection will
|
||||||
|
# fail. If this is the first connection ever, the driver will fail to initialize as well,
|
||||||
|
# otherwise it will retry the connection later.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for connections created after the
|
||||||
|
# change.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
init-query-timeout = 500 milliseconds
|
||||||
|
|
||||||
|
# The driver maintains a connection pool to each node, according to the distance assigned to it
|
||||||
|
# by the load balancing policy. If the distance is IGNORED, no connections are maintained.
|
||||||
|
pool {
|
||||||
|
local {
|
||||||
|
# The number of connections in the pool.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes; when the change is detected, all active pools will be notified
|
||||||
|
# and will adjust their size.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
remote {
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
advanced.metrics {
|
||||||
|
# The session-level metrics (all disabled by default).
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
session {
|
||||||
|
enabled = []
|
||||||
|
|
||||||
|
}
|
||||||
|
# The node-level metrics (all disabled by default).
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
node {
|
||||||
|
enabled = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
advanced.control-connection {
|
||||||
|
schema-agreement {
|
||||||
|
# The interval between each attempt.
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for checks issued after the change.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
interval = 100 seconds
|
||||||
|
|
||||||
|
# The timeout after which schema agreement fails.
|
||||||
|
# If this is set to 0, schema agreement is skipped and will always fail.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for checks issued after the change.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
timeout = 100 seconds
|
||||||
|
|
||||||
|
# Whether to log a warning if schema agreement fails.
|
||||||
|
# You might want to change this if you've set the timeout to 0.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for checks issued after the change.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
warn-on-failure = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Options related to the Netty event loop groups used internally by the driver.
|
||||||
|
advanced.netty {
|
||||||
|
|
||||||
|
# Whether the threads created by the driver should be daemon threads.
|
||||||
|
# This will apply to the threads in io-group, admin-group, and the timer thread.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
daemon = false
|
||||||
|
|
||||||
|
# The event loop group used for I/O operations (reading and writing to Cassandra nodes).
|
||||||
|
# By default, threads in this group are named after the session name, "-io-" and an incrementing
|
||||||
|
# counter, for example "s0-io-0".
|
||||||
|
io-group {
|
||||||
|
# The number of threads.
|
||||||
|
# If this is set to 0, the driver will use `Runtime.getRuntime().availableProcessors() * 2`.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
size = 4
|
||||||
|
|
||||||
|
# The options to shut down the event loop group gracefully when the driver closes. If a task
|
||||||
|
# gets submitted during the quiet period, it is accepted and the quiet period starts over.
|
||||||
|
# The timeout limits the overall shutdown time.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
shutdown {quiet-period = 0, timeout = 0, unit = SECONDS}
|
||||||
|
}
|
||||||
|
# The event loop group used for admin tasks not related to request I/O (handle cluster events,
|
||||||
|
# refresh metadata, schedule reconnections, etc.)
|
||||||
|
# By default, threads in this group are named after the session name, "-admin-" and an
|
||||||
|
# incrementing counter, for example "s0-admin-0".
|
||||||
|
admin-group {
|
||||||
|
size = 2
|
||||||
|
|
||||||
|
shutdown {quiet-period = 0, timeout = 0, unit = SECONDS}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
advanced.metadata {
|
||||||
|
# Topology events are external signals that inform the driver of the state of Cassandra nodes
|
||||||
|
# (by default, they correspond to gossip events received on the control connection).
|
||||||
|
# The debouncer helps smoothen out oscillations if conflicting events are sent out in short
|
||||||
|
# bursts.
|
||||||
|
# Debouncing may be disabled by setting the window to 0 or max-events to 1 (this is not
|
||||||
|
# recommended).
|
||||||
|
topology-event-debouncer {
|
||||||
|
# How long the driver waits to propagate an event. If another event is received within that
|
||||||
|
# time, the window is reset and a batch of accumulated events will be delivered.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
window = 0 second
|
||||||
|
|
||||||
|
# The maximum number of events that can accumulate. If this count is reached, the events are
|
||||||
|
# delivered immediately and the time window is reset. This avoids holding events indefinitely
|
||||||
|
# if the window keeps getting reset.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
max-events = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
# Options relating to schema metadata (Cluster.getMetadata.getKeyspaces).
|
||||||
|
# This metadata is exposed by the driver for informational purposes, and is also necessary for
|
||||||
|
# token-aware routing.
|
||||||
|
schema {
|
||||||
|
# Whether schema metadata is enabled.
|
||||||
|
# If this is false, the schema will remain empty, or to the last known value.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for refreshes issued after the
|
||||||
|
# change. It can also be overridden programmatically via Cluster.setSchemaMetadataEnabled.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
# Protects against bursts of schema updates (for example when a client issues a sequence of
|
||||||
|
# DDL queries), by coalescing them into a single update.
|
||||||
|
# Debouncing may be disabled by setting the window to 0 or max-events to 1 (this is highly
|
||||||
|
# discouraged for schema refreshes).
|
||||||
|
debouncer {
|
||||||
|
# How long the driver waits to apply a refresh. If another refresh is requested within that
|
||||||
|
# time, the window is reset and a single refresh will be triggered when it ends.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
window = 0 second
|
||||||
|
|
||||||
|
# The maximum number of refreshes that can accumulate. If this count is reached, a refresh
|
||||||
|
# is done immediately and the window is reset.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: no
|
||||||
|
# Overridable in a profile: no
|
||||||
|
max-events = 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Whether token metadata (Cluster.getMetadata.getTokenMap) is enabled.
|
||||||
|
# This metadata is exposed by the driver for informational purposes, and is also necessary for
|
||||||
|
# token-aware routing.
|
||||||
|
# If this is false, it will remain empty, or to the last known value. Note that its computation
|
||||||
|
# requires information about the schema; therefore if schema metadata is disabled or filtered to
|
||||||
|
# a subset of keyspaces, the token map will be incomplete, regardless of the value of this
|
||||||
|
# property.
|
||||||
|
#
|
||||||
|
# Required: yes
|
||||||
|
# Modifiable at runtime: yes, the new value will be used for refreshes issued after the change.
|
||||||
|
# Overridable in a profile: no
|
||||||
|
token-map.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user