Search in sources :

Example 1 with RedisSourceTask

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) {
    }
}
Also used : KeyValue(io.openmessaging.KeyValue) DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) SourceTaskContext(io.openmessaging.connector.api.source.SourceTaskContext) PositionStorageReader(io.openmessaging.connector.api.PositionStorageReader) RedisSourceTask(org.apache.rocketmq.connect.redis.connector.RedisSourceTask) ByteBuffer(java.nio.ByteBuffer) Map(java.util.Map) JedisConnectionException(redis.clients.jedis.exceptions.JedisConnectionException) Before(org.junit.Before)

Example 2 with RedisSourceTask

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();
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) RedisSourceTask(org.apache.rocketmq.connect.redis.connector.RedisSourceTask) JedisConnectionException(redis.clients.jedis.exceptions.JedisConnectionException) Test(org.junit.Test)

Aggregations

RedisSourceTask (org.apache.rocketmq.connect.redis.connector.RedisSourceTask)2 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)2 KeyValue (io.openmessaging.KeyValue)1 PositionStorageReader (io.openmessaging.connector.api.PositionStorageReader)1 SourceTaskContext (io.openmessaging.connector.api.source.SourceTaskContext)1 DefaultKeyValue (io.openmessaging.internal.DefaultKeyValue)1 ByteBuffer (java.nio.ByteBuffer)1 Map (java.util.Map)1 DefaultRedisEventProcessor (org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)1 RedisEventProcessor (org.apache.rocketmq.connect.redis.processor.RedisEventProcessor)1 Before (org.junit.Before)1 Test (org.junit.Test)1