DATAREDIS-562 - Polishing.

Move BitfieldCommand to top-level type BitFieldSubCommands.
Use primitives in command objects. Add toString methods. Add utility methods to extract responses from Jedis Client. Use Connection.execute(…) to invoke BITFIELD using Jedis. Fix Overflow values to string rendering.
Convert test ticket references to new format.

Original pull request: #227.
This commit is contained in:
Mark Paluch
2018-05-03 11:34:21 +02:00
parent 41db6a10fe
commit 10f8553c5a
25 changed files with 912 additions and 1018 deletions

View File

@@ -24,12 +24,13 @@ import static org.hamcrest.number.IsCloseTo.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import static org.springframework.data.redis.SpinBarrier.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.*;
import static org.springframework.data.redis.connection.ClusterTestVariables.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldIncrBy.Overflow.FAIL;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldCommand.newBitfieldCommand;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldType.*;
import static org.springframework.data.redis.connection.RedisStringCommands.Offset.*;
import static org.springframework.data.redis.core.ScanOptions.*;
import java.time.Duration;
@@ -78,7 +79,6 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.data.redis.test.util.HexStringUtils;
import org.springframework.data.redis.test.util.RedisClientRule;
import org.springframework.data.redis.test.util.RedisDriver;
@@ -2907,110 +2907,83 @@ public abstract class AbstractConnectionIntegrationTests {
verifyResults(Arrays.asList(new Object[] { null }));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitFieldSetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(connection.bitfield(key, newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(10L)));
actual.add(connection.bitfield(key, newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(20L)));
actual.add(connection.bitfield(KEY_1, create().set(INT_8).valueAt(offset(0L)).to(10L)));
actual.add(connection.bitfield(KEY_1, create().set(INT_8).valueAt(offset(0L)).to(20L)));
List<Object> results = getResults();
assertThat((List<Long>) results.get(0), contains(0L));
assertThat((List<Long>) results.get(1), contains(10L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitFieldGetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(connection.bitfield(key, newBitfieldCommand().get(INT_8).valueAt(offset(0L))));
actual.add(connection.bitfield(KEY_1, create().get(INT_8).valueAt(offset(0L))));
List<Object> results = getResults();
assertThat((List<Long>) results.get(0), contains(0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitFieldIncrByShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(connection.bitfield(key, newBitfieldCommand().incr(INT_8).valueAt(offset(100L)).by(1L)));
actual.add(connection.bitfield(KEY_1, create().incr(INT_8).valueAt(offset(100L)).by(1L)));
List<Object> results = getResults();
assertThat((List<Long>) results.get(0), contains(1L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(
connection.bitfield(key, newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
connection.bitfield(KEY_1, create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
actual.add(
connection.bitfield(key, newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
connection.bitfield(KEY_1, create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
actual.add(
connection.bitfield(key, newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
connection.bitfield(KEY_1, create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
actual.add(
connection.bitfield(key, newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
connection.bitfield(KEY_1, create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)));
List<Object> results = getResults();
assertThat((List<Long>) results.get(0), contains(1L));
assertThat((List<Long>) results.get(1), contains(2L));
assertThat((List<Long>) results.get(2), contains(3L));
assertThat(((List<Long>) results.get(3)).get(0), is(nullValue()));
assertThat(results.get(3), is(notNullValue()));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitfieldShouldAllowMultipleSubcommands() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(connection.bitfield(key,
newBitfieldCommand().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)));
actual.add(
connection.bitfield(KEY_1,
create().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)));
assertThat((List<Long>) getResults().get(0), contains(1L, 0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
String key = "bitfield-" + UUID.randomUUID();
actual.add(connection.bitfield(key, newBitfieldCommand().set(INT_8).valueAt(offset(0L).multipliedByTypeLength()).to(100L).set(INT_8).valueAt(offset(1L).multipliedByTypeLength()).to(200L)));
actual.add(connection.bitfield(key, newBitfieldCommand().get(INT_8).valueAt(offset(0L).multipliedByTypeLength()).get(INT_8).valueAt(offset(1L).multipliedByTypeLength())));
actual.add(connection.bitfield(KEY_1, create().set(INT_8).valueAt(offset(0L).multipliedByTypeLength()).to(100L)
.set(INT_8).valueAt(offset(1L).multipliedByTypeLength()).to(200L)));
actual.add(connection.bitfield(KEY_1, create().get(INT_8).valueAt(offset(0L).multipliedByTypeLength()).get(INT_8)
.valueAt(offset(1L).multipliedByTypeLength())));
List<Object> results = getResults();
assertThat((List<Long>) results.get(0), contains(0L, 0L));

View File

@@ -983,8 +983,8 @@ public class RedisConnectionUnitTests {
}
@Override
public List<Long> bitfield(byte[] key, BitfieldCommand operation) {
return delegate.bitfield(key, operation);
public List<Long> bitField(byte[] key, BitFieldSubCommands subCommands) {
return delegate.bitField(key, subCommands);
}
}
}

View File

@@ -17,13 +17,13 @@ package org.springframework.data.redis.connection.jedis;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.*;
import static org.springframework.data.redis.connection.ClusterTestVariables.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldCommand.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldIncrBy.Overflow.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldType.*;
import static org.springframework.data.redis.connection.RedisStringCommands.Offset.*;
import static org.springframework.data.redis.core.ScanOptions.*;
import redis.clients.jedis.HostAndPort;
@@ -34,7 +34,6 @@ import java.io.IOException;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.*;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.After;
@@ -2339,96 +2338,73 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
assertThat(clusterConnection.keyCommands().refcount(KEY_3_BYTES), is(nullValue()));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldSetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(10L)), contains(0L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(20L)), contains(10L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L)).to(10L)), contains(0L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L)).to(20L)), contains(10L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldGetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().get(INT_8).valueAt(offset(0L))),
clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().get(INT_8).valueAt(offset(0L))),
contains(0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldIncrByShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(INT_8).valueAt(offset(100L)).by(1L)), contains(1L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(INT_8).valueAt(offset(100L)).by(1L)), contains(1L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(1L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(2L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(3L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(1L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(2L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(3L));
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)).get(0),
clusterConnection.stringCommands()
.bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L))
.get(0),
is(nullValue()));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitfieldShouldAllowMultipleSubcommands() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)),
clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)),
contains(1L, 0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().set(INT_8).valueAt(offset(0L).multipliedByTypeLength())
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L).multipliedByTypeLength())
.to(100L).set(INT_8).valueAt(offset(1L).multipliedByTypeLength()).to(200L)), contains(0L, 0L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().get(INT_8).valueAt(offset(0L).multipliedByTypeLength())
assertThat(
clusterConnection.stringCommands()
.bitField(JedisConverters.toBytes(KEY_1), create().get(INT_8)
.valueAt(offset(0L).multipliedByTypeLength())
.get(INT_8).valueAt(offset(1L).multipliedByTypeLength())), contains(100L, -56L));
}
}

View File

@@ -17,13 +17,13 @@ package org.springframework.data.redis.connection.lettuce;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType.*;
import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.*;
import static org.springframework.data.redis.connection.ClusterTestVariables.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldCommand.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldIncrBy.Overflow.*;
import static org.springframework.data.redis.connection.RedisStringCommands.BitfieldType.*;
import static org.springframework.data.redis.connection.RedisStringCommands.Offset.*;
import static org.springframework.data.redis.core.ScanOptions.*;
import io.lettuce.core.RedisURI.Builder;
@@ -35,13 +35,11 @@ import io.lettuce.core.codec.ByteArrayCodec;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.*;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.dao.DataAccessException;
@@ -2365,98 +2363,68 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
assertThat(clusterConnection.keyCommands().refcount(KEY_3_BYTES), is(nullValue()));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldSetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(10L)), contains(0L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().set(INT_8).valueAt(offset(0L)).to(20L)), contains(10L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L)).to(10L)), contains(0L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L)).to(20L)), contains(10L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldGetShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().get(INT_8).valueAt(offset(0L))),
contains(0L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().get(INT_8).valueAt(offset(0L))), contains(0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldIncrByShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(INT_8).valueAt(offset(100L)).by(1L)), contains(1L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(INT_8).valueAt(offset(100L)).by(1L)), contains(1L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(1L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(2L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(3L));
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)).get(0),
is(nullValue()));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(1L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(2L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), contains(3L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(unsigned(2)).valueAt(offset(102L)).overflow(FAIL).by(1L)), is(notNullValue()));
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitfieldShouldAllowMultipleSubcommands() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(
clusterConnection.bitfield(JedisConverters.toBytes(key),
newBitfieldCommand().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)),
clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().incr(signed(5)).valueAt(offset(100L)).by(1L).get(unsigned(4)).valueAt(0L)),
contains(1L, 0L));
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore
@Test // DATAREDIS-562
@IfProfileValue(name = "redisVersion", value = "3.2+")
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
String key = "bitfield-" + UUID.randomUUID();
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().set(INT_8).valueAt(offset(0L).multipliedByTypeLength())
.to(100L).set(INT_8).valueAt(offset(1L).multipliedByTypeLength()).to(200L)), contains(0L, 0L));
assertThat(clusterConnection.bitfield(JedisConverters.toBytes(key), newBitfieldCommand().get(INT_8).valueAt(offset(0L).multipliedByTypeLength())
.get(INT_8).valueAt(offset(1L).multipliedByTypeLength())), contains(100L, -56L));
assertThat(clusterConnection.stringCommands().bitField(JedisConverters.toBytes(KEY_1),
create().set(INT_8).valueAt(offset(0L).multipliedByTypeLength()).to(100L).set(INT_8)
.valueAt(offset(1L).multipliedByTypeLength()).to(200L)),
contains(0L, 0L));
assertThat(
clusterConnection.stringCommands()
.bitField(JedisConverters.toBytes(KEY_1), create().get(INT_8)
.valueAt(offset(0L).multipliedByTypeLength()).get(INT_8).valueAt(offset(1L).multipliedByTypeLength())),
contains(100L, -56L));
}
}

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection.lettuce;
import static org.hamcrest.CoreMatchers.*;
@@ -31,7 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsCollectionContaining;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -338,24 +336,4 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
new RedisSentinelConfiguration().master("mymaster").sentinel("127.0.0.1", 26379).sentinel("127.0.0.1", 26380));
assertThat(connection.getSentinelConnection(), notNullValue());
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
super.bitFieldIncrByWithOverflowShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
super.bitfieldShouldWorkUsingNonZeroBasedOffset();
}
}

View File

@@ -22,7 +22,6 @@ import static org.springframework.data.redis.SpinBarrier.*;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.dao.DataAccessException;
@@ -110,24 +109,4 @@ public class LettuceConnectionPipelineIntegrationTests extends AbstractConnectio
public void testListClientsContainsAtLeastOneElement() {
super.testListClientsContainsAtLeastOneElement();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
super.bitFieldIncrByWithOverflowShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
super.bitfieldShouldWorkUsingNonZeroBasedOffset();
}
}

View File

@@ -19,7 +19,6 @@ import static org.junit.Assert.*;
import java.util.Arrays;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests;
@@ -69,64 +68,4 @@ public class LettuceConnectionTransactionIntegrationTests extends AbstractConnec
public void testSelect() {
super.testSelect();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
super.bitFieldIncrByWithOverflowShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldGetShouldWorkCorrectly() {
super.bitFieldGetShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldIncrByShouldWorkCorrectly() {
super.bitFieldIncrByShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitFieldSetShouldWorkCorrectly() {
super.bitFieldSetShouldWorkCorrectly();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitfieldShouldAllowMultipleSubcommands() {
super.bitfieldShouldAllowMultipleSubcommands();
}
/**
* @see DATAREDIS-562
*/
@Test
@Ignore("Lettuce Bug")
@Override
public void bitfieldShouldWorkUsingNonZeroBasedOffset() {
super.bitfieldShouldWorkUsingNonZeroBasedOffset();
}
}

View File

@@ -23,9 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.data.redis.connection.BitFieldSubCommands;
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@@ -56,18 +57,13 @@ public class DefaultValueOperationsUnitTests<K, V> {
this.valueOps = template.opsForValue();
}
/**
* @see DATAREDIS-562
*/
@Test
@Test // DATAREDIS-562
public void bitfieldShouldBeDelegatedCorrectly() {
RedisStringCommands.BitfieldCommand command = RedisStringCommands.BitfieldCommand.newBitfieldCommand()
.get(RedisStringCommands.BitfieldType.INT_8).valueAt(0L);
BitFieldSubCommands command = BitFieldSubCommands.create().get(BitFieldType.INT_8).valueAt(0L);
valueOps.bitfield("key", command);
valueOps.bitField("key", command);
verify(connectionMock, times(1)).bitfield(eq(serializer.serialize("key")), eq(command));
verify(connectionMock, times(1)).bitField(eq(serializer.serialize("key")), eq(command));
}
}