use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class JmsConnectorTest method testWithStringAndSessionModel.
@Test
public void testWithStringAndSessionModel() {
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");
map.put("mp.messaging.incoming.jms.session-mode", "DUPS_OK_ACKNOWLEDGE");
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);
assertThat(bean.list()).hasSizeGreaterThan(3);
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class JmsConnectorTest method testWithInvalidIncomingDestinationType.
@Test
public void testWithInvalidIncomingDestinationType() {
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-type", "invalid");
MapBasedConfig config = new MapBasedConfig(map);
addConfig(config);
assertThatThrownBy(() -> deploy(PayloadConsumerBean.class, ProducerBean.class)).isInstanceOf(DeploymentException.class);
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class JmsSinkTest method testDefaultConfigurationAgainstTopic.
@Test
public void testDefaultConfigurationAgainstTopic() throws JMSException {
MapBasedConfig config = new MapBasedConfig().with("destination", "my-topic").with("destination-type", "topic").with("channel-name", "jms");
JmsSink sink = new JmsSink(jms, new JmsConnectorOutgoingConfiguration(config), jsonMapping, executor);
MyJmsClient client1 = new MyJmsClient(jms.createTopic("my-topic"));
MyJmsClient client2 = new MyJmsClient(jms.createTopic("my-topic"));
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(() -> client1.messages.size() >= 1);
await().until(() -> client2.messages.size() >= 1);
assertThat(acked).isTrue();
assertThat(client1.messages.get(0).getBody(String.class)).isEqualTo("hello");
assertThat(client2.messages.get(0).getBody(String.class)).isEqualTo("hello");
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class JmsSinkTest method testWithDeliveryDelayAndMode.
@Test
public void testWithDeliveryDelayAndMode() throws JMSException {
MapBasedConfig config = new MapBasedConfig().with("destination", "queue-one").with("delivery-delay", 1500L).with("delivery-mode", "non_persistent").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().atLeast(1, TimeUnit.SECONDS).until(() -> client.messages.size() >= 1);
assertThat(acked).isTrue();
assertThat(client.messages.get(0).getBody(String.class)).isEqualTo("hello");
assertThat(client.messages.get(0).getJMSMessageID()).isNotNull();
assertThat(client.messages.get(0).getJMSTimestamp()).isPositive();
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class JmsSinkTest method testWithReplyToTopic.
@SuppressWarnings("ConstantConditions")
@Test
public void testWithReplyToTopic() throws JMSException {
MapBasedConfig config = new MapBasedConfig().with("destination", "queue-one").with("reply-to", "my-response").with("reply-to-destination-type", "topic").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).getJMSReplyTo()).isInstanceOf(Topic.class);
}
Aggregations