com.asarkar.spring:cassandra-unit-spring

Starts the Cassandra server and makes the ports available as Spring Boot environment properties

Лицензия

Лицензия

Категории

Категории

Cassandra Данные Базы данных
Группа

Группа

com.asarkar.spring
Идентификатор

Идентификатор

cassandra-unit-spring
Последняя версия

Последняя версия

2.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

com.asarkar.spring:cassandra-unit-spring
Starts the Cassandra server and makes the ports available as Spring Boot environment properties
Ссылка на сайт

Ссылка на сайт

https://github.com/asarkar/cassandra-unit-spring
Система контроля версий

Система контроля версий

https://github.com/asarkar/cassandra-unit-spring

Скачать cassandra-unit-spring

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.asarkar.spring/cassandra-unit-spring/ -->
<dependency>
    <groupId>com.asarkar.spring</groupId>
    <artifactId>cassandra-unit-spring</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.asarkar.spring/cassandra-unit-spring/
implementation 'com.asarkar.spring:cassandra-unit-spring:2.0.0'
// https://jarcasting.com/artifacts/com.asarkar.spring/cassandra-unit-spring/
implementation ("com.asarkar.spring:cassandra-unit-spring:2.0.0")
'com.asarkar.spring:cassandra-unit-spring:jar:2.0.0'
<dependency org="com.asarkar.spring" name="cassandra-unit-spring" rev="2.0.0">
  <artifact name="cassandra-unit-spring" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.asarkar.spring', module='cassandra-unit-spring', version='2.0.0')
)
libraryDependencies += "com.asarkar.spring" % "cassandra-unit-spring" % "2.0.0"
[com.asarkar.spring/cassandra-unit-spring "2.0.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.10

runtime (3)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-test jar
org.cassandraunit : cassandra-unit jar 4.3.1.0
com.datastax.oss : java-driver-core jar 4.9.0

Модули Проекта

Данный проект не имеет модулей.

cassandra-unit-spring

Starts the Cassandra server and makes the ports available as Spring Boot environment properties.

Requires Java 8 or later. Uses cassandra-unit and Spring Boot.

Installation

You can find the latest version on Bintray. Download

It is also on Maven Central and jcenter.

Usage

The only thing you need is the AutoConfigureCassandraUnit annotation:

@SpringBootTest
@AutoConfigureCassandraUnit(config = EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE)
public class AutoConfigureWithRandomPortsTest {
    @Value("${cassandra-unit.native-transport-port:-1}")
    private int nativeTransportPort = -1;

    @Value("${cassandra-unit.rpc-port:-1}")
    private int rpcPort = -1;

    @Test
    public void testUseRandomPorts() {
        Assertions.assertEquals(EmbeddedCassandraServerHelper.getNativeTransportPort(), nativeTransportPort);
        Assertions.assertEquals(EmbeddedCassandraServerHelper.getRpcPort(), rpcPort);
    }
}

See KDoc for more details.

Note that CassandraUnit can only run one Cassandra instance per JVM; thus, if AutoConfigureCassandraUnit annotation is present on more than one test classes, only the first one is used, the others are ignored. That means the port properties will not change once a Cassandra instance is started.

This library aims to be minimal and manages only the lifecycle of the Cassandra server during testing; it does not run initialization scripts or clean the database between tests, because you can do those things yourself.

If you abort a test or run two tests both of which start the server, you may be faced with a FileAlreadyExistsException. That is because of this bug. If using Maven, clean goal will delete the temporary directory; if using Gradle, you can either delete the target directory manually, or add it to the Gradle clean task.

Contribute

This project is a volunteer effort. You are welcome to send pull requests, ask questions, or create issues. If you like it, you can help by spreading the word!

License

Copyright 2020 Abhijit Sarkar - Released under Apache License v2.0.

Версии библиотеки

Версия
2.0.0
1.0.7