use of org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl in project hibernate-orm by hibernate.
the class ExtendedMixedAccessTest method testExtendedMixedAccess.
@Test
public void testExtendedMixedAccess() {
final Helper.TestingExtendedBeanManager extendedBeanManager = Helper.createExtendedBeanManager();
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.HBM2DDL_AUTO, Action.CREATE_DROP).applySetting(AvailableSettings.CDI_BEAN_MANAGER, extendedBeanManager).build();
final BeanContainer beanContainer = ssr.getService(ManagedBeanRegistry.class).getBeanContainer();
assertThat(beanContainer, instanceOf(CdiBeanContainerExtendedAccessImpl.class));
try (final SeContainer cdiContainer = Helper.createSeContainer()) {
final BeanManager beanManager = cdiContainer.getBeanManager();
extendedBeanManager.notifyListenerReady(beanManager);
assertThat(beanManager, sameInstance(((CdiBeanContainerExtendedAccessImpl) beanContainer).getUsableBeanManager()));
final ContainedBean<HostedBean> hostedBean = beanContainer.getBean(HostedBean.class, this, FallbackBeanInstanceProducer.INSTANCE);
assertThat(hostedBean, notNullValue());
assertThat(hostedBean.getBeanInstance(), notNullValue());
assertThat(hostedBean.getBeanInstance().getInjectedHostedBean(), notNullValue());
final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean(NonHostedBean.class, this, FallbackBeanInstanceProducer.INSTANCE);
assertThat(nonHostedBean, notNullValue());
assertThat(nonHostedBean.getBeanInstance(), notNullValue());
extendedBeanManager.notifyListenerShuttingDown(beanManager);
}
}
Aggregations