use of com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testNull.
@Test
public void testNull() {
Config config = getConfig();
RedisEventHandler handler = new DefaultRedisEventHandler(config);
KVEntry res = null;
Exception ex = null;
// 测试increment下的rdb数据处理
config.setSyncMod(SyncMod.LAST_OFFSET.name());
KeyValuePair keyValuePair = new KeyStringValueString();
keyValuePair.setKey("key".getBytes());
keyValuePair.setValue("value".getBytes());
try {
res = handler.handleKVString(replId, offset, keyValuePair);
} catch (Exception e) {
e.printStackTrace();
ex = e;
}
Assert.assertNull(res);
Assert.assertNull(ex);
// 测试未指定的command
GetSetCommand command = new GetSetCommand();
command.setKey("key".getBytes());
command.setValue("value".getBytes());
try {
res = handler.handleCommand(replId, offset, command);
} catch (Exception e) {
ex = e;
}
Assert.assertNull(res);
Assert.assertNull(ex);
}
use of com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString in project rocketmq-externals by apache.
the class ListenerTest method exceptionListenerTest.
@Test
public void exceptionListenerTest() {
ExceptionListener exceptionListener = new RedisExceptionListener(processor);
KeyValuePair pair = new KeyStringValueString();
exceptionListener.handle(null, new NullPointerException("adsf"), pair);
}
use of com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString in project rocketmq-externals by apache.
the class ListenerTest method testEventListenerRetry2.
@Test
public void testEventListenerRetry2() {
Config config = getConfig();
RedisEventProcessor processor = getExceptionProcessor(config);
EventListener eventListener = new RedisEventListener(config, processor);
KeyValuePair pair = new KeyStringValueString();
eventListener.onEvent(null, pair);
}
use of com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString in project rocketmq-externals by apache.
the class ListenerTest method testEventListenerRetry1.
@Test
public void testEventListenerRetry1() {
Config config = getConfig();
RedisEventProcessor processor = getFailedProcessor(config);
EventListener eventListener = new RedisEventListener(config, processor);
KeyValuePair pair = new KeyStringValueString();
eventListener.onEvent(null, pair);
}
use of com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString in project rocketmq-externals by apache.
the class RedisEventTest method test.
@Test
public void test() {
RedisEvent redisEvent = new RedisEvent();
redisEvent.setEvent(getKeyValuePair());
redisEvent.setReplOffset(3926872L);
redisEvent.setReplId("c18cece63c7b16851a6f387f52dbbb9eee07e46f");
redisEvent.setStreamDB(0);
Assert.assertEquals("c18cece63c7b16851a6f387f52dbbb9eee07e46f", redisEvent.getReplId());
Assert.assertTrue(3926872L == redisEvent.getReplOffset());
Assert.assertTrue(0 == redisEvent.getStreamDB());
Assert.assertNotNull(redisEvent.getEvent());
Assert.assertEquals(KeyStringValueString.class, redisEvent.getEvent().getClass());
Assert.assertEquals("key", new String(((KeyStringValueString) redisEvent.getEvent()).getKey()));
Assert.assertEquals("value", new String(((KeyStringValueString) redisEvent.getEvent()).getValue()));
}
Aggregations