use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler in project rocketmq-externals by apache.
the class ProcessorTest method getProcessor.
private RedisEventProcessor getProcessor(Config config) {
RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
RedisEventProcessor processor = new DefaultRedisEventProcessor(config);
processor.registEventHandler(eventHandler);
return processor;
}
use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler in project rocketmq-externals by apache.
the class ListenerTest method getExceptionProcessor.
private RedisEventProcessor getExceptionProcessor(Config config) {
RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
RedisEventProcessor processor = mock(DefaultRedisEventProcessor.class);
processor.registEventHandler(eventHandler);
try {
when(processor.commit(any())).thenThrow(new IllegalStateException("wrong number."));
} catch (Exception e) {
e.printStackTrace();
}
return processor;
}
use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler 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);
}
Aggregations