Search in sources :

Example 76 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testDelParser.

@Test
public void testDelParser() {
    String command = "del k1 k2 k3";
    KVEntry builder = new DelParser().parse(parseCommand(command));
    Assert.assertEquals("del", builder.getCommand());
    Assert.assertEquals("k1", builder.getKey());
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(3, res.size());
    Assert.assertEquals("k1", res.get(0));
    Assert.assertEquals("k2", res.get(1));
    Assert.assertEquals("k3", res.get(2));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) List(java.util.List) XDelParser(org.apache.rocketmq.connect.redis.parser.XDelParser) HDelParser(org.apache.rocketmq.connect.redis.parser.HDelParser) DelParser(org.apache.rocketmq.connect.redis.parser.DelParser) Test(org.junit.Test)

Example 77 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testDecrParser.

@Test
public void testDecrParser() {
    String command = "DECR key";
    KVEntry builder = new DecrParser().parse(parseCommand(command));
    Assert.assertEquals("DECR", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) DecrParser(org.apache.rocketmq.connect.redis.parser.DecrParser) Test(org.junit.Test)

Example 78 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testPfCountParser.

@Test
public void testPfCountParser() {
    String command = "PFCOUNT k1 k2";
    KVEntry builder = new PfCountParser().parse(parseCommand(command));
    Assert.assertEquals("PFCOUNT", builder.getCommand());
    Assert.assertEquals("k1", builder.getKey());
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("k1", res.get(0));
    Assert.assertEquals("k2", res.get(1));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) List(java.util.List) PfCountParser(org.apache.rocketmq.connect.redis.parser.PfCountParser) Test(org.junit.Test)

Example 79 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ProcessorTest method test.

@Test
public void test() {
    processor = getProcessor();
    RedisEvent event = getRedisEvent();
    Exception ex = null;
    try {
        processor.commit(event);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(ex);
    try {
        KVEntry entry = processor.poll();
        Assert.assertEquals("key", entry.getKey());
        Assert.assertEquals("value", entry.getValue());
        Assert.assertEquals("c18cece63c7b16851a6f387f52dbbb9eee07e46f", entry.getSourceId());
    } catch (InterruptedException e) {
        e.printStackTrace();
        ex = e;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Assert.assertNull(ex);
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) RedisEvent(org.apache.rocketmq.connect.redis.pojo.RedisEvent) IOException(java.io.IOException) JedisConnectionException(redis.clients.jedis.exceptions.JedisConnectionException) Test(org.junit.Test)

Example 80 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testSetExParser.

@Test
public void testSetExParser() {
    String command = "setex key 100 value";
    KVEntry builder = new SetExParser().parse(parseCommand(command));
    Assert.assertEquals("setex", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals("value", builder.getValue());
    Assert.assertTrue(100 == builder.getParam(Options.REDIS_EX));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) PSetExParser(org.apache.rocketmq.connect.redis.parser.PSetExParser) SetExParser(org.apache.rocketmq.connect.redis.parser.SetExParser) Test(org.junit.Test)

Aggregations

KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)118 Test (org.junit.Test)114 List (java.util.List)34 Map (java.util.Map)20 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)13 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)12 HashMap (java.util.HashMap)8 KeyStringValueList (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 HSetParser (org.apache.rocketmq.connect.redis.parser.HSetParser)5 HmSetParser (org.apache.rocketmq.connect.redis.parser.HmSetParser)5 LSetParser (org.apache.rocketmq.connect.redis.parser.LSetParser)5 MSetParser (org.apache.rocketmq.connect.redis.parser.MSetParser)5 ZSetEntry (com.moilioncircle.redis.replicator.rdb.datatype.ZSetEntry)3 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)3 SourceDataEntry (io.openmessaging.connector.api.data.SourceDataEntry)3 IOException (java.io.IOException)3 Config (org.apache.rocketmq.connect.redis.common.Config)3 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)3