Search in sources :

Example 56 with MapBasedConfig

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

the class AmqpSourceCDIConfigTest method testConfigGlobalOptionsByCDIMissingBean.

@Test
public void testConfigGlobalOptionsByCDIMissingBean() {
    Weld weld = new Weld();
    weld.addBeanClass(ConsumptionBean.class);
    weld.addBeanClass(ExecutionHolder.class);
    new MapBasedConfig().put("mp.messaging.incoming.data.address", "data").put("mp.messaging.incoming.data.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.incoming.data.host", host).put("mp.messaging.incoming.data.port", port).put("mp.messaging.incoming.data.tracing-enabled", false).put("amqp-username", username).put("amqp-password", password).put("amqp-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 57 with MapBasedConfig

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

the class AmqpSourceCDIConfigTest method testClientConfigWithHostSet.

/**
 * Reproduce https://github.com/smallrye/smallrye-reactive-messaging/issues/1491.
 */
@Test
public void testClientConfigWithHostSet() {
    Weld weld = new Weld();
    String address = UUID.randomUUID().toString();
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ConsumptionBean.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.address", address).with("mp.messaging.incoming.data.connector", AmqpConnector.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("amqp-username", username).with("amqp-password", password).with("amqp-client-options-name", "myclientoptions2").write();
    container = weld.initialize();
    await().until(() -> isAmqpConnectorAlive(container));
    await().until(() -> isAmqpConnectorReady(container));
    List<Integer> list = container.select(ConsumptionBean.class).get().getResults();
    assertThat(list).isEmpty();
    AtomicInteger counter = new AtomicInteger();
    usage.produceTenIntegers(address, 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 58 with MapBasedConfig

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

the class AmqpSourceCDIConfigTest method testConfigGlobalOptionsByCDICorrect.

@Test
public void testConfigGlobalOptionsByCDICorrect() {
    Weld weld = new Weld();
    String address = UUID.randomUUID().toString();
    weld.addBeanClass(ClientConfigurationBean.class);
    weld.addBeanClass(ConsumptionBean.class);
    new MapBasedConfig().with("mp.messaging.incoming.data.address", address).with("mp.messaging.incoming.data.connector", AmqpConnector.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("amqp-username", username).with("amqp-password", password).with("amqp-client-options-name", "myclientoptions").write();
    container = weld.initialize();
    await().until(() -> isAmqpConnectorAlive(container));
    await().until(() -> isAmqpConnectorReady(container));
    List<Integer> list = container.select(ConsumptionBean.class).get().getResults();
    assertThat(list).isEmpty();
    AtomicInteger counter = new AtomicInteger();
    usage.produceTenIntegers(address, 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 59 with MapBasedConfig

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

the class ObjectExchangeTest method testServicesExchangingStructuresAsJson.

@Test
public void testServicesExchangingStructuresAsJson() {
    weld.addBeanClass(Consumer.class);
    weld.addBeanClass(Generator.class);
    new MapBasedConfig().put("mp.messaging.outgoing.to-amqp.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.outgoing.to-amqp.address", "prices").put("mp.messaging.outgoing.to-amqp.durable", false).put("mp.messaging.outgoing.to-amqp.host", host).put("mp.messaging.outgoing.to-amqp.port", port).put("mp.messaging.outgoing.to-amqp.tracing-enabled", false).put("mp.messaging.incoming.from-amqp.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.incoming.from-amqp.address", "prices").put("mp.messaging.incoming.from-amqp.durable", true).put("mp.messaging.incoming.from-amqp.host", host).put("mp.messaging.incoming.from-amqp.port", port).put("mp.messaging.incoming.from-amqp.tracing-enabled", false).put("amqp-username", username).put("amqp-password", password).write();
    container = weld.initialize();
    await().until(() -> isAmqpConnectorReady(container));
    await().until(() -> isAmqpConnectorAlive(container));
    Generator generator = container.getBeanManager().createInstance().select(Generator.class).get();
    Consumer consumer = container.getBeanManager().createInstance().select(Consumer.class).get();
    generator.send();
    await().until(() -> consumer.list().size() == 2);
    assertThat(consumer.list()).allSatisfy(p -> {
        assertThat(p).isNotNull();
        assertThat(p.getPrice()).isGreaterThan(0);
    });
}
Also used : MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 60 with MapBasedConfig

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

the class RabbitMQTest method testReceivingMessagesFromRabbitMQ.

@Test
public void testReceivingMessagesFromRabbitMQ() {
    new MapBasedConfig().put("mp.messaging.incoming.data.address", "data").put("mp.messaging.incoming.data.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.incoming.data.host", host).put("mp.messaging.incoming.data.port", port).put("mp.messaging.incoming.data.tracing-enabled", false).put("amqp-username", username).put("amqp-password", password).write();
    weld.addBeanClass(ConsumptionBean.class);
    container = weld.initialize();
    await().until(() -> isAmqpConnectorReady(container));
    await().until(() -> isAmqpConnectorAlive(container));
    ConsumptionBean bean = container.getBeanManager().createInstance().select(ConsumptionBean.class).get();
    await().until(() -> isAmqpConnectorReady(container));
    await().until(() -> isAmqpConnectorAlive(container));
    List<Integer> list = bean.getResults();
    assertThat(list).isEmpty();
    AtomicInteger counter = new AtomicInteger();
    usage.produceTenIntegers("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) 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