Search in sources :

Example 1 with NoDefinitionInSpringContextTestBean

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();
}
Also used : BeanContainer(org.hibernate.resource.beans.container.spi.BeanContainer) NoDefinitionInSpringContextTestBean(org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean) Test(org.junit.jupiter.api.Test)

Example 2 with NoDefinitionInSpringContextTestBean

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();
}
Also used : BeanContainer(org.hibernate.resource.beans.container.spi.BeanContainer) NoDefinitionInSpringContextTestBean(org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean) Test(org.junit.jupiter.api.Test)

Example 3 with NoDefinitionInSpringContextTestBean

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();
}
Also used : BeanContainer(org.hibernate.resource.beans.container.spi.BeanContainer) NoDefinitionInSpringContextTestBean(org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean) Test(org.junit.jupiter.api.Test)

Example 4 with NoDefinitionInSpringContextTestBean

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();
}
Also used : BeanContainer(org.hibernate.resource.beans.container.spi.BeanContainer) NoDefinitionInSpringContextTestBean(org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean) Test(org.junit.jupiter.api.Test)

Aggregations

BeanContainer (org.hibernate.resource.beans.container.spi.BeanContainer)4 Test (org.junit.jupiter.api.Test)4 NoDefinitionInSpringContextTestBean (org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean)4