use of org.apache.rocketmq.connect.redis.pojo.KVEntry 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);
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testSet.
@Test
public void testSet() {
KVEntry builder = handlerTest(RDB_TYPE_SET, () -> {
Set<byte[]> values = new HashSet<>();
values.add("myValue".getBytes());
values.add("myValue2".getBytes());
return values;
});
List<String> va = (List<String>) builder.getValue();
Assert.assertNotNull(va);
Assert.assertEquals(2, va.size());
Assert.assertTrue(va.contains("myValue"));
Assert.assertTrue(va.contains("myValue2"));
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testModule2.
@Test
public void testModule2() {
KVEntry builder = handlerTest(RDB_TYPE_MODULE_2, () -> {
Module module = new Module() {
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public String toString() {
return super.toString();
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
};
return module;
});
Module va = (Module) builder.getValue();
Assert.assertNotNull(va);
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testSetIntSet.
@Test
public void testSetIntSet() {
KVEntry builder = handlerTest(RDB_TYPE_SET_INTSET, () -> {
Set<byte[]> values = new HashSet<>();
values.add("v1".getBytes());
values.add("v2".getBytes());
return values;
});
List<String> va = (List<String>) builder.getValue();
Assert.assertNotNull(va);
Assert.assertEquals(2, va.size());
Assert.assertTrue(va.contains("v1"));
Assert.assertTrue(va.contains("v2"));
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testKeyValuePair.
@Test
public void testKeyValuePair() {
KVEntry kvEntry = handlerTest(RDB_TYPE_STRING, () -> "value".getBytes());
Assert.assertEquals(replId, kvEntry.getSourceId());
Assert.assertTrue(kvEntry.getOffset() == 3926872L);
Assert.assertEquals("key", kvEntry.getKey());
Assert.assertEquals("value", kvEntry.getValue());
}
Aggregations