Files
spring-boot-rest/persistence-modules/redis/src/test/java/com/baeldung/RedissonConfigurationIntegrationTest.java
Doha2012 26c50909be group persistence modules (#2890)
* move security content from spring-security-rest-full

* swagger update

* move query language to new module

* rename spring-security-rest-full to spring-rest-full

* group persistence modules
2017-10-29 23:07:04 +01:00

65 lines
1.7 KiB
Java

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 RedissonConfigurationIntegrationTest {
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);
}
}