Search in sources :

Example 1 with KafkaAbstractSource

use of org.apache.pulsar.io.kafka.KafkaAbstractSource in project pulsar by yahoo.

the class KafkaAbstractSourceTest method testInvalidConfigWillThrownException.

@Test
public void testInvalidConfigWillThrownException() throws Exception {
    KafkaAbstractSource source = new DummySource();
    SourceContext ctx = mock(SourceContext.class);
    Map<String, Object> config = new HashMap<>();
    Assert.ThrowingRunnable openAndClose = () -> {
        try {
            source.open(config, ctx);
            fail();
        } finally {
            source.close();
        }
    };
    expectThrows(NullPointerException.class, openAndClose);
    config.put("topic", "topic_1");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("bootstrapServers", "localhost:8080");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("groupId", "test-group");
    config.put("fetchMinBytes", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("fetchMinBytes", 1000);
    config.put("autoCommitEnabled", true);
    config.put("autoCommitIntervalMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoCommitIntervalMs", 100);
    config.put("sessionTimeoutMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("sessionTimeoutMs", 10000);
    config.put("heartbeatIntervalMs", -100);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 20000);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 5000);
    config.put("autoOffsetReset", "some-value");
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoOffsetReset", "earliest");
    source.open(config, ctx);
    source.close();
}
Also used : KafkaAbstractSource(org.apache.pulsar.io.kafka.KafkaAbstractSource) Assert(org.testng.Assert) HashMap(java.util.HashMap) SourceContext(org.apache.pulsar.io.core.SourceContext) Test(org.testng.annotations.Test)

Example 2 with KafkaAbstractSource

use of org.apache.pulsar.io.kafka.KafkaAbstractSource in project incubator-pulsar by apache.

the class KafkaAbstractSourceTest method testInvalidConfigWillThrownException.

@Test
public void testInvalidConfigWillThrownException() throws Exception {
    KafkaAbstractSource source = new DummySource();
    SourceContext ctx = mock(SourceContext.class);
    Map<String, Object> config = new HashMap<>();
    Assert.ThrowingRunnable openAndClose = () -> {
        try {
            source.open(config, ctx);
            fail();
        } finally {
            source.close();
        }
    };
    expectThrows(NullPointerException.class, openAndClose);
    config.put("topic", "topic_1");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("bootstrapServers", "localhost:8080");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("groupId", "test-group");
    config.put("fetchMinBytes", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("fetchMinBytes", 1000);
    config.put("autoCommitEnabled", true);
    config.put("autoCommitIntervalMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoCommitIntervalMs", 100);
    config.put("sessionTimeoutMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("sessionTimeoutMs", 10000);
    config.put("heartbeatIntervalMs", -100);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 20000);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 5000);
    config.put("autoOffsetReset", "some-value");
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoOffsetReset", "earliest");
    source.open(config, ctx);
    source.close();
}
Also used : KafkaAbstractSource(org.apache.pulsar.io.kafka.KafkaAbstractSource) Assert(org.testng.Assert) HashMap(java.util.HashMap) SourceContext(org.apache.pulsar.io.core.SourceContext) Test(org.testng.annotations.Test)

Example 3 with KafkaAbstractSource

use of org.apache.pulsar.io.kafka.KafkaAbstractSource in project pulsar by apache.

the class KafkaAbstractSourceTest method testInvalidConfigWillThrownException.

@Test
public void testInvalidConfigWillThrownException() throws Exception {
    KafkaAbstractSource source = new DummySource();
    SourceContext ctx = mock(SourceContext.class);
    Map<String, Object> config = new HashMap<>();
    Assert.ThrowingRunnable openAndClose = () -> {
        try {
            source.open(config, ctx);
            fail();
        } finally {
            source.close();
        }
    };
    expectThrows(NullPointerException.class, openAndClose);
    config.put("topic", "topic_1");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("bootstrapServers", "localhost:8080");
    expectThrows(NullPointerException.class, openAndClose);
    config.put("groupId", "test-group");
    config.put("fetchMinBytes", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("fetchMinBytes", 1000);
    config.put("autoCommitEnabled", true);
    config.put("autoCommitIntervalMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoCommitIntervalMs", 100);
    config.put("sessionTimeoutMs", -1);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("sessionTimeoutMs", 10000);
    config.put("heartbeatIntervalMs", -100);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 20000);
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("heartbeatIntervalMs", 5000);
    config.put("autoOffsetReset", "some-value");
    expectThrows(IllegalArgumentException.class, openAndClose);
    config.put("autoOffsetReset", "earliest");
    source.open(config, ctx);
    source.close();
}
Also used : KafkaAbstractSource(org.apache.pulsar.io.kafka.KafkaAbstractSource) Assert(org.testng.Assert) HashMap(java.util.HashMap) SourceContext(org.apache.pulsar.io.core.SourceContext) Test(org.testng.annotations.Test)

Aggregations

HashMap (java.util.HashMap)3 SourceContext (org.apache.pulsar.io.core.SourceContext)3 KafkaAbstractSource (org.apache.pulsar.io.kafka.KafkaAbstractSource)3 Assert (org.testng.Assert)3 Test (org.testng.annotations.Test)3