BAEL-482: A Guide to Redis with Redisson (#1353)

* Evaluation artical : Different Types of Bean Injection in Spring

* Evaluation artical : Different Types of Bean Injection in Spring

* Evaluation artical : Different Types of Bean Injection in Spring

* BAEL-482

* Evaluation artical : Different Types of Bean Injection in Spring

* Evaluation artical : Different Types of Bean Injection in Spring

* Evaluation artical : Different Types of Bean Injection in Spring

* Evaluation artical : Different Types of Bean Injection in Spring

* BAEL-482

* Evaluation artical : Different Types of Bean Injection in Spring

* BAEL-482
This commit is contained in:
Johnson Okorie
2017-03-10 19:41:04 +01:00
committed by Grzegorz Piwowarek
parent 453de7e93d
commit 80b222b7bd
10 changed files with 447 additions and 0 deletions
@@ -0,0 +1,65 @@
package com.baeldung;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import redis.embedded.RedisServer;
import java.io.File;
import java.io.IOException;
/**
* Created by johnson on 3/9/17.
*/
public class RedissonConfigurationTest {
private static RedisServer redisServer;
private static RedissonClient client;
@BeforeClass
public static void setUp() throws IOException {
redisServer = new RedisServer(6379);
redisServer.start();
}
@AfterClass
public static void destroy() {
redisServer.stop();
client.shutdown();
}
@Test
public void givenJavaConfig_thenRedissonConnectToRedis() {
Config config = new Config();
config.useSingleServer()
.setAddress("127.0.0.1:6379");
client = Redisson.create(config);
assert(client != null && client.getKeys().count() >= 0);
}
@Test
public void givenJSONFileConfig_thenRedissonConnectToRedis() throws IOException {
Config config = Config.fromJSON(
new File(getClass().getClassLoader().getResource(
"singleNodeConfig.json").getFile()));
client = Redisson.create(config);
assert(client != null && client.getKeys().count() >= 0);
}
@Test
public void givenYAMLFileConfig_thenRedissonConnectToRedis() throws IOException {
Config config = Config.fromYAML(
new File(getClass().getClassLoader().getResource(
"singleNodeConfig.yaml").getFile()));
client = Redisson.create(config);
assert(client != null && client.getKeys().count() >= 0);
}
}