Enable long-running tests via system property

This commit is contained in:
Jennifer Hickey
2013-03-31 10:02:21 -07:00
parent a1fb8aad69
commit b968b85ff4
7 changed files with 54 additions and 22 deletions

View File

@@ -1,12 +1,12 @@
/*
* Copyright 2011-2013 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,51 +20,50 @@ import static org.junit.Assert.assertTrue;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Costin Leau
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("namespace.xml")
@ProfileValueSourceConfiguration
public class NamespaceTest {
private GenericXmlApplicationContext ctx;
@Autowired
private RedisMessageListenerContainer container;
@Before
public void setUp() {
ctx = new GenericXmlApplicationContext("/org/springframework/data/redis/config/namespace.xml");
}
@Autowired
private StringRedisTemplate template;
@After
public void tearDown() {
if (ctx != null)
ctx.destroy();
}
@Autowired
private StubErrorHandler handler;
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testSanityTest() throws Exception {
RedisMessageListenerContainer container = ctx.getBean(RedisMessageListenerContainer.class);
assertTrue(container.isRunning());
Thread.sleep(TimeUnit.SECONDS.toMillis(8));
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testWithMessages() throws Exception {
StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
template.convertAndSend("x1", "[X]test");
template.convertAndSend("z1", "[Z]test");
Thread.sleep(TimeUnit.SECONDS.toMillis(8));
}
public void testErrorHandler() throws Exception {
StubErrorHandler handler = ctx.getBean(StubErrorHandler.class);
int index = handler.throwables.size();
StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
template.convertAndSend("exception", "test1");
handler.throwables.pollLast(3, TimeUnit.SECONDS);
assertEquals(index + 1, handler.throwables.size());

View File

@@ -54,6 +54,8 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
/**
* Base test class for AbstractConnection integration tests
@@ -62,6 +64,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
* @author Jennifer Hickey
*
*/
@ProfileValueSourceConfiguration
public abstract class AbstractConnectionIntegrationTests {
protected StringRedisConnection connection;
@@ -93,6 +96,7 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpire() throws Exception {
connection.set("exp", "true");
assertTrue(connection.expire("exp", 1));
@@ -100,13 +104,15 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpireAt() throws Exception {
connection.set("exp2", "true");
assertTrue(connection.expireAt("exp2", System.currentTimeMillis() / 1000 + 1));
assertFalse(exists("exp2", 2000l));
assertFalse(exists("exp2", 3000l));
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testPersist() throws Exception {
connection.set("exp3", "true");
actual.add(connection.expire("exp3", 1));
@@ -117,6 +123,7 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testSetEx() throws Exception {
connection.setEx("expy", 1l, "yep");
assertEquals("yep", connection.get("expy"));
@@ -124,6 +131,7 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testBRPopTimeout() throws Exception {
actual.add(connection.bRPop(1, "alist"));
Thread.sleep(1500l);
@@ -131,6 +139,7 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testBLPopTimeout() throws Exception {
actual.add(connection.bLPop(1, "alist"));
Thread.sleep(1500l);
@@ -138,6 +147,7 @@ public abstract class AbstractConnectionIntegrationTests {
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testBRPopLPushTimeout() throws Exception {
actual.add(connection.bRPopLPush(1, "alist", "foo"));
Thread.sleep(1500l);
@@ -1157,6 +1167,10 @@ public abstract class AbstractConnectionIntegrationTests {
exists = false;
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
return exists;
}

View File

@@ -38,6 +38,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.data.redis.serializer.SerializationUtils;
import org.springframework.test.annotation.IfProfileValue;
/**
* Base test class for integration tests that execute each operation of a
@@ -107,6 +108,7 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpire() throws Exception {
connection.set("exp", "true");
actual.add(connection.expire("exp", 1));
@@ -116,6 +118,7 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpireAt() throws Exception {
connection.set("exp2", "true");
actual.add(connection.expireAt("exp2", System.currentTimeMillis() / 1000 + 1));
@@ -125,6 +128,7 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testPersist() throws Exception {
connection.set("exp3", "true");
actual.add(connection.expire("exp3", 1));
@@ -135,6 +139,7 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testSetEx() throws Exception {
connection.setEx("expy", 1l, "yep");
actual.add(connection.get("expy"));

View File

@@ -28,6 +28,7 @@ import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests;
import org.springframework.data.redis.connection.DefaultStringTuple;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -236,6 +237,7 @@ public class JedisConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpireAt() throws Exception {
connection.set("exp2", "true");
actual.add(connection.expireAt("exp2", System.currentTimeMillis() / 1000 + 1));
@@ -245,6 +247,7 @@ public class JedisConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testPersist() throws Exception {
connection.set("exp3", "true");
actual.add(connection.expire("exp3", 1));

View File

@@ -34,6 +34,7 @@ import org.junit.runner.RunWith;
import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests;
import org.springframework.data.redis.connection.DefaultStringTuple;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -209,6 +210,7 @@ public class LettuceConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testPersist() throws Exception {
connection.set("exp3", "true");
actual.add(connection.expire("exp3", 1));
@@ -219,6 +221,7 @@ public class LettuceConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpireAt() throws Exception {
connection.set("exp2", "true");
actual.add(connection.expireAt("exp2", System.currentTimeMillis() / 1000 + 1));
@@ -228,6 +231,7 @@ public class LettuceConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpire() throws Exception {
connection.set("exp", "true");
actual.add(connection.expire("exp", 1));
@@ -237,6 +241,7 @@ public class LettuceConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testSetEx() throws Exception {
connection.setEx("expy", 1l, "yep");
actual.add(connection.get("expy"));

View File

@@ -33,6 +33,7 @@ import org.springframework.data.redis.connection.DefaultStringRedisConnection;
import org.springframework.data.redis.connection.DefaultStringTuple;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.data.redis.serializer.SerializationUtils;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -223,6 +224,7 @@ public class RjcConnectionPipelineIntegrationTests extends
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testBRPopLPushTimeout() throws Exception {
connection.bRPopLPush(1, "alist", "foo");
Thread.sleep(1500l);