Search in sources :

Example 91 with MapBasedConfig

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

the class JmsSinkTest method testDisablingMessageIdAndTimestamp.

@Test
public void testDisablingMessageIdAndTimestamp() throws JMSException {
    MapBasedConfig config = new MapBasedConfig().with("destination", "queue-one").with("disable-message-id", true).with("disable-message-timestamp", true).with("channel-name", "jms");
    JmsSink sink = new JmsSink(jms, new JmsConnectorOutgoingConfiguration(config), jsonMapping, executor);
    MyJmsClient client = new MyJmsClient(jms.createQueue("queue-one"));
    subscriber = sink.getSink().build();
    subscriber.onSubscribe(new Subscriptions.EmptySubscription());
    AtomicBoolean acked = new AtomicBoolean();
    subscriber.onNext(Message.of("hello", () -> CompletableFuture.runAsync(() -> acked.set(true))));
    await().until(() -> client.messages.size() >= 1);
    assertThat(acked).isTrue();
    assertThat(client.messages.get(0).getBody(String.class)).isEqualTo("hello");
    assertThat(client.messages.get(0).getJMSMessageID()).isNull();
    assertThat(client.messages.get(0).getJMSTimestamp()).isEqualTo(0L);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscriptions(io.smallrye.mutiny.helpers.Subscriptions) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 92 with MapBasedConfig

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

the class NamedFactoryTest method testWithoutConnectionFactoryAndNameSet.

@Test
public void testWithoutConnectionFactoryAndNameSet() {
    initWithoutConnectionFactory();
    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);
    try {
        deploy(PayloadConsumerBean.class, ProducerBean.class);
    } catch (DeploymentException de) {
        assertThat(de).hasCauseInstanceOf(IllegalStateException.class).hasMessageContaining("javax.jms.ConnectionFactory bean named");
    }
}
Also used : HashMap(java.util.HashMap) DeploymentException(javax.enterprise.inject.spi.DeploymentException) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 93 with MapBasedConfig

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

the class NamedFactoryTest 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 94 with MapBasedConfig

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

the class InMemoryConnectorWithMergeTest method install.

@BeforeEach
public void install() {
    Map<String, Object> conf = new HashMap<>();
    conf.put("mp.messaging.outgoing.bar.connector", InMemoryConnector.CONNECTOR);
    conf.put("mp.messaging.outgoing.bar.merge", "true");
    installConfig(new MapBasedConfig(conf));
}
Also used : HashMap(java.util.HashMap) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 95 with MapBasedConfig

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

the class JacksonMappingTest method identityString.

@Test
@DisplayName("Test the conversion from string to object and back")
void identityString() {
    MapBasedConfig config = new MapBasedConfig(Collections.emptyMap());
    addConfig(config);
    WeldContainer container = deploy();
    JacksonMapping mapping = container.select(JacksonMapping.class).get();
    final String testObjectAsJson = "{\"my_id\": 1, \"my_Payload\": \"Lorem ipsum\"}";
    assertThat(mapping.toJson(mapping.fromJson(testObjectAsJson, TestObject.class))).isNotNull();
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

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