spring-test-redis

Tools suite to write integration tests for Spring Applications with the Redis.

Лицензия

Лицензия

Категории

Категории

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

Группа

com.jupiter-tools
Идентификатор

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

spring-test-redis
Последняя версия

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

0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

spring-test-redis
Tools suite to write integration tests for Spring Applications with the Redis.
Ссылка на сайт

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

https://github.com/jupiter-tools/spring-test-redis
Система контроля версий

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

https://github.com/jupiter-tools/spring-test-redis

Скачать spring-test-redis

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.testcontainers : testcontainers jar 1.10.2

provided (2)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-data-redis jar
org.springframework.boot : spring-boot-starter-test jar

test (5)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api jar 5.4.2
org.junit.jupiter : junit-jupiter-engine jar 5.4.2
org.junit.platform : junit-platform-engine jar 1.4.2
org.junit.platform : junit-platform-launcher jar 1.4.2
org.redisson : redisson jar 3.10.7

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

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

Spring Test Redis

Build Status

Tools to write integration tests of Spring Framework with Redis.

Overview

redis container scheme

How to write integration tests on Spring Framework with Redis

Add this library in dependencies:

<dependency>
    <groupId>com.jupiter-tools</groupId>
    <artifactId>spring-test-redis</artifactId>
    <version>0.1</version>
</dependency>

And now, you can start Redis in docker (TestContainers) by the using of @RedisTestContainer annotation in tests:

@SpringBootTest
@RedisTestContainer
class RedisTestContainerTest {

    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    void readWriteValueByRedisTemplate() {
        String key = "test";
        String value = "sabracadabra";
        // Act
        redisTemplate.opsForValue().set(key, value);
        // Assert
        assertThat(redisTemplate.opsForValue().get(key)).isEqualTo(value);
    }
}

You can use this annotation to start Redis container in tests both with JUnit5 and JUnit4. The implementation doesn’t depend on some test framework, just on the Spring Framework.

How to use multiple Redis containers in the one test case:

@SpringBootTest
@RedisTestContainer  (1)
@RedisTestContainer(hostTargetProperty = "my.host", portTargetProperty = "my.port")  (2)
class MultipleContainerInOneTest {

    ...

}
  1. start a Redis test container and set a host/port value of started container to default Spring Boot properties (spring.redis.host and spring.redis.port)

  2. start another Redis container and set a host/port value to specified properties, exactly in these properties you can read an actual value of host/port after run application context.

After test execution you can see something like this in the output:

multiple docker container result in stdout

com.jupiter-tools

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

Версия
0.1