提交 a4a10991 编写于 作者: N Nikita Koksharov

tests fixed

上级 7711c615
......@@ -3,6 +3,7 @@ package org.redisson;
import java.io.IOException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.redisson.api.RedissonClient;
......@@ -10,43 +11,24 @@ import org.redisson.config.Config;
public abstract class BaseTest {
protected RedissonClient redisson;
protected static RedissonClient defaultRedisson;
protected static RedissonClient redisson;
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {
if (!RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
defaultRedisson = createInstance();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
defaultRedisson.shutdown();
}
});
}
RedisRunner.startDefaultRedisServerInstance();
redisson = createInstance();
}
@Before
public void before() throws IOException, InterruptedException {
if (RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
redisson = createInstance();
} else {
if (redisson == null) {
redisson = defaultRedisson;
}
if (flushBetweenTests()) {
redisson.getKeys().flushall();
}
}
@AfterClass
public static void afterClass() throws InterruptedException {
redisson.shutdown();
RedisRunner.shutDownDefaultRedisServerInstance();
}
@After
public void after() throws InterruptedException {
if (RedissonRuntimeEnvironment.isTravis) {
redisson.shutdown();
RedisRunner.shutDownDefaultRedisServerInstance();
@Before
public void before() throws IOException, InterruptedException {
if (flushBetweenTests()) {
redisson.getKeys().flushall();
}
}
......
......@@ -24,27 +24,6 @@ public class RedissonLocalCachedMapSerializationCodecTest extends RedissonLocalC
return Redisson.create(config);
}
@BeforeClass
public static void beforeClass() throws IOException, InterruptedException {
if (!RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
defaultRedisson = createInstance();
}
}
@Before
public void before() throws IOException, InterruptedException {
if (RedissonRuntimeEnvironment.isTravis) {
RedisRunner.startDefaultRedisServerInstance();
redisson = createInstance();
} else {
if (redisson == null) {
redisson = defaultRedisson;
}
redisson.getKeys().flushall();
}
}
@Test @Override
public void testAddAndGet() throws InterruptedException {
// this method/test won't work with Java Serialization
......
......@@ -44,9 +44,7 @@ public class RedissonExecutorServiceTest extends BaseTest {
}
@After
@Override
public void after() throws InterruptedException {
super.after();
node.shutdown();
}
......
......@@ -44,9 +44,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
}
@After
@Override
public void after() throws InterruptedException {
super.after();
node.shutdown();
}
......
......@@ -115,10 +115,10 @@ public class SpringNamespaceObjectTest extends BaseTest {
public static void startContext() {
TestREntity entity = new TestREntity("live-object");
entity.setValue("1");
defaultRedisson.getLiveObjectService().merge(entity);
redisson.getLiveObjectService().merge(entity);
entity = new TestREntity("live-object-ext");
entity.setValue("1");
defaultRedisson.getLiveObjectService().merge(entity);
redisson.getLiveObjectService().merge(entity);
System.setProperty("redisAddress", RedisRunner.getDefaultRedisServerBindAddressAndPort());
context = new ClassPathXmlApplicationContext("classpath:org/redisson/spring/support/redisson_objects.xml");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册