use of org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean in project spring-framework by spring-projects.
the class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests method testCanRetrieveFallbackBeanByTypeWithNativeOptions.
@Test
public void testCanRetrieveFallbackBeanByTypeWithNativeOptions() {
BeanContainer beanContainer = getBeanContainer();
assertThat(beanContainer).isNotNull();
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean(NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer);
assertThat(fallbackProducer.currentUnnamedInstantiationCount()).isEqualTo(1);
assertThat(fallbackProducer.currentNamedInstantiationCount()).isEqualTo(0);
assertThat(bean).isNotNull();
NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance();
assertThat(instance).isNotNull();
assertThat(instance.getSource()).isEqualTo(BeanSource.FALLBACK);
assertThat(instance.getApplicationContext()).isNull();
}
use of org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean in project spring-framework by spring-projects.
the class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests method testCanRetrieveFallbackBeanByNameWithJpaCompliantOptions.
@Test
public void testCanRetrieveFallbackBeanByNameWithJpaCompliantOptions() {
BeanContainer beanContainer = getBeanContainer();
assertThat(beanContainer).isNotNull();
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean("some name", NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer);
assertThat(fallbackProducer.currentUnnamedInstantiationCount()).isEqualTo(0);
assertThat(fallbackProducer.currentNamedInstantiationCount()).isEqualTo(1);
assertThat(bean).isNotNull();
NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance();
assertThat(instance).isNotNull();
assertThat(instance.getSource()).isEqualTo(BeanSource.FALLBACK);
assertThat(instance.getName()).isEqualTo("some name");
assertThat(instance.getApplicationContext()).isNull();
}
use of org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean in project spring-framework by spring-projects.
the class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests method testCanRetrieveFallbackBeanByNameWithNativeOptions.
@Test
public void testCanRetrieveFallbackBeanByNameWithNativeOptions() {
BeanContainer beanContainer = getBeanContainer();
assertThat(beanContainer).isNotNull();
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean("some name", NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer);
assertThat(fallbackProducer.currentUnnamedInstantiationCount()).isEqualTo(0);
assertThat(fallbackProducer.currentNamedInstantiationCount()).isEqualTo(1);
assertThat(bean).isNotNull();
NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance();
assertThat(instance).isNotNull();
assertThat(instance.getSource()).isEqualTo(BeanSource.FALLBACK);
assertThat(instance.getName()).isEqualTo("some name");
assertThat(instance.getApplicationContext()).isNull();
}
use of org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean in project spring-framework by spring-projects.
the class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests method testCanRetrieveFallbackBeanByTypeWithJpaCompliantOptions.
@Test
public void testCanRetrieveFallbackBeanByTypeWithJpaCompliantOptions() {
BeanContainer beanContainer = getBeanContainer();
assertThat(beanContainer).isNotNull();
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean(NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer);
assertThat(fallbackProducer.currentUnnamedInstantiationCount()).isEqualTo(1);
assertThat(fallbackProducer.currentNamedInstantiationCount()).isEqualTo(0);
assertThat(bean).isNotNull();
NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance();
assertThat(instance).isNotNull();
assertThat(instance.getSource()).isEqualTo(BeanSource.FALLBACK);
assertThat(instance.getApplicationContext()).isNull();
}
Aggregations