Search in sources :

Example 26 with DefaultKeyValue

use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.

the class MongoSourceTaskTest method testContextStart.

@Test
public void testContextStart() throws NoSuchFieldException, IllegalAccessException {
    MongoSourceTask mongoSourceTask = new MongoSourceTask();
    DefaultKeyValue defaultKeyValue = new DefaultKeyValue();
    defaultKeyValue.put("mongoAddr", "test/127.0.0.1:27027");
    defaultKeyValue.put("serverSelectionTimeoutMS", "10");
    Field context = SourceTask.class.getDeclaredField("context");
    context.setAccessible(true);
    context.set(mongoSourceTask, TaskContext());
    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() == 22222222);
    Assert.assertTrue(replicaSetConfig1.getPosition().getInc() == 222);
    Assert.assertTrue(!replicaSetConfig1.getPosition().isInitSync());
}
Also used : DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) Field(java.lang.reflect.Field) ReplicaSetConfig(org.apache.connect.mongo.replicator.ReplicaSetConfig) ReplicaSetsContext(org.apache.connect.mongo.replicator.ReplicaSetsContext) List(java.util.List) ReplicaSet(org.apache.connect.mongo.replicator.ReplicaSet) MongoSourceTask(org.apache.connect.mongo.connector.MongoSourceTask) Test(org.junit.Test)

Example 27 with DefaultKeyValue

use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.

the class BaseJmsSourceConnectorTest method verifyAndSetConfigTest.

@Test
public void verifyAndSetConfigTest() {
    KeyValue keyValue = new DefaultKeyValue();
    for (String requestKey : Config.REQUEST_CONFIG) {
        assertEquals(connector.verifyAndSetConfig(keyValue), "Request config key: " + requestKey);
        keyValue.put(requestKey, requestKey);
    }
    assertEquals(connector.verifyAndSetConfig(keyValue), "");
}
Also used : DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) KeyValue(io.openmessaging.KeyValue) Test(org.junit.Test)

Example 28 with DefaultKeyValue

use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.

the class RabbitmqSourceTaskTest method test.

// @Test
public void test() throws InterruptedException {
    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");
    RabbitmqSourceTask task = new RabbitmqSourceTask();
    task.start(kv);
    for (int i = 0; i < 20; ) {
        Collection<SourceDataEntry> sourceDataEntry = task.poll();
        i = i + sourceDataEntry.size();
        System.out.println(sourceDataEntry);
    }
    Thread.sleep(20000);
}
Also used : DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) KeyValue(io.openmessaging.KeyValue) DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) SourceDataEntry(io.openmessaging.connector.api.data.SourceDataEntry)

Example 29 with DefaultKeyValue

use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.

the class ActivemqConnectorTest method taskConfigsTest.

@Test
public void taskConfigsTest() {
    assertEquals(connector.taskConfigs().get(0), null);
    KeyValue keyValue = new DefaultKeyValue();
    for (String requestKey : Config.REQUEST_CONFIG) {
        keyValue.put(requestKey, requestKey);
    }
    connector.verifyAndSetConfig(keyValue);
    assertEquals(connector.taskConfigs().get(0), keyValue);
}
Also used : DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) KeyValue(io.openmessaging.KeyValue) Test(org.junit.Test)

Example 30 with DefaultKeyValue

use of io.openmessaging.internal.DefaultKeyValue in project rocketmq-externals by apache.

the class ActivemqConnectorTest method verifyAndSetConfigTest.

@Test
public void verifyAndSetConfigTest() {
    KeyValue keyValue = new DefaultKeyValue();
    for (String requestKey : Config.REQUEST_CONFIG) {
        assertEquals(connector.verifyAndSetConfig(keyValue), "Request config key: " + requestKey);
        keyValue.put(requestKey, requestKey);
    }
    assertEquals(connector.verifyAndSetConfig(keyValue), "");
}
Also used : DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) DefaultKeyValue(io.openmessaging.internal.DefaultKeyValue) KeyValue(io.openmessaging.KeyValue) Test(org.junit.Test)

Aggregations

DefaultKeyValue (io.openmessaging.internal.DefaultKeyValue)32 KeyValue (io.openmessaging.KeyValue)27 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)8 List (java.util.List)7 HashMap (java.util.HashMap)4 Field (java.lang.reflect.Field)3 SourceDataEntry (io.openmessaging.connector.api.data.SourceDataEntry)2 Map (java.util.Map)2 Set (java.util.Set)2 MongoSourceTask (org.apache.connect.mongo.connector.MongoSourceTask)2 ReplicaSet (org.apache.connect.mongo.replicator.ReplicaSet)2 ReplicaSetConfig (org.apache.connect.mongo.replicator.ReplicaSetConfig)2 ReplicaSetsContext (org.apache.connect.mongo.replicator.ReplicaSetsContext)2 TaskTopicInfo (org.apache.rocketmq.replicator.config.TaskTopicInfo)2 Before (org.junit.Before)2 RedisURI (com.moilioncircle.redis.replicator.RedisURI)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ByteBuffer (java.nio.ByteBuffer)1 LinkedList (java.util.LinkedList)1