Java Code Examples for org.jboss.weld.environment.se.Weld#addBeanClass()
The following examples show how to use
org.jboss.weld.environment.se.Weld#addBeanClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsTestBase.java From smallrye-reactive-messaging with Apache License 2.0 | 7 votes |
protected Weld initWithoutConnectionFactory() { weld = new Weld(); // SmallRye config ConfigExtension extension = new ConfigExtension(); weld.addExtension(extension); weld.addBeanClass(MediatorFactory.class); weld.addBeanClass(MediatorManager.class); weld.addBeanClass(InternalChannelRegistry.class); weld.addBeanClass(ConfiguredChannelFactory.class); weld.addBeanClass(ChannelProducer.class); weld.addBeanClass(ExecutionHolder.class); weld.addBeanClass(WorkerPoolRegistry.class); weld.addExtension(new ReactiveMessagingExtension()); weld.addBeanClass(JmsConnector.class); weld.disableDiscovery(); return weld; }
Example 2
Source File: AmqpSinkTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Test(expected = DeploymentException.class) public void testConfigByCDIIncorrectBean() { Weld weld = new Weld(); 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", true) .put("amqp-username", username) .put("amqp-password", password) .put("mp.messaging.outgoing.sink.client-options-name", "dummyoptionsnonexistent") .write(); container = weld.initialize(); }
Example 3
Source File: AmqpSinkTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Test public void testABeanProducingMessagesSentToAMQPWithOutboundMetadata() throws InterruptedException { Weld weld = new Weld(); CountDownLatch latch = new CountDownLatch(10); usage.consumeIntegers("sink", v -> latch.countDown()); weld.addBeanClass(ProducingBeanUsingOutboundMetadata.class); new MapBasedConfig() .put("mp.messaging.outgoing.sink.address", "not-used") .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", true) .put("amqp-username", username) .put("amqp-password", password) .write(); container = weld.initialize(); assertThat(latch.await(1, TimeUnit.MINUTES)).isTrue(); }
Example 4
Source File: AmqpSinkTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Test(expected = DeploymentException.class) @Ignore("Failing on CI - to be investigated") public void testConfigGlobalOptionsByCDIIncorrectBean() { Weld weld = new Weld(); 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", true) .put("amqp-username", username) .put("amqp-password", password) .put("amqp-client-options-name", "dummyoptionsnonexistent") .write(); container = weld.initialize(); }
Example 5
Source File: AmqpSourceTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Test(expected = DeploymentException.class) public void testConfigByCDIIncorrectBean() { Weld weld = new Weld(); weld.addBeanClass(ConsumptionBean.class); weld.addBeanClass(ClientConfigurationBean.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("amqp-username", username) .put("amqp-password", password) .put("mp.messaging.incoming.data.client-options-name", "dummyoptionsnonexistent") .write(); container = weld.initialize(); }
Example 6
Source File: KafkaTestBase.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
public static Weld baseWeld() { Weld weld = new Weld(); // SmallRye config ConfigExtension extension = new ConfigExtension(); weld.addExtension(extension); weld.addBeanClass(MediatorFactory.class); weld.addBeanClass(MediatorManager.class); weld.addBeanClass(InternalChannelRegistry.class); weld.addBeanClass(ConfiguredChannelFactory.class); weld.addBeanClass(ChannelProducer.class); weld.addBeanClass(ExecutionHolder.class); weld.addBeanClass(WorkerPoolRegistry.class); weld.addExtension(new ReactiveMessagingExtension()); weld.addBeanClass(KafkaConnector.class); weld.disableDiscovery(); return weld; }
Example 7
Source File: PubSubTestBase.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
static Weld baseWeld() { final Weld weld = new Weld(); weld.addExtension(new ConfigExtension()); weld.addBeanClass(MediatorFactory.class); weld.addBeanClass(MediatorManager.class); weld.addBeanClass(InternalChannelRegistry.class); weld.addBeanClass(ConfiguredChannelFactory.class); weld.addBeanClass(ChannelProducer.class); weld.addBeanClass(ExecutionHolder.class); weld.addBeanClass(WorkerPoolRegistry.class); weld.addExtension(new ReactiveMessagingExtension()); weld.addBeanClass(PubSubManager.class); weld.addBeanClass(PubSubConnector.class); weld.disableDiscovery(); return weld; }
Example 8
Source File: DynamicMqttTopicSourceTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testWithTwoPlusInExpression() { Weld weld = baseWeld(getConfig("/+/hello/+/greeting")); weld.addBeanClass(DynamicTopicApp.class); container = weld.initialize(); awaitAndVerify(); }
Example 9
Source File: DynamicMqttTopicSourceTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testWithPlusInExpression() { Weld weld = baseWeld(getConfig("/app/hello/+/greeting")); weld.addBeanClass(DynamicTopicApp.class); container = weld.initialize(); awaitAndVerify(); }
Example 10
Source File: FooWeldJunitEnricher.java From weld-junit with Apache License 2.0 | 5 votes |
@Override public void enrich(Object testInstance, ExtensionContext context, Weld weld, Builder weldInitiatorBuilder) { if (WeldJunitEnricherTest.class.equals(testInstance.getClass()) || WeldJunitEnricherDisabledTest.class.equals(testInstance.getClass())) { weld.addBeanClass(Foo.class); } }
Example 11
Source File: MultipleTopicsConsumptionTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testWithoutClientId() { Clients.clear(); Weld weld = baseWeld(getConfig(null)); weld.addBeanClass(Consumers.class); container = weld.initialize(); Consumers bean = container.getBeanManager().createInstance().select(Consumers.class).get(); await().until(() -> this.container.select(MediatorManager.class).get().isInitialized()); await() .until(() -> this.container.select(MqttConnector.class, ConnectorLiteral.of("smallrye-mqtt")).get().isReady()); assertThat(bean.prices()).isEmpty(); assertThat(bean.products()).isEmpty(); AtomicInteger counter1 = new AtomicInteger(); AtomicInteger counter2 = new AtomicInteger(); new Thread(() -> usage.produceIntegers("prices", 10, null, counter1::getAndIncrement)) .start(); new Thread(() -> usage.produceIntegers("products", 10, null, counter2::getAndIncrement)) .start(); await().atMost(2, TimeUnit.MINUTES).until(() -> bean.products().size() >= 10); await().atMost(2, TimeUnit.MINUTES).until(() -> bean.prices().size() >= 10); }
Example 12
Source File: DocumentationTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testKafkaPriceMessageProducer() { KafkaUsage usage = new KafkaUsage(); List<Double> list = new CopyOnWriteArrayList<>(); usage.consumeDoubles("prices", 50, 60, TimeUnit.SECONDS, null, (s, v) -> list.add(v)); MapBasedConfig config = getProducerConfiguration(); Weld weld = baseWeld(); addConfig(config); weld.addBeanClass(KafkaPriceMessageProducer.class); weld.disableDiscovery(); container = weld.initialize(); await().until(() -> list.size() >= 50); }
Example 13
Source File: DynamicMqttTopicSourceTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testWithDash() { Weld weld = baseWeld(getConfig("#")); weld.addBeanClass(DynamicTopicApp.class); container = weld.initialize(); awaitAndVerify(); }
Example 14
Source File: WeldInitiator.java From weld-junit with Apache License 2.0 | 5 votes |
/** * Create a builder instance. * * @param weld * @return a builder instance * @see #of(Class...) */ public static Builder from(Class<?>... beanClasses) { Weld weld = createWeld(); for (Class<?> clazz : beanClasses) { if (Extension.class.isAssignableFrom(clazz)) { weld.addExtensions((Class<? extends Extension>) clazz); } else { weld.addBeanClass(clazz); } } return from(weld); }
Example 15
Source File: DocumentationTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testKafkaPriceProducer() { KafkaUsage usage = new KafkaUsage(); List<Double> list = new CopyOnWriteArrayList<>(); usage.consumeDoubles("prices", 50, 60, TimeUnit.SECONDS, null, (s, v) -> list.add(v)); MapBasedConfig config = getProducerConfiguration(); Weld weld = baseWeld(); addConfig(config); weld.addBeanClass(KafkaPriceProducer.class); weld.disableDiscovery(); container = weld.initialize(); await().until(() -> list.size() >= 50); }
Example 16
Source File: MetadataPropagationTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
private <T> void deploy(MapBasedConfig config, Class<T> clazz) { if (config != null) { config.write(); } else { MapBasedConfig.clear(); } Weld weld = baseWeld(); weld.addBeanClass(clazz); container = weld.initialize(); }
Example 17
Source File: EventBusSinkTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Test public void testABeanProducingMessagesSentToEventBus() { Weld weld = baseWeld(); weld.addBeanClass(ProducingBean.class); weld.addBeanClass(VertxProducer.class); addConfig(getConfig()); container = weld.initialize(); ProducingBean bean = container.getBeanManager().createInstance().select(ProducingBean.class).get(); await().until(() -> bean.messages().size() == 10); assertThat(bean.messages().size()).isEqualTo(10); }
Example 18
Source File: WeldInitiator.java From weld-junit with Apache License 2.0 | 5 votes |
/** * Create a builder instance. * * @param beanClasses * @return a builder instance * @see #of(Class...) */ @SuppressWarnings("unchecked") public static Builder from(Class<?>... beanClasses) { Weld weld = createWeld(); for (Class<?> clazz : beanClasses) { if (Extension.class.isAssignableFrom(clazz)) { weld.addExtensions((Class<? extends Extension>) clazz); } else { weld.addBeanClass(clazz); } } return from(weld); }
Example 19
Source File: SecureMqttSourceTest.java From smallrye-reactive-messaging with Apache License 2.0 | 4 votes |
private ConsumptionBean deploy() { Weld weld = MqttTestBase.baseWeld(getConfig()); weld.addBeanClass(ConsumptionBean.class); container = weld.initialize(); return container.getBeanManager().createInstance().select(ConsumptionBean.class).get(); }
Example 20
Source File: WeldJunit5AutoExtension.java From weld-junit with Apache License 2.0 | 3 votes |
@Override protected void weldInit(Object testInstance, ExtensionContext context, Weld weld, WeldInitiator.Builder weldInitiatorBuilder) { Class<?> testClass = testInstance.getClass(); ClassScanning.scanForRequiredBeanClass(testClass, weld, getExplicitInjectionInfoFromStore(context)); weld.addBeanClass(testClass); weld.addExtension(new TestInstanceInjectionExtension(testClass, testInstance)); AnnotationSupport.findRepeatableAnnotations(testClass, ActivateScopes.class) .forEach(ann -> weldInitiatorBuilder.activate(ann.value())); }