Adapt to changes in Spring Framework.
Test based on JNDI injection removed, along with the context configuration xml used by the test. The classes used for mocking the JNDI context are no longer part of Spring Framework. RequiredAnnotationBeanPostProcessor removed from configuration. It's no longer provided by Spring Framework. Closes #2385
This commit is contained in:
@@ -16,20 +16,16 @@
|
||||
package org.springframework.data.jpa.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -37,7 +33,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.jpa.domain.sample.Category;
|
||||
import org.springframework.data.jpa.domain.sample.User;
|
||||
import org.springframework.data.jpa.infrastructure.HibernateTestUtils;
|
||||
@@ -45,9 +40,6 @@ import org.springframework.data.jpa.repository.JpaContext;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
import org.springframework.jndi.JndiObjectFactoryBean;
|
||||
import org.springframework.mock.jndi.ExpectedLookupTemplate;
|
||||
import org.springframework.mock.jndi.SimpleNamingContextBuilder;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -132,21 +124,6 @@ public class DefaultJpaContextIntegrationTests {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test // DATAJPA-813
|
||||
void bootstrapsDefaultJpaContextInSpringContainerWithEntityManagerFromJndi() throws Exception {
|
||||
|
||||
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
|
||||
builder.bind("some/EMF", createEntityManagerFactory("spring-data-jpa"));
|
||||
builder.bind("some/other/Component", new Object());
|
||||
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("config/jpa-context-with-jndi.xml");
|
||||
ApplicationComponent component = context.getBean(ApplicationComponent.class);
|
||||
|
||||
assertThat(component.context).isNotNull();
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@EnableJpaRepositories
|
||||
@ComponentScan(includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = ApplicationComponent.class),
|
||||
useDefaultFilters = false)
|
||||
@@ -157,19 +134,6 @@ public class DefaultJpaContextIntegrationTests {
|
||||
return createEntityManagerFactoryBean("spring-data-jpa");
|
||||
}
|
||||
|
||||
// A non-EntityManagerFactory JNDI object to make sure the detection doesn't include it
|
||||
// see DATAJPA-956
|
||||
@Bean
|
||||
public JndiObjectFactoryBean jndiObject() throws NamingException {
|
||||
|
||||
JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
|
||||
|
||||
bean.setJndiName("some/DataSource");
|
||||
bean.setJndiTemplate(new ExpectedLookupTemplate("some/DataSource", mock(DataSource.class)));
|
||||
bean.setExpectedType(DataSource.class);
|
||||
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
|
||||
@@ -39,9 +39,6 @@
|
||||
<!-- Adds transaparent exception translation to the DAOs -->
|
||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
|
||||
|
||||
<!-- Adds dependency checks for setters annotated with @Required -->
|
||||
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" />
|
||||
|
||||
<bean id="expressionEvaluationContextProvider" class="org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider" autowire="constructor" />
|
||||
|
||||
<bean class="org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor" />
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jee https://www.springframework.org/schema/jee/spring-jee.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/jpa https://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
|
||||
|
||||
<jpa:repositories base-package="org.springframework.data.jpa.repository.support" />
|
||||
|
||||
<jee:jndi-lookup id="entityManagerFactory"
|
||||
jndi-name="some/EMF"
|
||||
expected-type="jakarta.persistence.EntityManagerFactory" />
|
||||
|
||||
<jee:jndi-lookup id="someOtherJndiBean"
|
||||
jndi-name="some/other/Component" />
|
||||
|
||||
<bean class="org.springframework.data.jpa.repository.support.DefaultJpaContextIntegrationTests$ApplicationComponent" autowire="constructor" />
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user