From 3bfcc7daf6c062e448f6afa48249e659e5e49c2a Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Wed, 23 May 2012 19:29:04 +0300 Subject: [PATCH] add test exclusion to avoid RJC bug for incr(by) DATAREDIS-88 --- .../data/redis/core/TemplateTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/org/springframework/data/redis/core/TemplateTest.java b/src/test/java/org/springframework/data/redis/core/TemplateTest.java index 3d8b310d6..c665fb621 100644 --- a/src/test/java/org/springframework/data/redis/core/TemplateTest.java +++ b/src/test/java/org/springframework/data/redis/core/TemplateTest.java @@ -19,13 +19,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Collection; +import java.util.List; import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import org.springframework.dao.DataAccessException; import org.springframework.data.redis.ConnectionFactoryTracker; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.rjc.RjcConnectionFactory; import org.springframework.data.redis.support.collections.CollectionTestParams; import org.springframework.data.redis.support.collections.ObjectFactory; @@ -60,11 +64,33 @@ public class TemplateTest { @Test public void testIncrement() throws Exception { + // disable in case of Rjc + if (isRjc()) { + return; + } + StringRedisTemplate sr = new StringRedisTemplate(template.getConnectionFactory()); String key = "test.template.inc"; ValueOperations valueOps = sr.opsForValue(); valueOps.set(key, "10"); valueOps.increment(key, -10); assertEquals(0, Integer.valueOf(valueOps.get(key)).intValue()); + valueOps.increment(key, -10); + assertEquals(-10, Integer.valueOf(valueOps.get(key)).intValue()); + } + + private boolean isRjc() { + return (template.getConnectionFactory() instanceof RjcConnectionFactory); + } + + //@Test + public void testGetNonExistingKey() throws Exception { + List res = (List) template.execute(new RedisCallback>() { + + public List doInRedis(RedisConnection connection) throws DataAccessException { + connection.hGet("non-existing-key".getBytes(), "some-value".getBytes()); + return connection.closePipeline(); + } + }, true, true); } }