Search in sources :

Example 1 with RedisEventProcessor

use of org.apache.rocketmq.connect.redis.processor.RedisEventProcessor 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)

Example 2 with RedisEventProcessor

use of org.apache.rocketmq.connect.redis.processor.RedisEventProcessor 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);
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) EventListener(com.moilioncircle.redis.replicator.event.EventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) Test(org.junit.Test)

Example 3 with RedisEventProcessor

use of org.apache.rocketmq.connect.redis.processor.RedisEventProcessor in project rocketmq-externals by apache.

the class ListenerTest method getProcessor.

private RedisEventProcessor getProcessor() {
    Config config = getConfig();
    RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
    RedisEventProcessor processor = new DefaultRedisEventProcessor(config);
    processor.registEventHandler(eventHandler);
    return processor;
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) Config(org.apache.rocketmq.connect.redis.common.Config) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)

Example 4 with RedisEventProcessor

use of org.apache.rocketmq.connect.redis.processor.RedisEventProcessor 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);
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) EventListener(com.moilioncircle.redis.replicator.event.EventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) Test(org.junit.Test)

Example 5 with RedisEventProcessor

use of org.apache.rocketmq.connect.redis.processor.RedisEventProcessor in project rocketmq-externals by apache.

the class ListenerTest method getFailedProcessor.

private RedisEventProcessor getFailedProcessor(Config config) {
    RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
    RedisEventProcessor processor = mock(DefaultRedisEventProcessor.class);
    processor.registEventHandler(eventHandler);
    try {
        when(processor.commit(any())).thenReturn(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return processor;
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) IOException(java.io.IOException)

Aggregations

DefaultRedisEventProcessor (org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)8 RedisEventProcessor (org.apache.rocketmq.connect.redis.processor.RedisEventProcessor)8 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)4 RedisEventHandler (org.apache.rocketmq.connect.redis.handler.RedisEventHandler)4 Test (org.junit.Test)4 Config (org.apache.rocketmq.connect.redis.common.Config)3 EventListener (com.moilioncircle.redis.replicator.event.EventListener)2 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)2 KeyValuePair (com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair)2 IOException (java.io.IOException)2 RedisEventListener (org.apache.rocketmq.connect.redis.processor.RedisEventListener)2 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)2 RedisSourceTask (org.apache.rocketmq.connect.redis.connector.RedisSourceTask)1