Merge branch 'DATAREDIS-117' of github.com:porcelijn/spring-data-redis into porcelijn-DATAREDIS-117
Conflicts: src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java
This commit is contained in:
@@ -76,7 +76,6 @@ public class RedisCacheTest extends AbstractNativeCacheTest<RedisTemplate> {
|
||||
public void setUp() throws Exception {
|
||||
ConnectionFactoryTracker.add(template.getConnectionFactory());
|
||||
super.setUp();
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -161,4 +160,4 @@ public class RedisCacheTest extends AbstractNativeCacheTest<RedisTemplate> {
|
||||
assertNotNull(cache);
|
||||
assertTrue(redisCM.getCacheNames().contains(cacheName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
try {
|
||||
connection.decr((String) null);
|
||||
} catch (Exception ex) {
|
||||
// excepted
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
@@ -38,4 +40,30 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
protected RedisConnectionFactory getConnectionFactory() {
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncrDecrBy() {
|
||||
String key = "test.count";
|
||||
long largeNumber = 0x123456789L; // > 32bits
|
||||
connection.set(key.getBytes(), "0".getBytes());
|
||||
connection.incrBy(key.getBytes(), largeNumber);
|
||||
assertEquals(largeNumber, Long.valueOf(new String(connection.get(key.getBytes()))).longValue());
|
||||
connection.decrBy(key.getBytes(), largeNumber);
|
||||
assertEquals(0, Long.valueOf(new String(connection.get(key.getBytes()))).longValue());
|
||||
connection.decrBy(key.getBytes(), 2*largeNumber);
|
||||
assertEquals(-2*largeNumber, Long.valueOf(new String(connection.get(key.getBytes()))).longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashIncrDecrBy() {
|
||||
byte[] key = "test.hcount".getBytes();
|
||||
byte[] hkey = "hashkey".getBytes();
|
||||
|
||||
long largeNumber = 0x123456789L; // > 32bits
|
||||
connection.hSet(key, hkey, "0".getBytes());
|
||||
connection.hIncrBy(key, hkey, largeNumber);
|
||||
assertEquals(largeNumber, Long.valueOf(new String(connection.hGet(key, hkey))).longValue());
|
||||
connection.hIncrBy(key, hkey, -2*largeNumber);
|
||||
assertEquals(-largeNumber, Long.valueOf(new String(connection.hGet(key, hkey))).longValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user