use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class RabbitMQTest method testSendingMessagesToRabbitMQWithNotAnonymousDetection.
@Test
public void testSendingMessagesToRabbitMQWithNotAnonymousDetection() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(10);
usage.consumeIntegers("sink-not-anonymous", v -> latch.countDown());
weld.addBeanClass(ProducingBean.class);
new MapBasedConfig().with("mp.messaging.outgoing.sink.address", "sink-not-anonymous").with("mp.messaging.outgoing.sink.connector", AmqpConnector.CONNECTOR_NAME).with("mp.messaging.outgoing.sink.host", host).with("mp.messaging.outgoing.sink.port", port).with("mp.messaging.outgoing.sink.durable", false).with("mp.messaging.outgoing.sink.tracing-enabled", false).with("amqp-username", username).with("amqp-password", password).write();
container = weld.initialize();
await().until(() -> isAmqpConnectorReady(container));
await().until(() -> isAmqpConnectorAlive(container));
assertThat(latch.await(1, TimeUnit.MINUTES)).isTrue();
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class TracingAmqpToAppNoParentTest method testFromAmqpToAppWithNoParent.
@Test
public void testFromAmqpToAppWithNoParent() {
weld.addBeanClass(MyAppReceivingData.class);
new MapBasedConfig().put("mp.messaging.incoming.stuff.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.incoming.stuff.host", host).put("mp.messaging.incoming.stuff.port", port).put("mp.messaging.incoming.stuff.address", "no-parent-stuff").put("amqp-username", username).put("amqp-password", password).write();
container = weld.initialize();
MyAppReceivingData bean = container.getBeanManager().createInstance().select(MyAppReceivingData.class).get();
await().until(() -> isAmqpConnectorReady(container));
AtomicInteger count = new AtomicInteger();
usage.produce("no-parent-stuff", 10, count::getAndIncrement);
await().until(() -> bean.list().size() >= 10);
assertThat(bean.list()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
assertThat(bean.tracing()).hasSizeGreaterThanOrEqualTo(10);
assertThat(bean.tracing()).doesNotContainNull().doesNotHaveDuplicates();
List<String> spanIds = new ArrayList<>();
for (TracingMetadata tracing : bean.tracing()) {
spanIds.add(Span.fromContext(tracing.getCurrentContext()).getSpanContext().getSpanId());
assertThat(Span.fromContextOrNull(tracing.getPreviousContext())).isNull();
}
assertThat(spanIds).doesNotContainNull().doesNotHaveDuplicates().hasSizeGreaterThanOrEqualTo(10);
for (SpanData data : testExporter.getFinishedSpanItems()) {
assertThat(data.getSpanId()).isIn(spanIds);
assertThat(data.getSpanId()).isNotEqualTo(data.getParentSpanId());
assertThat(data.getKind()).isEqualByComparingTo(SpanKind.CONSUMER);
}
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class AmqpLinkTest method doIncomingTestImpl.
private void doIncomingTestImpl(boolean durable) throws Exception {
List<DispositionRecord> dispositionsReceived = Collections.synchronizedList(new ArrayList<>());
AtomicReference<ProtonConnection> connectionRef = new AtomicReference<>();
AtomicReference<ProtonSender> senderRef = new AtomicReference<>();
server = setupMockServer(connectionRef, senderRef, dispositionsReceived, executionHolder.vertx().getDelegate());
Weld weld = new Weld();
weld.addBeanClass(MyConsumer.class);
String containerId = "myContainerId";
String subscriptionName = "mySubName";
String address = "people";
MapBasedConfig config = new MapBasedConfig().put("mp.messaging.incoming.people-in.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.incoming.people-in.container-id", containerId).put("mp.messaging.incoming.people-in.address", address).put("mp.messaging.incoming.people-in.link-name", subscriptionName).put("mp.messaging.incoming.people-in.host", "localhost").put("mp.messaging.incoming.people-in.port", server.actualPort()).put("mp.messaging.incoming.people-in.tracing-enabled", false);
if (durable) {
config.put("mp.messaging.incoming.people-in.durable", true);
}
config.write();
container = weld.initialize();
MyConsumer consumer = container.getBeanManager().createInstance().select(MyConsumer.class).get();
await().atMost(6, TimeUnit.SECONDS).until(() -> consumer.list().size() >= 3);
assertThat(consumer.list()).containsExactly("Luke", "Leia", "Han");
await().atMost(3, TimeUnit.SECONDS).until(() -> dispositionsReceived.size() >= 3);
AtomicInteger count = new AtomicInteger();
dispositionsReceived.forEach(record -> {
assertThat(record.getMessageNumber()).isEqualTo(count.get() + 1);
assertThat(record.getState()).isInstanceOf(Accepted.class);
assertThat(record.isSettled()).isTrue();
count.incrementAndGet();
});
assertThat(count.get()).isEqualTo(3);
// Verify details of the connection and link created
ProtonConnection serverConnection = connectionRef.get();
assertThat(serverConnection).isNotNull();
assertThat(serverConnection.getRemoteContainer()).isEqualTo(containerId);
ProtonSender serverSender = senderRef.get();
assertThat(serverSender).isNotNull();
assertThat(serverSender.getName()).isEqualTo(subscriptionName);
Source source = (org.apache.qpid.proton.amqp.messaging.Source) serverSender.getRemoteSource();
assertThat(source).isNotNull();
assertThat(source.getAddress()).isEqualTo(address);
if (durable) {
assertThat(source.getDurable()).isEqualTo(TerminusDurability.UNSETTLED_STATE);
assertThat(source.getExpiryPolicy()).isEqualTo(TerminusExpiryPolicy.NEVER);
} else {
assertThat(source.getDurable()).isEqualTo(TerminusDurability.NONE);
assertThat(source.getExpiryPolicy()).isNotEqualTo(TerminusExpiryPolicy.NEVER);
}
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class AmqpSinkCDIConfigTest method testConfigByCDIMissingBean.
@Test
public void testConfigByCDIMissingBean() {
Weld weld = new Weld();
weld.addBeanClass(ProducingBean.class);
new MapBasedConfig().put("mp.messaging.outgoing.sink.address", "sink").put("mp.messaging.outgoing.sink.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.outgoing.sink.host", host).put("mp.messaging.outgoing.sink.port", port).put("amqp-username", username).put("amqp-password", password).put("mp.messaging.outgoing.sink.client-options-name", "myclientoptions").put("mp.messaging.outgoing.sink.tracing-enabled", false).write();
assertThatThrownBy(() -> container = weld.initialize()).isInstanceOf(DeploymentException.class);
}
use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.
the class AmqpSinkCDIConfigTest method testConfigGlobalOptionsByCDICorrect.
@Test
public void testConfigGlobalOptionsByCDICorrect() throws InterruptedException {
Weld weld = new Weld();
CountDownLatch latch = new CountDownLatch(10);
usage.consumeIntegers("sink", v -> latch.countDown());
weld.addBeanClass(ProducingBean.class);
weld.addBeanClass(ClientConfigurationBean.class);
new MapBasedConfig().put("mp.messaging.outgoing.sink.address", "sink").put("mp.messaging.outgoing.sink.connector", AmqpConnector.CONNECTOR_NAME).put("mp.messaging.outgoing.sink.host", host).put("mp.messaging.outgoing.sink.port", port).put("mp.messaging.outgoing.sink.durable", false).put("mp.messaging.outgoing.sink.tracing-enabled", false).put("amqp-username", username).put("amqp-password", password).put("amqp-client-options-name", "myclientoptions").write();
container = weld.initialize();
assertThat(latch.await(1, TimeUnit.MINUTES)).isTrue();
}
Aggregations