dryrun is a collection of already-mocked classes that serve pretty useful during testing. For example unit testing code with RedisTemplate usually involves spinning a Redis instance. Our DryRunRedisTemplate uses the MockJedis framework to connect to an in-memory Redis, that connects via API calls and not via the usual connection.

Currently only RedisTemplate with operations for values is available. Operations on sets/lists/… are still pending.


To test code that uses RedisTemplate as a service, just inject the mocked template as:

// create a MockJedis instance
MockJedis jedis = new MockJedis("mock-jedis");

// create an instance of RedisTemplate
RedisTemplate<String, byte[]> template = new DryRunRedisTemplate<String, byte[]>(jedis);

// must specify the key and value serializers
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new RedisSerializer<byte[]>() {

	public byte[] serialize(byte[] t) throws SerializationException {
		return t;

	public byte[] deserialize(byte[] bytes) throws SerializationException {
		return bytes;

// inject in your service
MyTestableService service = new DefaultMyTestableServiceImpl();


The library can be downloaded from Maven Central using:

Fork me on GitHub