Streamline XML namespace support towards unversioned schemas

This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
This commit is contained in:
Juergen Hoeller
2016-07-05 20:50:00 +02:00
parent 12d373659a
commit bc2c22d51e
217 changed files with 413 additions and 41094 deletions

View File

@@ -113,14 +113,8 @@ public class XmlBeanFactoryTests {
private static final ClassPathResource NO_SUCH_FACTORY_METHOD_CONTEXT = classPathResource("-noSuchFactoryMethod.xml");
private static final ClassPathResource RECURSIVE_IMPORT_CONTEXT = classPathResource("-recursiveImport.xml");
private static final ClassPathResource RESOURCE_CONTEXT = classPathResource("-resource.xml");
private static final ClassPathResource SATISFIED_ALL_DEP_CONTEXT = classPathResource("-satisfiedAllDepCheck.xml");
private static final ClassPathResource SATISFIED_OBJECT_DEP_CONTEXT = classPathResource("-satisfiedObjectDepCheck.xml");
private static final ClassPathResource SATISFIED_SIMPLE_DEP_CONTEXT = classPathResource("-satisfiedSimpleDepCheck.xml");
private static final ClassPathResource TEST_WITH_DUP_NAMES_CONTEXT = classPathResource("-testWithDuplicateNames.xml");
private static final ClassPathResource TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT = classPathResource("-testWithDuplicateNameInAlias.xml");
private static final ClassPathResource UNSATISFIED_ALL_DEP_CONTEXT = classPathResource("-unsatisfiedAllDepCheckMissingObjects.xml");
private static final ClassPathResource UNSATISFIED_OBJECT_DEP_CONTEXT = classPathResource("-unsatisfiedObjectDepCheck.xml");
private static final ClassPathResource UNSATISFIED_SIMPLE_DEP_CONTEXT = classPathResource("-unsatisfiedSimpleDepCheck.xml");
private static final ClassPathResource REFTYPES_CONTEXT = classPathResource("-reftypes.xml");
private static final ClassPathResource DEFAULT_LAZY_CONTEXT = classPathResource("-defaultLazyInit.xml");
private static final ClassPathResource DEFAULT_AUTOWIRE_CONTEXT = classPathResource("-defaultAutowire.xml");
@@ -776,54 +770,6 @@ public class XmlBeanFactoryTests {
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT);
}
@Test(expected = UnsatisfiedDependencyException.class)
public void unsatisfiedObjectDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_OBJECT_DEP_CONTEXT);
xbf.getBean("a", DependenciesBean.class);
}
@Test(expected = UnsatisfiedDependencyException.class)
public void unsatisfiedSimpleDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_SIMPLE_DEP_CONTEXT);
xbf.getBean("a", DependenciesBean.class);
}
@Test
public void testSatisfiedObjectDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_OBJECT_DEP_CONTEXT);
DependenciesBean a = (DependenciesBean) xbf.getBean("a");
assertNotNull(a.getSpouse());
assertEquals(xbf, a.getBeanFactory());
}
@Test
public void testSatisfiedSimpleDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_SIMPLE_DEP_CONTEXT);
DependenciesBean a = (DependenciesBean) xbf.getBean("a");
assertEquals(a.getAge(), 33);
}
@Test(expected = UnsatisfiedDependencyException.class)
public void unsatisfiedAllDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(UNSATISFIED_ALL_DEP_CONTEXT);
xbf.getBean("a", DependenciesBean.class);
}
@Test
public void testSatisfiedAllDependencyCheck() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(SATISFIED_ALL_DEP_CONTEXT);
DependenciesBean a = (DependenciesBean) xbf.getBean("a");
assertEquals(a.getAge(), 33);
assertNotNull(a.getName());
assertNotNull(a.getSpouse());
}
@Test
public void testAutowire() throws Exception {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
@@ -909,13 +855,6 @@ public class XmlBeanFactoryTests {
// should have been autowired
assertNotNull(rod2.getSpouse());
assertTrue(rod2.getSpouse().getName().equals("Kerry"));
try {
xbf.getBean("rod3", DependenciesBean.class);
fail("Must have thrown UnsatisfiedDependencyException");
}
catch (UnsatisfiedDependencyException expected) {
}
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,32 +152,6 @@ public class ComponentScanParserBeanDefinitionDefaultsTests {
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
}
@Test
public void testDependencyCheckAll() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultDependencyCheckAllTests.xml");
try {
context.refresh();
fail("expected exception due to dependency check");
}
catch (UnsatisfiedDependencyException ex) {
// expected
}
}
@Test
public void testDependencyCheckObjectsWithAutowireByName() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultDependencyCheckObjectsWithAutowireByNameTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("constructor dependency should not have been autowired", bean.getConstructorDependency());
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency1());
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency2());
}
@Test
public void testDefaultInitAndDestroyMethodsNotDefined() {
GenericApplicationContext context = new GenericApplicationContext();

View File

@@ -541,15 +541,6 @@ public class GroovyScriptFactoryTests {
ContextScriptBean bean2 = (ContextScriptBean) ctx.getBean("bean2");
assertEquals(tb, bean2.getTestBean());
assertEquals(ctx, bean2.getApplicationContext());
try {
ctx.getBean("bean3");
fail("Should have thrown BeanCreationException");
}
catch (BeanCreationException ex) {
// expected
assertTrue(ex.contains(UnsatisfiedDependencyException.class));
}
}
@Test