use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.
the class KafkaSourceConnectorTest method taskConfigsTest.
@Test
public void taskConfigsTest() {
assertEquals(connector.taskConfigs().size(), 0);
KeyValue keyValue = new DefaultKeyValue();
for (String requestKey : ConfigDefine.REQUEST_CONFIG) {
keyValue.put(requestKey, requestKey);
}
keyValue.put(ConfigDefine.TASK_NUM, 1);
connector.verifyAndSetConfig(keyValue);
assertEquals(connector.taskConfigs().get(0).getString(ConfigDefine.TOPICS), keyValue.getString(ConfigDefine.TOPICS));
}
use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.
the class ConfigTest method test.
@Test
public void test() {
Config config = new Config();
config.setRedisAddr("127.0.0.1");
config.setRedisPort(6379);
config.setRedisPassword("123456");
config.setTimeout(500);
config.setSyncMod(SyncMod.CUSTOM_OFFSET.name());
config.setOffset(65535L);
config.setReplId("c18cece63c7b16851a6f387f52dbbb9eee07e46f");
config.setCommands("SET,GET");
config.setPosition(3926872L);
config.setEventCommitRetryInterval(1000L);
config.setEventCommitRetryTimes(10);
Assert.assertEquals("127.0.0.1", config.getRedisAddr());
Assert.assertEquals(6379, (int) config.getRedisPort());
Assert.assertEquals("123456", config.getRedisPassword());
Assert.assertEquals(500, (int) config.getTimeout());
Assert.assertEquals(SyncMod.CUSTOM_OFFSET, config.getSyncMod());
Assert.assertEquals(65535L, (long) config.getOffset());
Assert.assertEquals("c18cece63c7b16851a6f387f52dbbb9eee07e46f", config.getReplId());
Assert.assertEquals("SET,GET", config.getCommands());
Assert.assertEquals(3926872L, (long) config.getPosition());
Assert.assertEquals(1000L, (long) config.getEventCommitRetryInterval());
RedisURI redisURI = config.getRedisUri();
Assert.assertNotNull(redisURI);
ByteBuffer byteBuffer = config.getPositionPartitionKey();
Assert.assertNotNull(byteBuffer);
Set<String> set = Config.getRequestConfig();
Assert.assertNotNull(set);
KeyValue keyValue = new DefaultKeyValue();
keyValue.put("a", "B");
String bo = Config.checkConfig(keyValue);
Assert.assertNotNull(bo);
keyValue.put("redisAddr", "127.0.0.1");
keyValue.put("redisPort", "6379");
bo = Config.checkConfig(keyValue);
Assert.assertNotNull(bo);
keyValue.put("redisPassword", "1234567");
bo = Config.checkConfig(keyValue);
Assert.assertNull(bo);
keyValue.put("syncMod", SyncMod.LAST_OFFSET.name());
Config config1 = new Config();
config1.load(keyValue);
Assert.assertEquals("127.0.0.1", config.getRedisAddr());
Assert.assertTrue(6379 == config1.getRedisPort());
Assert.assertEquals("1234567", config1.getRedisPassword());
Assert.assertEquals(SyncMod.LAST_OFFSET, config1.getSyncMod());
String err = config1.load(null);
Assert.assertNotNull(err);
}
use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.
the class MongoSourceTaskTest method testEmptyContextStart.
@Test
public void testEmptyContextStart() throws NoSuchFieldException, IllegalAccessException {
MongoSourceTask mongoSourceTask = new MongoSourceTask();
DefaultKeyValue defaultKeyValue = new DefaultKeyValue();
defaultKeyValue.put("mongoAddr", "test/127.0.0.1:27027");
defaultKeyValue.put("positionTimeStamp", "11111111");
defaultKeyValue.put("positionInc", "111");
defaultKeyValue.put("serverSelectionTimeoutMS", "10");
defaultKeyValue.put("dataSync", "true");
Field context = SourceTask.class.getDeclaredField("context");
context.setAccessible(true);
context.set(mongoSourceTask, emptyTaskContext());
mongoSourceTask.start(defaultKeyValue);
Field replicaSetsContext = MongoSourceTask.class.getDeclaredField("replicaSetsContext");
replicaSetsContext.setAccessible(true);
ReplicaSetsContext setsContext = (ReplicaSetsContext) replicaSetsContext.get(mongoSourceTask);
Field replicaSets = ReplicaSetsContext.class.getDeclaredField("replicaSets");
replicaSets.setAccessible(true);
List<ReplicaSet> replicaSetList = (List<ReplicaSet>) replicaSets.get(setsContext);
Assert.assertTrue(replicaSetList.size() == 1);
ReplicaSet replicaSet = replicaSetList.get(0);
Field replicaSetConfig = ReplicaSet.class.getDeclaredField("replicaSetConfig");
replicaSetConfig.setAccessible(true);
ReplicaSetConfig replicaSetConfig1 = (ReplicaSetConfig) replicaSetConfig.get(replicaSet);
Assert.assertTrue(StringUtils.equals(replicaSetConfig1.getReplicaSetName(), "test"));
Assert.assertTrue(StringUtils.equals(replicaSetConfig1.getHost(), "127.0.0.1:27027"));
Assert.assertTrue(replicaSetConfig1.getPosition().getTimeStamp() == 11111111);
Assert.assertTrue(replicaSetConfig1.getPosition().getInc() == 111);
Assert.assertTrue(replicaSetConfig1.getPosition().isInitSync());
}
use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.
the class RabbitmqSourceConnectorTest method verifyAndSetConfig.
@Test
public void verifyAndSetConfig() {
KeyValue keyValue = new DefaultKeyValue();
for (String requestKey : RabbitmqConfig.REQUEST_CONFIG) {
assertEquals(rabbitmqSourceConnector.verifyAndSetConfig(keyValue), "Request config key: " + requestKey);
keyValue.put(requestKey, requestKey);
}
assertEquals(rabbitmqSourceConnector.verifyAndSetConfig(keyValue), "");
}
use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.
the class RabbitmqSourceTaskTest method getPatternProcessor.
public void getPatternProcessor(Replicator replicator) {
KeyValue kv = new DefaultKeyValue();
kv.put("rabbitmqUrl", "amqp://112.74.48.251:5672");
kv.put("rabbitmqUsername", "admin");
kv.put("rabbitmqPassword", "admin");
kv.put("destinationType", "queue");
kv.put("destinationName", "test-queue");
RabbitmqConfig config = new RabbitmqConfig();
config.load(kv);
replicator = new Replicator(config, null);
RabbitmqSourceTask task = new RabbitmqSourceTask();
assertEquals(RabbitMQPatternProcessor.class, task.getPatternProcessor(replicator).getClass());
}
Aggregations