Search in sources :

Example 1 with BatchedKeyValuePair

use of com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair in project rocketmq-externals by apache.

the class RedisEventHandlerTest method test.

@Test
public void test() {
    Config config = getConfig();
    RedisEventHandler handler = new DefaultRedisEventHandler(config);
    KVEntry entry = getBuilder();
    KVEntry res = null;
    Exception ex = null;
    try {
        res = handler.handleCommand(replId, offset, entry);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertEquals("c18cece63c7b16851a6f387f52dbbb9eee07e46f", res.getSourceId());
    Assert.assertTrue(res.getOffset() == 3926872L);
    Assert.assertNull(ex);
    AuxField auxField = new AuxField("a", "b");
    try {
        res = handler.handleOtherEvent(replId, offset, auxField);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
    BatchedKeyValuePair pair = new BatchedKeyStringValueString();
    pair.setKey("A".getBytes());
    pair.setValue("B".getBytes());
    try {
        res = handler.handleBatchKVString(replId, offset, pair);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
}
Also used : AuxField(com.moilioncircle.redis.replicator.rdb.datatype.AuxField) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) BatchedKeyValuePair(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) Test(org.junit.Test)

Aggregations

AuxField (com.moilioncircle.redis.replicator.rdb.datatype.AuxField)1 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)1 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)1 Config (org.apache.rocketmq.connect.redis.common.Config)1 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)1 RedisEventHandler (org.apache.rocketmq.connect.redis.handler.RedisEventHandler)1 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)1 Test (org.junit.Test)1