{"id":18329631,"url":"https://github.com/jupiter-tools/spring-test-redis","last_synced_at":"2025-08-10T03:06:21.344Z","repository":{"id":57725719,"uuid":"188244211","full_name":"jupiter-tools/spring-test-redis","owner":"jupiter-tools","description":"Tools to write integration tests of Spring Framework with Redis","archived":false,"fork":false,"pushed_at":"2024-08-05T21:30:34.000Z","size":423,"stargazers_count":2,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-10T21:07:07.773Z","etag":null,"topics":["redis","spring-boot","spring-boot-redis","spring-boot-test","spring-data-redis","spring-redis","testcontainers"],"latest_commit_sha":null,"homepage":"http://jupiter-tools.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jupiter-tools.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-23T13:54:08.000Z","updated_at":"2021-07-22T06:11:24.000Z","dependencies_parsed_at":"2022-09-02T03:41:11.793Z","dependency_job_id":null,"html_url":"https://github.com/jupiter-tools/spring-test-redis","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jupiter-tools/spring-test-redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fspring-test-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fspring-test-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fspring-test-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fspring-test-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupiter-tools","download_url":"https://codeload.github.com/jupiter-tools/spring-test-redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fspring-test-redis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269668693,"owners_count":24456526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["redis","spring-boot","spring-boot-redis","spring-boot-test","spring-data-redis","spring-redis","testcontainers"],"created_at":"2024-11-05T19:18:07.708Z","updated_at":"2025-08-10T03:06:21.300Z","avatar_url":"https://github.com/jupiter-tools.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":":toc: preamble\n\n# Spring Test Redis\n\nimage:https://travis-ci.com/jupiter-tools/spring-test-redis.svg?branch=master[\"Build Status\", link=\"https://travis-ci.com/jupiter-tools/spring-test-redis\"]\n\n\nTools to write integration tests of Spring Framework with Redis.\n\n## Overview\n\nimage:./images/redis.png[redis container scheme,300]\n\n## How to write integration tests on Spring Framework with Redis\n\nAdd this library in dependencies:\n\n[source,xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.jupiter-tools\u003c/groupId\u003e\n    \u003cartifactId\u003espring-test-redis\u003c/artifactId\u003e\n    \u003cversion\u003e0.1\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nAnd now, you can start Redis in docker (TestContainers) by the using of `@RedisTestContainer` annotation in tests:\n\n[source, java]\n----\n@SpringBootTest\n@RedisTestContainer\nclass RedisTestContainerTest {\n\n    @Autowired\n    private RedisTemplate redisTemplate;\n\n    @Test\n    void readWriteValueByRedisTemplate() {\n        String key = \"test\";\n        String value = \"sabracadabra\";\n        // Act\n        redisTemplate.opsForValue().set(key, value);\n        // Assert\n        assertThat(redisTemplate.opsForValue().get(key)).isEqualTo(value);\n    }\n}\n----\n\nYou 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.\n\n## How to use multiple Redis containers in the one test case:\n\n[source, java]\n----\n@SpringBootTest\n@RedisTestContainer  \u003c1\u003e\n@RedisTestContainer(hostTargetProperty = \"my.host\", portTargetProperty = \"my.port\")  \u003c2\u003e\nclass MultipleContainerInOneTest {\n\n    ...\n\n}\n----\n\u003c1\u003e 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`)\n\u003c2\u003e 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.\n\nAfter test execution you can see something like this in the output:\n\nimage:./images/multiple_containers.png[multiple docker container result in stdout]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiter-tools%2Fspring-test-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupiter-tools%2Fspring-test-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiter-tools%2Fspring-test-redis/lists"}