Start and stop Redis(v3.2.5) instance for unit testing applications.
Redis unit requires Java 8 at runtime.
- Redis Server support
- Redis Master / Slave support
- Redis Sentinel (+ Redis Master / Slave) support
- Redis Cluster support
<dependency>
<groupId>net.ishiis.redis</groupId>
<artifactId>redis-unit</artifactId>
<version>1.0.3</version>
<scope>test</scope>
</dependency>
Redis Server listen 6379
RedisServer server = new RedisServer();
server.start();
// do something
server.stop();
Redis Master listen 6379
, and Slave listen 6380
.
RedisMasterSlave masterSlave = new RedisMasterSlave();
masterSlave.start();
// do something
masterSlave.stop();
Redis Sentinel listen 26379, 26380, 26381
.
RedisSentinel sentinel = new RedisSentinel();
sentinel.start();
// do something
sentinel.stop();
Redis Cluster listen 6379, 6380, 6381
.
RedisCluster cluster = new RedisCluster();
cluster.start();
// do something
cluster.stop();
If you want to customize Redis instances, use RedisConfig
.
RedisMasterSlaveConfig master = new RedisMasterSlaveConfig.MasterBuilder(6379)
.redisBinaryPath("/usr/local/bin/redis-server").build();
List<RedisMasterSlaveConfig> slaves = new ArrayList<>();
slaves.add(new RedisMasterSlaveConfig.SlaveBuilder(6380, 6379).redisBinaryPath("/usr/local/bin/redis-server").build());
slaves.add(new RedisMasterSlaveConfig.SlaveBuilder(6381, 6379).redisBinaryPath("/usr/local/bin/redis-server").build());
RedisMasterSlave masterSlave = new RedisMasterSlave(master, slaves);
- Java 8
- Maven 3.0.0 or higher
cd redis_unit_source_dir
./mvnw
./mvnw test