From 89cf1f7decfeb434043a06acf7b17f57ca4865c0 Mon Sep 17 00:00:00 2001 From: sriramak Date: Tue, 24 Jan 2017 16:35:41 +0530 Subject: [PATCH] unit tests work only if redis is running on the test machine. added embedded redis so the tests will pass --- pom.xml | 6 ++++++ .../java/com/cwbase/logback/RedisAppenderTest.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pom.xml b/pom.xml index b3efa7e..b43eb30 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,12 @@ 1.1.2 provided + + com.github.kstyrc + embedded-redis + 0.6 + test + diff --git a/src/test/java/com/cwbase/logback/RedisAppenderTest.java b/src/test/java/com/cwbase/logback/RedisAppenderTest.java index decaa50..8a04f00 100644 --- a/src/test/java/com/cwbase/logback/RedisAppenderTest.java +++ b/src/test/java/com/cwbase/logback/RedisAppenderTest.java @@ -21,12 +21,26 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import java.io.IOException; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import redis.embedded.RedisServer; public class RedisAppenderTest { + static RedisServer redisServer; String key = "logstash"; Jedis redis; + @BeforeClass + public static void beforeClass() throws IOException { + redisServer = new RedisServer(6379); + redisServer.start(); + } + @AfterClass + public static void afterClass() { + redisServer.stop(); + } @Test public void logTest() throws Exception { // refer to logback.xml in test folder