Search in sources :

Example 41 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class RabbitMQSourceCDIConfigTest method testConfigByCDIIncorrectBean.

@Test
public void testConfigByCDIIncorrectBean() {
    Weld weld = new Weld();
    weld.addBeanClass(ConsumptionBean.class);
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ExecutionHolder.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.queue.name", "data").with("mp.messaging.incoming.data.connector", RabbitMQConnector.CONNECTOR_NAME).with("mp.messaging.incoming.data.host", host).with("mp.messaging.incoming.data.port", port).with("rabbitmq-username", username).with("rabbitmq-password", password).with("mp.messaging.incoming.data.client-options-name", "dummyoptionsnonexistent").with("mp.messaging.incoming.data.tracing-enabled", false).write();
    assertThatThrownBy(() -> container = weld.initialize()).isInstanceOf(DeploymentException.class);
}
Also used : MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.jupiter.api.Test)

Example 42 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class RabbitMQSourceCDIConfigTest method testConfigByCDICorrect.

@Test
public void testConfigByCDICorrect() {
    Weld weld = new Weld();
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ConsumptionBean.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.queue.name", "data").with("mp.messaging.incoming.data.connector", RabbitMQConnector.CONNECTOR_NAME).with("mp.messaging.incoming.data.host", host).with("mp.messaging.incoming.data.port", port).with("rabbitmq-username", username).with("rabbitmq-password", password).with("mp.messaging.incoming.data.client-options-name", "myclientoptions").with("mp.messaging.incoming.data.tracing-enabled", false).write();
    container = weld.initialize();
    await().until(() -> isRabbitMQConnectorAlive(container));
    await().until(() -> isRabbitMQConnectorReady(container));
    List<Integer> list = container.select(ConsumptionBean.class).get().getResults();
    assertThat(list).isEmpty();
    AtomicInteger counter = new AtomicInteger();
    usage.produceTenIntegers("data", "data", "", counter::getAndIncrement);
    await().atMost(2, TimeUnit.MINUTES).until(() -> list.size() >= 10);
    assertThat(list).containsExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.jupiter.api.Test)

Example 43 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class RabbitMQSourceCDIConfigTest method testConfigGlobalOptionsByCDIIncorrectBean.

@Test
public void testConfigGlobalOptionsByCDIIncorrectBean() {
    Weld weld = new Weld();
    weld.addBeanClass(ConsumptionBean.class);
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ExecutionHolder.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.queue.name", "data").with("mp.messaging.incoming.data.connector", RabbitMQConnector.CONNECTOR_NAME).with("mp.messaging.incoming.data.host", host).with("mp.messaging.incoming.data.port", port).with("mp.messaging.incoming.data.tracing-enabled", false).with("rabbitmq-username", username).with("rabbitmq-password", password).with("rabbitmq-client-options-name", "dummyoptionsnonexistent").write();
    assertThatThrownBy(() -> container = weld.initialize()).isInstanceOf(DeploymentException.class);
}
Also used : MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.jupiter.api.Test)

Example 44 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class RabbitMQSourceCDIConfigTest method testConfigGlobalOptionsByCDIMissingBean.

@Test
public void testConfigGlobalOptionsByCDIMissingBean() {
    Weld weld = new Weld();
    weld.addBeanClass(ConsumptionBean.class);
    weld.addBeanClass(ExecutionHolder.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.queue.name", "data").with("mp.messaging.incoming.data.connector", RabbitMQConnector.CONNECTOR_NAME).with("mp.messaging.incoming.data.host", host).with("mp.messaging.incoming.data.port", port).with("mp.messaging.incoming.data.tracing-enabled", false).with("rabbitmq-username", username).with("rabbitmq-password", password).with("rabbitmq-client-options-name", "myclientoptions").write();
    assertThatThrownBy(() -> container = weld.initialize()).isInstanceOf(DeploymentException.class);
}
Also used : MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.jupiter.api.Test)

Example 45 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class RabbitMQSourceCDIConfigTest method testConfigGlobalOptionsByCDICorrect.

@Test
public void testConfigGlobalOptionsByCDICorrect() {
    Weld weld = new Weld();
    String queueName = UUID.randomUUID().toString();
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ConsumptionBean.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.queue.name", queueName).with("mp.messaging.incoming.data.exchange.name", queueName).with("mp.messaging.incoming.data.connector", RabbitMQConnector.CONNECTOR_NAME).with("mp.messaging.incoming.data.host", host).with("mp.messaging.incoming.data.port", port).with("mp.messaging.incoming.data.tracing-enabled", false).with("rabbitmq-username", username).with("rabbitmq-password", password).with("rabbitmq-client-options-name", "myclientoptions").write();
    container = weld.initialize();
    await().until(() -> isRabbitMQConnectorAlive(container));
    await().until(() -> isRabbitMQConnectorReady(container));
    List<Integer> list = container.select(ConsumptionBean.class).get().getResults();
    assertThat(list).isEmpty();
    AtomicInteger counter = new AtomicInteger();
    usage.produceTenIntegers(queueName, queueName, "", counter::getAndIncrement);
    await().atMost(2, TimeUnit.MINUTES).until(() -> list.size() >= 10);
    assertThat(list).containsExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.jupiter.api.Test)

Aggregations

MapBasedConfig (io.smallrye.reactive.messaging.test.common.config.MapBasedConfig)272 Test (org.junit.jupiter.api.Test)223 Message (org.eclipse.microprofile.reactive.messaging.Message)69 JsonObject (io.vertx.core.json.JsonObject)63 ArrayList (java.util.ArrayList)61 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)57 TopicPartition (org.apache.kafka.common.TopicPartition)43 Awaitility.await (org.awaitility.Awaitility.await)38 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)37 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)34 Weld (org.jboss.weld.environment.se.Weld)32 KafkaMapBasedConfig (io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)31 HashMap (java.util.HashMap)29 AfterEach (org.junit.jupiter.api.AfterEach)29 Collectors (java.util.stream.Collectors)28 HealthReport (io.smallrye.reactive.messaging.health.HealthReport)26 KafkaSource (io.smallrye.reactive.messaging.kafka.impl.KafkaSource)26 IntegerDeserializer (org.apache.kafka.common.serialization.IntegerDeserializer)25 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)23 Duration (java.time.Duration)22