use of org.apache.rocketmq.connect.redis.connector.RedisSourceTask in project rocketmq-externals by apache.
the class RedisSourceTaskTest method initAndStartTask.
@Before
public void initAndStartTask() {
try {
initKeyValue();
this.task = new RedisSourceTask();
this.task.initialize(new SourceTaskContext() {
@Override
public PositionStorageReader positionStorageReader() {
return new PositionStorageReader() {
@Override
public ByteBuffer getPosition(ByteBuffer byteBuffer) {
return null;
}
@Override
public Map<ByteBuffer, ByteBuffer> getPositions(Collection<ByteBuffer> collection) {
return null;
}
};
}
@Override
public KeyValue configs() {
return keyValue;
}
});
this.task.start(this.keyValue);
} catch (JedisConnectionException e) {
}
}
use of org.apache.rocketmq.connect.redis.connector.RedisSourceTask in project rocketmq-externals by apache.
the class RedisSourceTaskTest method testException.
@Test
public void testException() {
RedisEventProcessor processor = mock(DefaultRedisEventProcessor.class);
try {
when(processor.poll()).thenThrow(new InterruptedException());
} catch (Exception e) {
e.printStackTrace();
}
RedisSourceTask redisSourceTask = new RedisSourceTask();
redisSourceTask.setEventProcessor(processor);
redisSourceTask.poll();
RedisEventProcessor processor2 = mock(DefaultRedisEventProcessor.class);
try {
when(processor2.poll()).thenThrow(new Exception());
} catch (Exception e) {
e.printStackTrace();
}
RedisSourceTask redisSourceTask2 = new RedisSourceTask();
redisSourceTask2.setEventProcessor(processor2);
redisSourceTask2.poll();
}
Aggregations