Redis instance for unit testing applications.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 923fc03 Feb 4, 2017
Permalink
Failed to load latest commit information.
.mvn/wrapper first commit Nov 26, 2016
src add javadocs Feb 3, 2017
.gitignore set temporary directory in project Dec 4, 2016
.travis.yml Update .travis.yml Dec 13, 2016
README.md add existence check Dec 21, 2016
appveyor.yml update appveyor.yml Dec 15, 2016
mvnw first commit Nov 26, 2016
mvnw.cmd first commit Nov 26, 2016
pom.xml add existence check Dec 21, 2016

README.md

Redis Unit

Build Status Build Status Maven Central

Start and stop Redis(v3.2.5) instance for unit testing applications.

Redis unit requires Java 8 at runtime.

Features

  • Redis Server support
  • Redis Master / Slave support
  • Redis Sentinel (+ Redis Master / Slave) support
  • Redis Cluster support

Maven Central

<dependency>
  <groupId>net.ishiis.redis</groupId>
  <artifactId>redis-unit</artifactId>
  <version>1.0.3</version>
  <scope>test</scope>
</dependency>

Usage

Quick start

1, Redis Server

Redis Server listen 6379

RedisServer server = new RedisServer();
server.start();
// do something
server.stop();

2, Redis Master / Slave

Redis Master listen 6379, and Slave listen 6380.

RedisMasterSlave masterSlave = new RedisMasterSlave();
masterSlave.start();
// do something
masterSlave.stop();

3, Redis Sentinel (+ Redis Master / Slave)

Redis Sentinel listen 26379, 26380, 26381.

RedisSentinel sentinel = new RedisSentinel();
sentinel.start();
// do something
sentinel.stop();

4, Redis Cluster

Redis Cluster listen 6379, 6380, 6381.

RedisCluster cluster = new RedisCluster();
cluster.start();
// do something
cluster.stop();

Customize

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);

Development

Requirements

  • Java 8
  • Maven 3.0.0 or higher

First bootstrap and download the wrapper

cd redis_unit_source_dir
./mvnw

Running unit tests

./mvnw test