Search in sources :

Example 6 with RedisRunner

use of org.redisson.RedisRunner in project redisson by redisson.

the class SpringNamespaceWikiTest method testReplicated.

@Test
public void testReplicated() throws Exception {
    RedisRunner.RedisProcess master = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").nosave().randomDir().run();
    RedisRunner.RedisProcess slave1 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6380).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    RedisRunner.RedisProcess slave2 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6381).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    try {
        ((ConfigurableApplicationContext) new ClassPathXmlApplicationContext("classpath:org/redisson/spring/support/namespace_wiki_replicated.xml")).close();
    } finally {
        master.stop();
        slave1.stop();
        slave2.stop();
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) RedisRunner(org.redisson.RedisRunner) Test(org.junit.Test)

Example 7 with RedisRunner

use of org.redisson.RedisRunner in project redisson by redisson.

the class JCacheTest method testRedissonConfig.

@Test
public void testRedissonConfig() throws InterruptedException, IllegalArgumentException, URISyntaxException, IOException {
    RedisProcess runner = new RedisRunner().nosave().randomDir().port(6311).run();
    URL configUrl = getClass().getResource("redisson-jcache.json");
    Config cfg = Config.fromJSON(configUrl);
    Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
    Cache<String, String> cache = Caching.getCachingProvider().getCacheManager().createCache("test", config);
    cache.put("1", "2");
    Assert.assertEquals("2", cache.get("1"));
    cache.close();
    runner.stop();
}
Also used : RedisProcess(org.redisson.RedisRunner.RedisProcess) Config(org.redisson.config.Config) RedisRunner(org.redisson.RedisRunner) URL(java.net.URL) BaseTest(org.redisson.BaseTest) Test(org.junit.Test)

Aggregations

RedisRunner (org.redisson.RedisRunner)7 Test (org.junit.Test)6 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4 BaseTest (org.redisson.BaseTest)2 ClusterRunner (org.redisson.ClusterRunner)2 RedisProcess (org.redisson.RedisRunner.RedisProcess)2 URI (java.net.URI)1 URL (java.net.URL)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)1 MutableConfiguration (javax.cache.configuration.MutableConfiguration)1 CacheEntryExpiredListener (javax.cache.event.CacheEntryExpiredListener)1 Duration (javax.cache.expiry.Duration)1 Config (org.redisson.config.Config)1