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);
}
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);
}
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);
}
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);
});
}
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);
}
Aggregations