Search in sources :

Example 81 with MapBasedConfig

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

the class DeprecatedNamedFactoryTest method testNamedConnectionFactory.

@Test
public void testNamedConnectionFactory() {
    initWithoutConnectionFactory().addBeanClasses(BarConnectionFactoryBean.class, FooConnectionFactoryBean.class);
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.connector." + JmsConnector.CONNECTOR_NAME + ".connection-factory-name", "foo");
    map.put("mp.messaging.outgoing.queue-one.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.destination", "queue-one");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    WeldContainer container = deploy(PayloadConsumerBean.class, ProducerBean.class);
    PayloadConsumerBean bean = container.select(PayloadConsumerBean.class).get();
    await().until(() -> bean.list().size() > 3);
}
Also used : HashMap(java.util.HashMap) WeldContainer(org.jboss.weld.environment.se.WeldContainer) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 82 with MapBasedConfig

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

the class HeaderPropagationTest method testFromAppToJMS.

@Test
public void testFromAppToJMS() {
    MyJmsClient client = new MyJmsClient(jms.createQueue("some-queue"));
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.outgoing.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.outgoing.jms.destination", "should-not-be-used");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    deploy(MyAppGeneratingData.class);
    await().until(() -> client.messages.size() == 10);
    assertThat(client.messages).allSatisfy(entry -> {
        try {
            assertThat(entry.getBody(String.class)).isNotNull();
            assertThat(entry.getJMSCorrelationID()).startsWith("my-correlation-");
            assertThat(entry.getStringProperty("prop")).isEqualTo("bar");
        } catch (JMSException e) {
            fail("unable to read jms data", e);
        }
    });
}
Also used : HashMap(java.util.HashMap) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 83 with MapBasedConfig

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

the class HeaderPropagationTest method testFromJmsToAppToJms.

@Test
public void testFromJmsToAppToJms() {
    MyJmsClient client = new MyJmsClient(jms.createQueue("some-queue"));
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.incoming.source.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.source.destination", "source");
    map.put("mp.messaging.outgoing.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.outgoing.jms.destination", "should-not-be-used");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    deploy(MyAppProcessingData.class);
    AtomicInteger count = new AtomicInteger();
    JMSProducer producer = jms.createProducer();
    Queue source = jms.createQueue("source");
    for (int i = 0; i < 20; i++) {
        ObjectMessage message = jms.createObjectMessage(count.getAndIncrement());
        producer.send(source, message);
    }
    await().until(() -> client.messages.size() >= 10);
    assertThat(client.messages).allSatisfy(entry -> {
        try {
            assertThat(entry.getBody(String.class)).isNotNull();
            assertThat(entry.getJMSCorrelationID()).startsWith("my-correlation-");
            assertThat(entry.getStringProperty("prop")).isEqualTo("bar");
        } catch (JMSException e) {
            fail("unable to read jms data", e);
        }
    });
}
Also used : HashMap(java.util.HashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 84 with MapBasedConfig

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

the class JmsConnectorTest method testWithPerson.

@Test
public void testWithPerson() {
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.outgoing.queue-one.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.destination", "queue-one");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    WeldContainer container = deploy(PersonConsumerBean.class, PersonProducerBean.class);
    PersonConsumerBean bean = container.select(PersonConsumerBean.class).get();
    await().until(() -> bean.list().size() > 1);
    assertThat(bean.list()).isNotEmpty();
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 85 with MapBasedConfig

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

the class JmsConnectorTest method testWithInvalidOutgoingDestinationType.

@Test
public void testWithInvalidOutgoingDestinationType() {
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.outgoing.queue-one.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.outgoing.queue-one.destination-type", "invalid");
    map.put("mp.messaging.incoming.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.destination-type", "queue");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    assertThatThrownBy(() -> {
        deploy(PayloadConsumerBean.class, ProducerBean.class);
    }).isInstanceOf(DeploymentException.class);
}
Also used : 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