Skip to content

Redis embedded server for Java integration testing

Notifications You must be signed in to change notification settings

magro/embedded-redis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

embedded-redis

Redis embedded server for Java integration testing

Maven dependency

Currently embedded-redis is available in clojars repository:

<repository>
  <id>clojars.org</id>
  <url>http://clojars.org/repo</url>
</repository>

Dependency configuration:

<dependency>
  <groupId>redis.embedded</groupId>
  <artifactId>embedded-redis</artifactId>
  <version>0.1</version>
</dependency>

More at https://clojars.org/redis.embedded/embedded-redis

Usage example

Running RedisServer is as simple as:

RedisServer redisServer = new RedisServer(6379);
redisServer.start();
// do some work
redisServer.stop();

You can also provide RedisServer with your own redis executable to run:

RedisServer redisServer = new RedisServer("/path/to/your/redis", 6379);

A simple redis integration test would look like this:

public class SomeIntegrationTestThatRequiresRedis {
  private RedisServer redisServer;
  
  @Before
  public void setup() throws Exception {
    redisServer = new RedisServer(6379); // or new RedisServer("/path/to/your/redis", 6379);
    redisServer.start();
  }
  
  @Test
  public void test() throws Exception {
    // testing code that requires redis running
  }
  
  @After
  public void tearDown() throws Exception {
    redisServer.stop();
  }
}

Redis version

When not provided with the desired redis executable, RedisServer runs os-dependent executable enclosed in jar. Currently is uses:

However, you should provide RedisServer with redis executable if you need specific version.

About

Redis embedded server for Java integration testing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%