Search in sources :

Example 1 with KafkaTestApplication

use of org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication in project sda-dropwizard-commons by SDA-SE.

the class KafkaBundleWithSaslScramIT method shouldReceiveEntries.

@Test
public void shouldReceiveEntries() {
    Set<String> results = new HashSet<>();
    DW.<KafkaTestApplication>getApplication().kafkaBundle().createMessageListener(MessageListenerRegistration.builder().withDefaultListenerConfig().forTopic("my-topic").withDefaultConsumer().withKeyDeserializer(new StringDeserializer()).withValueDeserializer(new StringDeserializer()).withListenerStrategy(new SyncCommitMLS<>(r -> results.add(r.value()), null)).build());
    Map<byte[], byte[]> records = new HashMap<>();
    records.put("key".getBytes(StandardCharsets.UTF_8), "My Message".getBytes(StandardCharsets.UTF_8));
    KAFKA.getKafkaTestUtils().produceRecords(records, "my-topic", 0);
    await().atMost(KafkaBundleConsts.N_MAX_WAIT_MS, MILLISECONDS).untilAsserted(() -> assertThat(results).containsOnly("My Message"));
}
Also used : SystemPropertyRule(org.sdase.commons.server.testing.SystemPropertyRule) TestRule(org.junit.rules.TestRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MessageListenerRegistration(org.sdase.commons.server.kafka.builder.MessageListenerRegistration) SharedKafkaTestResource(com.salesforce.kafka.test.junit4.SharedKafkaTestResource) HashMap(java.util.HashMap) JaasUtils(org.apache.kafka.common.security.JaasUtils) SharedKafkaTestResourceScram(com.salesforce.kafka.test.SharedKafkaTestResourceScram) HashSet(java.util.HashSet) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) DropwizardAppRule(io.dropwizard.testing.junit.DropwizardAppRule) Map(java.util.Map) KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) SyncCommitMLS(org.sdase.commons.server.kafka.consumer.strategies.synccommit.SyncCommitMLS) ClassRule(org.junit.ClassRule) Awaitility.await(org.awaitility.Awaitility.await) Set(java.util.Set) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) StandardCharsets(java.nio.charset.StandardCharsets) RuleChain(org.junit.rules.RuleChain) ConfigOverride.config(io.dropwizard.testing.ConfigOverride.config) ResourceHelpers.resourceFilePath(io.dropwizard.testing.ResourceHelpers.resourceFilePath) SaslScramListener(com.salesforce.kafka.test.listeners.SaslScramListener) KafkaTestConfiguration(org.sdase.commons.server.kafka.dropwizard.KafkaTestConfiguration) HashMap(java.util.HashMap) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with KafkaTestApplication

use of org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication in project sda-dropwizard-commons by SDA-SE.

the class KafkaPrometheusMonitoringIT method before.

@Before
public void before() {
    KafkaTestApplication app = DROPWIZARD_APP_RULE.getApplication();
    kafkaBundle = app.kafkaBundle();
    resultsLong.clear();
}
Also used : KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) Before(org.junit.Before)

Example 3 with KafkaTestApplication

use of org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication in project sda-dropwizard-commons by SDA-SE.

the class KafkaTopicIT method setup.

@BeforeEach
public void setup() {
    results.clear();
    KafkaTestApplication app = DW.getApplication();
    bundle = app.kafkaBundle();
}
Also used : KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with KafkaTestApplication

use of org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication in project sda-dropwizard-commons by SDA-SE.

the class KafkaBundleWithConfigIT method healthCheckShouldBeAdded.

@Test
public void healthCheckShouldBeAdded() {
    KafkaTestApplication app = DROPWIZARD_APP_RULE.getApplication();
    assertThat(app.healthCheckRegistry().getHealthCheck("kafkaConnection")).isNotNull();
}
Also used : KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) Test(org.junit.Test)

Example 5 with KafkaTestApplication

use of org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication in project sda-dropwizard-commons by SDA-SE.

the class AppWithoutKafkaServerIT method before.

@Before
public void before() {
    KafkaTestApplication app = DW.getApplication();
    bundle = app.kafkaBundle();
    results.clear();
}
Also used : KafkaTestApplication(org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication) Before(org.junit.Before)

Aggregations

KafkaTestApplication (org.sdase.commons.server.kafka.dropwizard.KafkaTestApplication)10 Test (org.junit.Test)5 SharedKafkaTestResource (com.salesforce.kafka.test.junit4.SharedKafkaTestResource)4 ConfigOverride.config (io.dropwizard.testing.ConfigOverride.config)4 ResourceHelpers.resourceFilePath (io.dropwizard.testing.ResourceHelpers.resourceFilePath)4 DropwizardAppRule (io.dropwizard.testing.junit.DropwizardAppRule)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)4 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Awaitility.await (org.awaitility.Awaitility.await)4 Before (org.junit.Before)4 ClassRule (org.junit.ClassRule)4 RuleChain (org.junit.rules.RuleChain)4 TestRule (org.junit.rules.TestRule)4 MessageListenerRegistration (org.sdase.commons.server.kafka.builder.MessageListenerRegistration)4 SyncCommitMLS (org.sdase.commons.server.kafka.consumer.strategies.synccommit.SyncCommitMLS)4 KafkaTestConfiguration (org.sdase.commons.server.kafka.dropwizard.KafkaTestConfiguration)4 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)3