DATAJPA-127 - Setup hybrid Spring 3.0.6 / 3.1 build.

Removed deprecated usage of XmlBeanFactory in tests.
This commit is contained in:
Oliver Gierke
2011-11-28 16:17:43 +01:00
parent 5ffbb4f1d1
commit 45bcdb60ac
6 changed files with 45 additions and 16 deletions

View File

@@ -22,8 +22,8 @@ import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
/**
@@ -33,13 +33,15 @@ import org.springframework.core.io.ClassPathResource;
*/
public class AuditingBeanFactoryPostProcessorUnitTests {
ConfigurableListableBeanFactory beanFactory;
DefaultListableBeanFactory beanFactory;
AuditingBeanFactoryPostProcessor processor;
@Before
public void setUp() {
beanFactory = new XmlBeanFactory(new ClassPathResource("auditing/" + getConfigFile()));
beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(new ClassPathResource("auditing/" + getConfigFile()));
processor = new AuditingBeanFactoryPostProcessor();
}
@@ -53,7 +55,6 @@ public class AuditingBeanFactoryPostProcessorUnitTests {
public void testname() throws Exception {
processor.postProcessBeanFactory(beanFactory);
BeanDefinition definition = beanFactory.getBeanDefinition("entityManagerFactory");
assertTrue(Arrays.asList(definition.getDependsOn()).contains(

View File

@@ -21,7 +21,8 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
/**
@@ -45,7 +46,10 @@ public class AuditingBeanDefinitionParserTests {
private void assertSetDatesIsSetTo(String configFile, String value) {
XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource(configFile));
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource(configFile));
BeanDefinition definition = factory
.getBeanDefinition(AuditingBeanDefinitionParser.AUDITING_ENTITY_LISTENER_CLASS_NAME);
PropertyValue propertyValue = definition.getPropertyValues().getPropertyValue("dateTimeForNow");

View File

@@ -21,7 +21,8 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
/**
@@ -34,8 +35,9 @@ public class JpaRepositoryConfigDefinitionParserTests {
@Test
public void getsTransactionManagerSet() throws Exception {
XmlBeanFactory factory = new XmlBeanFactory(
new ClassPathResource("multiple-entity-manager-integration-context.xml"));
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource("multiple-entity-manager-integration-context.xml"));
BeanDefinition definition = factory.getBeanDefinition("auditableUserRepository");
assertThat(definition, is(notNullValue()));

View File

@@ -23,7 +23,8 @@ import javax.persistence.EntityManagerFactory;
import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanReference;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
/**
@@ -36,7 +37,9 @@ public class EntityManagerFactoryRefUnitTests {
@Test
public void repositoriesGetTheSecondEntityManagerFactoryInjected2() {
XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("multiple-entity-manager-context.xml"));
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource("multiple-entity-manager-context.xml"));
BeanDefinition bean = factory.getBeanDefinition("userRepository");
Object value = getPropertyValue(bean, "entityManager");