diff --git a/src/main/java/org/springframework/data/redis/core/ScanCursor.java b/src/main/java/org/springframework/data/redis/core/ScanCursor.java index bd088db81..d12ddf8fd 100644 --- a/src/main/java/org/springframework/data/redis/core/ScanCursor.java +++ b/src/main/java/org/springframework/data/redis/core/ScanCursor.java @@ -77,7 +77,7 @@ public abstract class ScanCursor implements Cursor { this.scanOptions = options != null ? options : ScanOptions.NONE; this.cursorId = cursorId; this.state = CursorState.READY; - this.delegate = Collections.emptyIterator(); + this.delegate = Collections. emptyList().iterator(); } private void scan(long cursorId) { @@ -143,7 +143,7 @@ public abstract class ScanCursor implements Cursor { } private void resetDelegate() { - delegate = Collections.emptyIterator(); + delegate = Collections. emptyList().iterator(); } /* diff --git a/src/test/java/org/springframework/data/redis/RedisTestProfileValueSource.java b/src/test/java/org/springframework/data/redis/RedisTestProfileValueSource.java index f2e8c1011..0d3a8e68f 100644 --- a/src/test/java/org/springframework/data/redis/RedisTestProfileValueSource.java +++ b/src/test/java/org/springframework/data/redis/RedisTestProfileValueSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 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. @@ -26,11 +26,13 @@ import org.springframework.test.annotation.ProfileValueSource; * "redisVersion" * * @author Jennifer Hickey + * @author Christoph Strobl */ public class RedisTestProfileValueSource implements ProfileValueSource { private static final String REDIS_24 = "2.4"; private static final String REDIS_26 = "2.6"; + private static final String REDIS_28 = "2.8"; private static final String REDIS_VERSION_KEY = "redisVersion"; private static Version redisVersion; private static final RedisTestProfileValueSource INSTANCE = new RedisTestProfileValueSource(); @@ -43,11 +45,15 @@ public class RedisTestProfileValueSource implements ProfileValueSource { RedisConnection connection = connectionFactory.getConnection(); redisVersion = RedisVersionUtils.getRedisVersion(connection); connection.close(); + connectionFactory.destroy(); } } public String get(String key) { if (REDIS_VERSION_KEY.equals(key)) { + if (redisVersion.compareTo(RedisVersionUtils.parseVersion(REDIS_28)) >= 0) { + return REDIS_28; + } if (redisVersion.compareTo(RedisVersionUtils.parseVersion(REDIS_26)) >= 0) { return REDIS_26; } diff --git a/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithCommitUnitTests.java b/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithCommitUnitTests.java index 3cd6be73e..69e2a5eee 100644 --- a/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithCommitUnitTests.java +++ b/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithCommitUnitTests.java @@ -39,10 +39,10 @@ import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.PlatformTransactionManager; @@ -51,7 +51,7 @@ import org.springframework.transaction.annotation.Transactional; /** * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration @Transactional @TransactionConfiguration(transactionManager = "transactionManager") diff --git a/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithRollbackUnitTests.java b/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithRollbackUnitTests.java index ad32c6252..cf6a404a2 100644 --- a/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithRollbackUnitTests.java +++ b/src/test/java/org/springframework/data/redis/cache/TransactionalRedisCacheManagerWithRollbackUnitTests.java @@ -35,10 +35,10 @@ import org.springframework.data.redis.cache.TransactionalRedisCacheManagerTestBa import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.PlatformTransactionManager; @@ -47,7 +47,7 @@ import org.springframework.transaction.annotation.Transactional; /** * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration @Transactional @TransactionConfiguration(transactionManager = "transactionManager") diff --git a/src/test/java/org/springframework/data/redis/config/NamespaceTest.java b/src/test/java/org/springframework/data/redis/config/NamespaceTest.java index 23032fbea..a83e22c36 100644 --- a/src/test/java/org/springframework/data/redis/config/NamespaceTest.java +++ b/src/test/java/org/springframework/data/redis/config/NamespaceTest.java @@ -15,8 +15,7 @@ */ package org.springframework.data.redis.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.concurrent.TimeUnit; @@ -25,15 +24,15 @@ 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.data.redis.test.util.RelaxedJUnit4ClassRunner; 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) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("namespace.xml") @ProfileValueSourceConfiguration public class NamespaceTest { diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index 0117931f4..b139d19b6 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -132,7 +132,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPExpire() { connection.set("exp", "true"); actual.add(connection.pExpire("exp", 100)); @@ -141,14 +141,14 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPExpireKeyNotExists() { actual.add(connection.pExpire("nonexistent", 100)); verifyResults(Arrays.asList(new Object[] { false })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPExpireAt() { connection.set("exp2", "true"); actual.add(connection.pExpireAt("exp2", System.currentTimeMillis() + 200)); @@ -157,14 +157,14 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPExpireAtKeyNotExists() { actual.add(connection.pExpireAt("nonexistent", System.currentTimeMillis() + 200)); verifyResults(Arrays.asList(new Object[] { false })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptLoadEvalSha() { getResults(); String sha1 = connection.scriptLoad("return KEYS[1]"); @@ -175,7 +175,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("unchecked") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayStrings() { getResults(); String sha1 = connection.scriptLoad("return {KEYS[1],ARGV[1]}"); @@ -188,21 +188,21 @@ public abstract class AbstractConnectionIntegrationTests { } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { connection.evalSha("notasha", ReturnType.MULTI, 1, "key1", "arg1"); getResults(); } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { connection.evalSha("somefakesha", ReturnType.VALUE, 2, "key1", "key2"); getResults(); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnString() { actual.add(connection.eval("return KEYS[1]", ReturnType.VALUE, 1, "foo")); byte[] result = (byte[]) getResults().get(0); @@ -210,35 +210,35 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnNumber() { actual.add(connection.eval("return 10", ReturnType.INTEGER, 0)); verifyResults(Arrays.asList(new Object[] { 10l })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleOK() { actual.add(connection.eval("return redis.call('set','abc','ghk')", ReturnType.STATUS, 0)); assertEquals(Arrays.asList(new Object[] { "OK" }), getResults()); } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { connection.eval("return redis.call('expire','foo')", ReturnType.BOOLEAN, 0); getResults(); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnFalse() { actual.add(connection.eval("return false", ReturnType.BOOLEAN, 0)); verifyResults(Arrays.asList(new Object[] { false })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnTrue() { actual.add(connection.eval("return true", ReturnType.BOOLEAN, 0)); verifyResults(Arrays.asList(new Object[] { true })); @@ -246,7 +246,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("unchecked") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayStrings() { actual.add(connection.eval("return {KEYS[1],ARGV[1]}", ReturnType.MULTI, 1, "foo", "bar")); List result = (List) getResults().get(0); @@ -255,14 +255,14 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayNumbers() { actual.add(connection.eval("return {1,2}", ReturnType.MULTI, 1, "foo", "bar")); verifyResults(Arrays.asList(new Object[] { Arrays.asList(new Object[] { 1l, 2l }) })); } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { // Syntax error connection.eval("return {1,2", ReturnType.MULTI, 1, "foo", "bar"); @@ -271,7 +271,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("unchecked") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { actual.add(connection.eval("return { redis.call('set','abc','ghk'), redis.call('set','abc','lfdf')}", ReturnType.MULTI, 0)); @@ -281,21 +281,21 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayFalses() { actual.add(connection.eval("return { false, false}", ReturnType.MULTI, 0)); verifyResults(Arrays.asList(new Object[] { Arrays.asList(new Object[] { null, null }) })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayTrues() { actual.add(connection.eval("return { true, true}", ReturnType.MULTI, 0)); verifyResults(Arrays.asList(new Object[] { Arrays.asList(new Object[] { 1l, 1l }) })); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptExists() { getResults(); String sha1 = connection.scriptLoad("return 'foo'"); @@ -334,7 +334,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptFlush() { getResults(); String sha1 = connection.scriptLoad("return KEYS[1]"); @@ -429,7 +429,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitCount() { String key = "bitset-test"; actual.add(connection.setBit(key, 0, false)); @@ -440,7 +440,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitCountInterval() { connection.set("mykey", "foobar"); actual.add(connection.bitCount("mykey", 1, 1)); @@ -448,14 +448,14 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitCountNonExistentKey() { actual.add(connection.bitCount("mykey")); verifyResults(new ArrayList(Collections.singletonList(0l))); } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitOpAnd() { connection.set("key1", "foo"); connection.set("key2", "bar"); @@ -465,7 +465,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitOpOr() { connection.set("key1", "foo"); connection.set("key2", "ugh"); @@ -475,7 +475,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitOpXOr() { connection.set("key1", "abcd"); connection.set("key2", "efgh"); @@ -484,7 +484,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitOpNot() { connection.set("key1", "abcd"); actual.add(connection.bitOp(BitOperation.NOT, "key3", "key1")); @@ -492,7 +492,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testBitOpNotMultipleSources() { connection.set("key1", "abcd"); connection.set("key2", "efgh"); @@ -511,7 +511,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testInfoBySection() throws Exception { actual.add(connection.info("server")); List results = getResults(); @@ -907,7 +907,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPTtlNoExpire() { connection.set("whatup", "yo"); actual.add(connection.pTtl("whatup")); @@ -915,7 +915,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testPTtl() { connection.set("whatup", "yo"); actual.add(connection.pExpire("whatup", 9000l)); @@ -925,7 +925,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testDumpAndRestore() { connection.set("testing", "12"); actual.add(connection.dump("testing".getBytes())); @@ -939,14 +939,14 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testDumpNonExistentKey() { actual.add(connection.dump("fakey".getBytes())); verifyResults(Arrays.asList(new Object[] { null })); } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { // Use something other than dump-specific serialization connection.restore("testing".getBytes(), 0, "foo".getBytes()); @@ -954,7 +954,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test(expected = RedisSystemException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { connection.set("testing", "12"); actual.add(connection.dump("testing".getBytes())); @@ -965,7 +965,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreTtl() { connection.set("testing", "12"); actual.add(connection.dump("testing".getBytes())); @@ -1059,7 +1059,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testIncrByDouble() { connection.set("tdb", "4.5"); actual.add(connection.incrBy("tdb", 7.2)); @@ -1377,7 +1377,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("rawtypes") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCount() { actual.add(connection.sAdd("myset", "foo")); actual.add(connection.sAdd("myset", "bar")); @@ -1388,7 +1388,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("rawtypes") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountNegative() { actual.add(connection.sAdd("myset", "foo")); actual.add(connection.sRandMember("myset", -2)); @@ -1397,7 +1397,7 @@ public abstract class AbstractConnectionIntegrationTests { @SuppressWarnings("rawtypes") @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountKeyNotExists() { actual.add(connection.sRandMember("notexist", 2)); assertTrue(((Collection) getResults().get(0)).isEmpty()); @@ -1813,7 +1813,7 @@ public abstract class AbstractConnectionIntegrationTests { } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testHIncrByDouble() { actual.add(connection.hSet("test", "key", "2.9")); actual.add(connection.hIncrBy("test", "key", 3.5)); @@ -1920,7 +1920,7 @@ public abstract class AbstractConnectionIntegrationTests { * @see DATAREDIS-290 */ @Test - @IfProfileValue(name = "redisVersion", value = "2.8") + @IfProfileValue(name = "redisVersion", value = "2.8+") public void scanShouldReadEntireValueRange() { if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) { @@ -1954,7 +1954,7 @@ public abstract class AbstractConnectionIntegrationTests { * @see DATAREDIS-304 */ @Test - @IfProfileValue(name = "redisVersion", value = "2.8") + @IfProfileValue(name = "redisVersion", value = "2.8+") public void sScanShouldReadEntireValueRange() { if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) { diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionPipelineIntegrationTests.java index 8f2d8738d..661e7ca45 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionPipelineIntegrationTests.java @@ -71,37 +71,37 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends Abstrac } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionTransactionIntegrationTests.java index 6e7d419a7..3d7261203 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionTransactionIntegrationTests.java @@ -79,7 +79,7 @@ abstract public class AbstractConnectionTransactionIntegrationTests extends Abst } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptKill() { // Impossible to call script kill in a tx because you can't issue the // exec command while Redis is running a script diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractTransactionalTestBase.java b/src/test/java/org/springframework/data/redis/connection/AbstractTransactionalTestBase.java index 22f27c407..036eee9ae 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractTransactionalTestBase.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractTransactionalTestBase.java @@ -32,15 +32,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.test.annotation.Rollback; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @Transactional @TransactionConfiguration(transactionManager = "transactionManager") public abstract class AbstractTransactionalTestBase { diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java index 51b9f4b91..811cb4a32 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java @@ -42,9 +42,9 @@ import org.springframework.data.redis.connection.MessageListener; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import redis.clients.jedis.JedisPoolConfig; @@ -56,7 +56,7 @@ import redis.clients.jedis.JedisPoolConfig; * @author Thomas Darimont * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrationTests { @@ -127,37 +127,37 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { connection.eval("return redis.call('expire','foo')", ReturnType.BOOLEAN, 0); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { connection.evalSha("somefakesha", ReturnType.VALUE, 2, "key1", "key2"); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } @@ -331,7 +331,7 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati connection.set("redis", "supercalifragilisticexpialidocious"); assertThat( - (Iterable)connection.execute("MGET", "spring".getBytes(), "data".getBytes(), "redis".getBytes()), + (Iterable) connection.execute("MGET", "spring".getBytes(), "data".getBytes(), "redis".getBytes()), AllOf.allOf(IsInstanceOf.instanceOf(List.class), IsCollectionContaining.hasItems("awesome".getBytes(), "cool".getBytes(), "supercalifragilisticexpialidocious".getBytes()))); } diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java index 807b0270f..e3d63f0f1 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java @@ -28,9 +28,9 @@ import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests; import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import redis.clients.jedis.JedisPoolConfig; @@ -40,7 +40,7 @@ import redis.clients.jedis.JedisPoolConfig; * @author Jennifer Hickey * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("JedisConnectionIntegrationTests-context.xml") public class JedisConnectionPipelineIntegrationTests extends AbstractConnectionPipelineIntegrationTests { @@ -123,121 +123,121 @@ public class JedisConnectionPipelineIntegrationTests extends AbstractConnectionP // Unsupported Ops @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptLoadEvalSha() { super.testScriptLoadEvalSha(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayStrings() { super.testEvalShaArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnString() { super.testEvalReturnString(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnNumber() { super.testEvalReturnNumber(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleOK() { super.testEvalReturnSingleOK(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnFalse() { super.testEvalReturnFalse(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnTrue() { super.testEvalReturnTrue(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayStrings() { super.testEvalReturnArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayNumbers() { super.testEvalReturnArrayNumbers(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { super.testEvalReturnArrayOKs(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayFalses() { super.testEvalReturnArrayFalses(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayTrues() { super.testEvalReturnArrayTrues(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptExists() { super.testScriptExists(); } - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") @Test(expected = UnsupportedOperationException.class) public void testScriptKill() throws Exception { connection.scriptKill(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptFlush() { connection.scriptFlush(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testInfoBySection() throws Exception { super.testInfoBySection(); } diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java index 3435fdd9b..d6c582bc7 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java @@ -42,13 +42,13 @@ public class JedisConnectionPipelineTxIntegrationTests extends JedisConnectionTr } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java index 0501fd898..7a92af62d 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java @@ -21,9 +21,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link JedisConnection} transaction functionality. @@ -33,7 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * * @author Jennifer Hickey */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("JedisConnectionIntegrationTests-context.xml") public class JedisConnectionTransactionIntegrationTests extends AbstractConnectionTransactionIntegrationTests { @@ -56,121 +56,121 @@ public class JedisConnectionTransactionIntegrationTests extends AbstractConnecti // Unsupported Ops @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptLoadEvalSha() { super.testScriptLoadEvalSha(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayStrings() { super.testEvalShaArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnString() { super.testEvalReturnString(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnNumber() { super.testEvalReturnNumber(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleOK() { super.testEvalReturnSingleOK(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnFalse() { super.testEvalReturnFalse(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnTrue() { super.testEvalReturnTrue(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayStrings() { super.testEvalReturnArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayNumbers() { super.testEvalReturnArrayNumbers(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { super.testEvalReturnArrayOKs(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayFalses() { super.testEvalReturnArrayFalses(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayTrues() { super.testEvalReturnArrayTrues(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptExists() { super.testScriptExists(); } - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") @Test(expected = UnsupportedOperationException.class) public void testScriptKill() { connection.scriptKill(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptFlush() { connection.scriptFlush(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testInfoBySection() throws Exception { super.testInfoBySection(); } @@ -181,13 +181,13 @@ public class JedisConnectionTransactionIntegrationTests extends AbstractConnecti } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = InvalidDataAccessApiUsageException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } diff --git a/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java index 4aa7f1a8c..c43cc472f 100644 --- a/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jredis/JRedisConnectionIntegrationTests.java @@ -24,8 +24,8 @@ import java.util.HashSet; import java.util.List; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; -import org.hamcrest.core.IsInstanceOf; import org.hamcrest.core.IsCollectionContaining; +import org.hamcrest.core.IsInstanceOf; import org.jredis.JRedis; import org.jredis.protocol.BulkResponse; import org.jredis.ri.alphazero.protocol.SyncProtocol.SyncMultiBulkResponse; @@ -42,9 +42,9 @@ import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.SortParameters.Order; import org.springframework.data.redis.connection.StringRedisConnection; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link JredisConnection} @@ -53,7 +53,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Jennifer Hickey * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrationTests { @@ -425,103 +425,103 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptLoadEvalSha() { super.testScriptLoadEvalSha(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayStrings() { super.testEvalShaArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnString() { super.testEvalReturnString(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnNumber() { super.testEvalReturnNumber(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleOK() { super.testEvalReturnSingleOK(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnFalse() { super.testEvalReturnFalse(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnTrue() { super.testEvalReturnTrue(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayStrings() { super.testEvalReturnArrayStrings(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayNumbers() { super.testEvalReturnArrayNumbers(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { super.testEvalReturnArrayOKs(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayFalses() { super.testEvalReturnArrayFalses(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayTrues() { super.testEvalReturnArrayTrues(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptExists() { super.testScriptExists(); } @@ -532,31 +532,31 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testScriptFlush() { connection.scriptFlush(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCount() { super.testSRandMemberCount(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountKeyNotExists() { super.testSRandMemberCountKeyNotExists(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountNegative() { super.testSRandMemberCountNegative(); } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testInfoBySection() throws Exception { super.testInfoBySection(); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java index 729014cee..a7cdc98cc 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionIntegrationTests.java @@ -39,9 +39,9 @@ import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.StringRedisConnection; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.lambdaworks.redis.RedisAsyncConnection; @@ -53,7 +53,7 @@ import com.lambdaworks.redis.RedisAsyncConnection; * @author Thomas Darimont * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegrationTests { @@ -223,7 +223,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountNegative() { super.testSRandMemberCountNegative(); } @@ -293,7 +293,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra connection.set("redis", "supercalifragilisticexpialidocious"); assertThat( - (Iterable)connection.execute("MGET", "spring".getBytes(), "data".getBytes(), "redis".getBytes()), + (Iterable) connection.execute("MGET", "spring".getBytes(), "data".getBytes(), "redis".getBytes()), AllOf.allOf(IsInstanceOf.instanceOf(List.class), IsCollectionContaining.hasItems("awesome".getBytes(), "cool".getBytes(), "supercalifragilisticexpialidocious".getBytes()))); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineIntegrationTests.java index db102aa3c..51a50cd86 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineIntegrationTests.java @@ -32,9 +32,9 @@ import org.springframework.data.redis.connection.AbstractConnectionPipelineInteg import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.StringRedisConnection; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link LettuceConnection} pipeline functionality @@ -43,7 +43,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Darimont * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("LettuceConnectionIntegrationTests-context.xml") public class LettuceConnectionPipelineIntegrationTests extends AbstractConnectionPipelineIntegrationTests { @@ -53,7 +53,7 @@ public class LettuceConnectionPipelineIntegrationTests extends AbstractConnectio } @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountNegative() { super.testSRandMemberCountNegative(); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineTxIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineTxIntegrationTests.java index 67d9b2e63..b1ef498fa 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineTxIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionPipelineTxIntegrationTests.java @@ -32,37 +32,37 @@ import org.springframework.test.annotation.IfProfileValue; public class LettuceConnectionPipelineTxIntegrationTests extends LettuceConnectionTransactionIntegrationTests { @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java index e269d6006..d0592c334 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java @@ -24,9 +24,9 @@ import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests; import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.data.redis.connection.StringRedisConnection; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link LettuceConnection} functionality within a transaction @@ -35,12 +35,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Darimont * @author Christoph Strobl */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("LettuceConnectionIntegrationTests-context.xml") public class LettuceConnectionTransactionIntegrationTests extends AbstractConnectionTransactionIntegrationTests { @Test(expected = UnsupportedOperationException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testSRandMemberCountNegative() { super.testSRandMemberCountNegative(); } diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java index 0d6502643..18f462981 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java @@ -26,9 +26,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests; import org.springframework.data.redis.connection.ReturnType; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import redis.reply.Reply; @@ -38,7 +38,7 @@ import redis.reply.Reply; * @author Costin Leau * @author Jennifer Hickey */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration public class SrpConnectionIntegrationTests extends AbstractConnectionIntegrationTests { @@ -73,7 +73,7 @@ public class SrpConnectionIntegrationTests extends AbstractConnectionIntegration } @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { // SRP returns the Strings from individual StatusReplys in a MultiBulkReply, while other clients return as byte[] actual.add(connection.eval("return { redis.call('set','abc','ghk'), redis.call('set','abc','lfdf')}", diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java index 4ebba822b..040d4ca22 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java @@ -22,21 +22,21 @@ import org.junit.runner.RunWith; import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests; import org.springframework.data.redis.connection.ReturnType; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link SrpConnection} pipeline functionality * * @author Jennifer Hickey */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("SrpConnectionIntegrationTests-context.xml") public class SrpConnectionPipelineIntegrationTests extends AbstractConnectionPipelineIntegrationTests { @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { // SRP returns the Strings from individual StatusReplys in a // MultiBulkReply, while other clients return as byte[] diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java index 514e150e9..ac42cb6ac 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java @@ -59,37 +59,37 @@ public class SrpConnectionPipelineTxIntegrationTests extends SrpConnectionTransa } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaNotFound() { super.testEvalShaNotFound(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnSingleError() { super.testEvalReturnSingleError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreExistingKey() { super.testRestoreExistingKey(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testRestoreBadData() { super.testRestoreBadData(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalArrayScriptError() { super.testEvalArrayScriptError(); } @Test(expected = RedisPipelineException.class) - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalShaArrayError() { super.testEvalShaArrayError(); } diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java index bf9d5dd5a..d9297934f 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java @@ -21,21 +21,21 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests; import org.springframework.data.redis.connection.ReturnType; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Integration test of {@link SrpConnection} functionality within a transaction * * @author Jennifer Hickey */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration("SrpConnectionIntegrationTests-context.xml") public class SrpConnectionTransactionIntegrationTests extends AbstractConnectionTransactionIntegrationTests { @Test - @IfProfileValue(name = "redisVersion", value = "2.6") + @IfProfileValue(name = "redisVersion", value = "2.6+") public void testEvalReturnArrayOKs() { // SRP returns the Strings from individual StatusReplys in a MultiBulkReply, while other clients return as byte[] actual.add(connection.eval("return { redis.call('set','abc','ghk'), redis.call('set','abc','lfdf')}", diff --git a/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsTests.java b/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsTests.java index ee708a008..058f4b70a 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsTests.java @@ -30,6 +30,7 @@ import java.util.Set; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -38,6 +39,8 @@ import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.RedisTestProfileValueSource; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.data.redis.test.util.MinimumRedisVersionRule; +import org.springframework.test.annotation.IfProfileValue; /** * Integration test of {@link DefaultSetOperations} @@ -56,6 +59,8 @@ public class DefaultSetOperationsTests { private SetOperations setOps; + public @Rule MinimumRedisVersionRule versionRule = new MinimumRedisVersionRule(); + public DefaultSetOperationsTests(RedisTemplate redisTemplate, ObjectFactory keyFactory, ObjectFactory valueFactory) { this.redisTemplate = redisTemplate; @@ -200,6 +205,7 @@ public class DefaultSetOperationsTests { */ @Test @SuppressWarnings("unchecked") + @IfProfileValue(name = "redisVersion", value = "2.8+") public void testSSCanReadsValuesFully() { // TODO: remove this when upgrading to jedis v.2.4.3 as this guard to avoids key serialization diff --git a/src/test/java/org/springframework/data/redis/core/script/DefaultScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/DefaultScriptExecutorTests.java index 7ee76c8c7..2a84e5e6a 100644 --- a/src/test/java/org/springframework/data/redis/core/script/DefaultScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/DefaultScriptExecutorTests.java @@ -15,10 +15,7 @@ */ package org.springframework.data.redis.core.script; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.Arrays; import java.util.Collections; @@ -42,21 +39,21 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.data.redis.test.util.RelaxedJUnit4ClassRunner; import org.springframework.scripting.support.StaticScriptSource; 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; /** * Integration test of {@link DefaultScriptExecutor} * * @author Jennifer Hickey */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(RelaxedJUnit4ClassRunner.class) @ContextConfiguration @ProfileValueSourceConfiguration(RedisTestProfileValueSource.class) -@IfProfileValue(name = "redisVersion", value = "2.6") +@IfProfileValue(name = "redisVersion", value = "2.6+") public class DefaultScriptExecutorTests { @Autowired private RedisConnectionFactory connFactory; diff --git a/src/test/java/org/springframework/data/redis/test/util/MinimumRedisVersionRule.java b/src/test/java/org/springframework/data/redis/test/util/MinimumRedisVersionRule.java new file mode 100644 index 000000000..74181e0bc --- /dev/null +++ b/src/test/java/org/springframework/data/redis/test/util/MinimumRedisVersionRule.java @@ -0,0 +1,104 @@ +/* + * Copyright 2014 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.redis.test.util; + +import org.junit.internal.AssumptionViolatedException; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.springframework.data.redis.RedisVersionUtils; +import org.springframework.data.redis.SettingsUtils; +import org.springframework.data.redis.Version; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.util.StringUtils; + +/** + * {@link MinimumRedisVersionRule} is a custom {@link TestRule} validating {@literal redisVersion} given in + * {@link IfProfileValue} against used redis server version. + * + * @author Christoph Strobl + * @since 1.4 + */ +public class MinimumRedisVersionRule implements TestRule { + + private static final String PROFILE_NAME = "redisVersion"; + private Version redisVersion; + + public MinimumRedisVersionRule() { + this.redisVersion = readServerVersion(); + } + + private Version readServerVersion() { + + JedisConnectionFactory connectionFactory = new JedisConnectionFactory(); + connectionFactory.setHostName(SettingsUtils.getHost()); + connectionFactory.setPort(SettingsUtils.getPort()); + + connectionFactory.afterPropertiesSet(); + RedisConnection connection = connectionFactory.getConnection(); + + Version version = Version.UNKNOWN; + + try { + version = RedisVersionUtils.getRedisVersion(connection); + connection.close(); + } finally { + connectionFactory.destroy(); + } + + return version; + } + + @Override + public Statement apply(final Statement base, Description description) { + + IfProfileValue profileValue = description.getAnnotation(IfProfileValue.class); + final String version = (profileValue != null && profileValue.name().equals(PROFILE_NAME)) ? profileValue.value() + : null; + + return new Statement() { + + @Override + public void evaluate() throws Throwable { + + verify(version); + base.evaluate(); + } + }; + } + + protected void verify(String version) throws Throwable { + + if (StringUtils.hasText(version)) { + + boolean sloppyMatch = version.endsWith("+"); + String cleanedVersionString = version.replace("+", ""); + Version expected = RedisVersionUtils.parseVersion(cleanedVersionString); + + if (sloppyMatch) { + if (redisVersion.compareTo(expected) < 0) { + throw new AssumptionViolatedException("Expected Redis version " + version + " but found " + redisVersion); + } + } else { + if (redisVersion.compareTo(expected) == 0) { + throw new AssumptionViolatedException("Expected Redis version " + version + " but found " + redisVersion); + } + } + } + } +} diff --git a/src/test/java/org/springframework/data/redis/test/util/RelaxedJUnit4ClassRunner.java b/src/test/java/org/springframework/data/redis/test/util/RelaxedJUnit4ClassRunner.java new file mode 100644 index 000000000..66d6efa89 --- /dev/null +++ b/src/test/java/org/springframework/data/redis/test/util/RelaxedJUnit4ClassRunner.java @@ -0,0 +1,100 @@ +/* + * Copyright 2014 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.redis.test.util; + +import java.lang.reflect.Method; + +import org.junit.Ignore; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.springframework.test.annotation.IfProfileValue; +import org.springframework.test.annotation.ProfileValueSource; +import org.springframework.test.annotation.ProfileValueUtils; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; + +/** + * Extends the {@link SpringJUnit4ClassRunner} to accept {@code +} as wildcard for values tweaking comparison a litte so + * that tests marked {@code IfProfileValue(name="varName" value="2.6+"} will be executed in + * {@code 2.6, 2.6.1, 2.8, 3.0,... } environments. + * + * @author Christoph Strobl + */ +public class RelaxedJUnit4ClassRunner extends SpringJUnit4ClassRunner { + + public RelaxedJUnit4ClassRunner(Class clazz) throws InitializationError { + super(clazz); + } + + @Override + protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { + + Method method = frameworkMethod.getMethod(); + + if (method.isAnnotationPresent(Ignore.class)) { + return true; + } + + IfProfileValue ifProfileValue = method.getAnnotation(IfProfileValue.class); + if (ifProfileValue == null) { + return false; + } + + String environmentValue = extractEnvironmentValue(ifProfileValue); + return !isValidEnvironmentValue(environmentValue, ifProfileValue); + } + + private boolean isValidEnvironmentValue(String environmentValue, IfProfileValue ifProfileValue) { + + for (String value : extractProfileValues(ifProfileValue)) { + + if (value.endsWith("+")) { + + String expected = value.replace("+", ""); + if (expected.compareTo(environmentValue) <= 0) { + return true; + } + + } else { + if (ObjectUtils.nullSafeEquals(value, environmentValue)) { + return true; + } + } + } + return false; + } + + private String extractEnvironmentValue(IfProfileValue ifProfileValue) { + ProfileValueSource profileValueSource = ProfileValueUtils.retrieveProfileValueSource(getTestClass().getJavaClass()); + + String environmentValue = profileValueSource.get(ifProfileValue.name()); + return environmentValue; + } + + private String[] extractProfileValues(IfProfileValue ifProfileValue) { + String[] annotatedValues = ifProfileValue.values(); + + if (StringUtils.hasLength(ifProfileValue.value())) { + if (annotatedValues.length > 0) { + throw new IllegalArgumentException("Setting both the 'value' and 'values' attributes " + + "of @IfProfileValue is not allowed: choose one or the other."); + } + annotatedValues = new String[] { ifProfileValue.value() }; + } + return annotatedValues; + } +}