Browse Source

Consistent local vs external resolution of https schema references

Closes gh-22504
pull/22571/head
Juergen Hoeller 7 years ago
parent
commit
2b5434e46c
  1. 3
      spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java
  3. 4
      spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java
  4. 27
      spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java
  5. 82
      spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
  6. 20
      spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
  7. 2
      spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
  8. 4
      spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml

3
spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.beans.factory.xml;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.logging.Log;
@ -76,7 +77,7 @@ public class BeansDtdResolver implements EntityResolver { @@ -76,7 +77,7 @@ public class BeansDtdResolver implements EntityResolver {
}
return source;
}
catch (IOException ex) {
catch (FileNotFoundException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Could not resolve beans DTD [" + systemId + "]: not found in classpath", ex);
}

4
spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
@ -86,6 +86,8 @@ public class DelegatingEntityResolver implements EntityResolver { @@ -86,6 +86,8 @@ public class DelegatingEntityResolver implements EntityResolver {
return this.schemaResolver.resolveEntity(publicId, systemId);
}
}
// Fall back to the parser's default behavior.
return null;
}

4
spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java

@ -110,6 +110,10 @@ public class PluggableSchemaResolver implements EntityResolver { @@ -110,6 +110,10 @@ public class PluggableSchemaResolver implements EntityResolver {
if (systemId != null) {
String resourceLocation = getSchemaMappings().get(systemId);
if (resourceLocation == null && systemId.startsWith("https:")) {
// Retrieve canonical http schema mapping even for https declaration
resourceLocation = getSchemaMappings().get("http:" + systemId.substring(6));
}
if (resourceLocation != null) {
Resource resource = new ClassPathResource(resourceLocation, this.classLoader);
try {

27
spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
@ -30,9 +30,9 @@ import org.springframework.core.io.Resource; @@ -30,9 +30,9 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
/**
* EntityResolver implementation that tries to resolve entity references
* {@code EntityResolver} implementation that tries to resolve entity references
* through a {@link org.springframework.core.io.ResourceLoader} (usually,
* relative to the resource base of an ApplicationContext), if applicable.
* relative to the resource base of an {@code ApplicationContext}), if applicable.
* Extends {@link DelegatingEntityResolver} to also provide DTD and XSD lookup.
*
* <p>Allows to use standard XML entities to include XML snippets into an
@ -72,6 +72,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver { @@ -72,6 +72,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
InputSource source = super.resolveEntity(publicId, systemId);
if (source == null && systemId != null) {
String resourcePath = null;
try {
@ -103,7 +104,27 @@ public class ResourceEntityResolver extends DelegatingEntityResolver { @@ -103,7 +104,27 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
logger.debug("Found XML entity [" + systemId + "]: " + resource);
}
}
else if (systemId.endsWith(DTD_SUFFIX) || systemId.endsWith(XSD_SUFFIX)) {
// External dtd/xsd lookup via https even for canonical http declaration
String url = systemId;
if (url.startsWith("http:")) {
url = "https:" + url.substring(5);
}
try {
source = new InputSource(new URL(url).openStream());
source.setPublicId(publicId);
source.setSystemId(systemId);
}
catch (IOException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Could not resolve XML entity [" + systemId + "] through URL [" + url + "]", ex);
}
// Fall back to the parser's default behavior.
source = null;
}
}
}
return source;
}

82
spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -129,16 +129,16 @@ public class XmlBeanFactoryTests { @@ -129,16 +129,16 @@ public class XmlBeanFactoryTests {
return new ClassPathResource(CLASSNAME + suffix, CLASS);
}
/* SPR-2368 */
@Test
public void testCollectionsReferredToAsRefLocals() throws Exception {
@Test // SPR-2368
public void testCollectionsReferredToAsRefLocals() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(COLLECTIONS_XSD_CONTEXT);
factory.preInstantiateSingletons();
}
@Test
public void testRefToSeparatePrototypeInstances() throws Exception {
public void testRefToSeparatePrototypeInstances() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@ -157,7 +157,7 @@ public class XmlBeanFactoryTests { @@ -157,7 +157,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testRefToSingleton() throws Exception {
public void testRefToSingleton() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
@ -313,7 +313,7 @@ public class XmlBeanFactoryTests { @@ -313,7 +313,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceFromParentFactoryPrototype() throws Exception {
public void testInheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -329,7 +329,7 @@ public class XmlBeanFactoryTests { @@ -329,7 +329,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceWithDifferentClass() throws Exception {
public void testInheritanceWithDifferentClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -344,7 +344,7 @@ public class XmlBeanFactoryTests { @@ -344,7 +344,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInheritanceWithClass() throws Exception {
public void testInheritanceWithClass() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -359,7 +359,7 @@ public class XmlBeanFactoryTests { @@ -359,7 +359,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrototypeInheritanceFromParentFactoryPrototype() throws Exception {
public void testPrototypeInheritanceFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -379,7 +379,7 @@ public class XmlBeanFactoryTests { @@ -379,7 +379,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testPrototypeInheritanceFromParentFactorySingleton() throws Exception {
public void testPrototypeInheritanceFromParentFactorySingleton() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -439,7 +439,7 @@ public class XmlBeanFactoryTests { @@ -439,7 +439,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDependenciesMaterializeThis() throws Exception {
public void testDependenciesMaterializeThis() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEP_MATERIALIZE_CONTEXT);
@ -458,7 +458,7 @@ public class XmlBeanFactoryTests { @@ -458,7 +458,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testChildOverridesParentBean() throws Exception {
public void testChildOverridesParentBean() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -477,7 +477,7 @@ public class XmlBeanFactoryTests { @@ -477,7 +477,7 @@ public class XmlBeanFactoryTests {
* If a singleton does this the factory will fail to load.
*/
@Test
public void testBogusParentageFromParentFactory() throws Exception {
public void testBogusParentageFromParentFactory() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -488,7 +488,7 @@ public class XmlBeanFactoryTests { @@ -488,7 +488,7 @@ public class XmlBeanFactoryTests {
}
catch (BeanDefinitionStoreException ex) {
// check exception message contains the name
assertTrue(ex.getMessage().indexOf("bogusParent") != -1);
assertTrue(ex.getMessage().contains("bogusParent"));
assertTrue(ex.getCause() instanceof NoSuchBeanDefinitionException);
}
}
@ -499,7 +499,7 @@ public class XmlBeanFactoryTests { @@ -499,7 +499,7 @@ public class XmlBeanFactoryTests {
* instances even if derived from a prototype
*/
@Test
public void testSingletonInheritsFromParentFactoryPrototype() throws Exception {
public void testSingletonInheritsFromParentFactoryPrototype() {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
@ -664,7 +664,7 @@ public class XmlBeanFactoryTests { @@ -664,7 +664,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testInitMethodIsInvoked() throws Exception {
public void testInitMethodIsInvoked() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
DoubleInitializer in = (DoubleInitializer) xbf.getBean("init-method1");
@ -684,14 +684,14 @@ public class XmlBeanFactoryTests { @@ -684,14 +684,14 @@ public class XmlBeanFactoryTests {
fail();
}
catch (BeanCreationException ex) {
assertTrue(ex.getResourceDescription().indexOf("initializers.xml") != -1);
assertTrue(ex.getResourceDescription().contains("initializers.xml"));
assertEquals("init-method2", ex.getBeanName());
assertTrue(ex.getCause() instanceof IOException);
}
}
@Test
public void testNoSuchInitMethod() throws Exception {
public void testNoSuchInitMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
try {
@ -700,9 +700,9 @@ public class XmlBeanFactoryTests { @@ -700,9 +700,9 @@ public class XmlBeanFactoryTests {
}
catch (FatalBeanException ex) {
// check message is helpful
assertTrue(ex.getMessage().indexOf("initializers.xml") != -1);
assertTrue(ex.getMessage().indexOf("init-method3") != -1);
assertTrue(ex.getMessage().indexOf("init") != -1);
assertTrue(ex.getMessage().contains("initializers.xml"));
assertTrue(ex.getMessage().contains("init-method3"));
assertTrue(ex.getMessage().contains("init"));
}
}
@ -710,7 +710,7 @@ public class XmlBeanFactoryTests { @@ -710,7 +710,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is called first.
*/
@Test
public void testInitializingBeanAndInitMethod() throws Exception {
public void testInitializingBeanAndInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@ -731,7 +731,7 @@ public class XmlBeanFactoryTests { @@ -731,7 +731,7 @@ public class XmlBeanFactoryTests {
* Check that InitializingBean method is not called twice.
*/
@Test
public void testInitializingBeanAndSameInitMethod() throws Exception {
public void testInitializingBeanAndSameInitMethod() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT);
@ -749,7 +749,7 @@ public class XmlBeanFactoryTests { @@ -749,7 +749,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testDefaultLazyInit() throws Exception {
public void testDefaultLazyInit() {
InitAndIB.constructed = false;
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_LAZY_CONTEXT);
@ -765,13 +765,13 @@ public class XmlBeanFactoryTests { @@ -765,13 +765,13 @@ public class XmlBeanFactoryTests {
}
@Test(expected = BeanDefinitionStoreException.class)
public void noSuchXmlFile() throws Exception {
public void noSuchXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(MISSING_CONTEXT);
}
@Test(expected = BeanDefinitionStoreException.class)
public void invalidXmlFile() throws Exception {
public void invalidXmlFile() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INVALID_CONTEXT);
}
@ -825,7 +825,7 @@ public class XmlBeanFactoryTests { @@ -825,7 +825,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowire() throws Exception {
public void testAutowire() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
TestBean spouse = new TestBean("kerry", 0);
@ -834,7 +834,7 @@ public class XmlBeanFactoryTests { @@ -834,7 +834,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireWithParent() throws Exception {
public void testAutowireWithParent() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(AUTOWIRE_CONTEXT);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
@ -847,7 +847,7 @@ public class XmlBeanFactoryTests { @@ -847,7 +847,7 @@ public class XmlBeanFactoryTests {
doTestAutowire(xbf);
}
private void doTestAutowire(DefaultListableBeanFactory xbf) throws Exception {
private void doTestAutowire(DefaultListableBeanFactory xbf) {
DependenciesBean rod1 = (DependenciesBean) xbf.getBean("rod1");
TestBean kerry = (TestBean) xbf.getBean("spouse");
// should have been autowired
@ -896,7 +896,7 @@ public class XmlBeanFactoryTests { @@ -896,7 +896,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireWithDefault() throws Exception {
public void testAutowireWithDefault() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(DEFAULT_AUTOWIRE_CONTEXT);
@ -919,7 +919,7 @@ public class XmlBeanFactoryTests { @@ -919,7 +919,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireByConstructor() throws Exception {
public void testAutowireByConstructor() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
ConstructorDependenciesBean rod1 = (ConstructorDependenciesBean) xbf.getBean("rod1");
@ -957,7 +957,7 @@ public class XmlBeanFactoryTests { @@ -957,7 +957,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testAutowireByConstructorWithSimpleValues() throws Exception {
public void testAutowireByConstructorWithSimpleValues() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
@ -995,7 +995,7 @@ public class XmlBeanFactoryTests { @@ -995,7 +995,7 @@ public class XmlBeanFactoryTests {
xbf.getBean("rod2Accessor");
}
catch (BeanCreationException ex) {
assertTrue(ex.toString().indexOf("touchy") != -1);
assertTrue(ex.toString().contains("touchy"));
ex.printStackTrace();
assertNull(ex.getRelatedCauses());
}
@ -1075,14 +1075,14 @@ public class XmlBeanFactoryTests { @@ -1075,14 +1075,14 @@ public class XmlBeanFactoryTests {
}
@Test(expected = BeanCreationException.class)
public void throwsExceptionOnTooManyArguments() throws Exception {
public void throwsExceptionOnTooManyArguments() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
xbf.getBean("rod7", ConstructorDependenciesBean.class);
}
@Test(expected = UnsatisfiedDependencyException.class)
public void throwsExceptionOnAmbiguousResolution() throws Exception {
public void throwsExceptionOnAmbiguousResolution() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
xbf.getBean("rod8", ConstructorDependenciesBean.class);
@ -1176,7 +1176,7 @@ public class XmlBeanFactoryTests { @@ -1176,7 +1176,7 @@ public class XmlBeanFactoryTests {
fail("Must have thrown a CannotLoadBeanClassException");
}
catch (CannotLoadBeanClassException ex) {
assertTrue(ex.getResourceDescription().indexOf("classNotFound.xml") != -1);
assertTrue(ex.getResourceDescription().contains("classNotFound.xml"));
assertTrue(ex.getCause() instanceof ClassNotFoundException);
}
}
@ -1428,12 +1428,12 @@ public class XmlBeanFactoryTests { @@ -1428,12 +1428,12 @@ public class XmlBeanFactoryTests {
}
catch (BeanDefinitionStoreException ex) {
// Check that the bogus method name was included in the error message
assertTrue("Bogus method name correctly reported", ex.getMessage().indexOf("bogusMethod") != -1);
assertTrue("Bogus method name correctly reported", ex.getMessage().contains("bogusMethod"));
}
}
@Test
public void serializableMethodReplacerAndSuperclass() throws Exception {
public void serializableMethodReplacerAndSuperclass() throws IOException {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
reader.loadBeanDefinitions(DELEGATION_OVERRIDES_CONTEXT);
@ -1632,7 +1632,7 @@ public class XmlBeanFactoryTests { @@ -1632,7 +1632,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testWithDuplicateName() throws Exception {
public void testWithDuplicateName() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
try {
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAMES_CONTEXT);
@ -1644,7 +1644,7 @@ public class XmlBeanFactoryTests { @@ -1644,7 +1644,7 @@ public class XmlBeanFactoryTests {
}
@Test
public void testWithDuplicateNameInAlias() throws Exception {
public void testWithDuplicateNameInAlias() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
try {
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(TEST_WITH_DUP_NAME_IN_ALIAS_CONTEXT);

20
spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@ -48,7 +48,7 @@ public class ContextNamespaceHandlerTests { @@ -48,7 +48,7 @@ public class ContextNamespaceHandlerTests {
@Test
public void propertyPlaceholder() throws Exception {
public void propertyPlaceholder() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-replace.xml", getClass());
assertEquals("bar", applicationContext.getBean("string"));
@ -56,7 +56,7 @@ public class ContextNamespaceHandlerTests { @@ -56,7 +56,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderSystemProperties() throws Exception {
public void propertyPlaceholderSystemProperties() {
String value = System.setProperty("foo", "spam");
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
@ -72,7 +72,7 @@ public class ContextNamespaceHandlerTests { @@ -72,7 +72,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderEnvironmentProperties() throws Exception {
public void propertyPlaceholderEnvironmentProperties() {
MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
applicationContext.setEnvironment(env);
@ -83,7 +83,7 @@ public class ContextNamespaceHandlerTests { @@ -83,7 +83,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderLocation() throws Exception {
public void propertyPlaceholderLocation() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-location.xml", getClass());
assertEquals("bar", applicationContext.getBean("foo"));
@ -92,7 +92,7 @@ public class ContextNamespaceHandlerTests { @@ -92,7 +92,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderLocationWithSystemPropertyForOneLocation() throws Exception {
public void propertyPlaceholderLocationWithSystemPropertyForOneLocation() {
System.setProperty("properties",
"classpath*:/org/springframework/context/config/test-*.properties");
try {
@ -108,7 +108,7 @@ public class ContextNamespaceHandlerTests { @@ -108,7 +108,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderLocationWithSystemPropertyForMultipleLocations() throws Exception {
public void propertyPlaceholderLocationWithSystemPropertyForMultipleLocations() {
System.setProperty("properties",
"classpath*:/org/springframework/context/config/test-*.properties," +
"classpath*:/org/springframework/context/config/empty-*.properties," +
@ -126,7 +126,7 @@ public class ContextNamespaceHandlerTests { @@ -126,7 +126,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderLocationWithSystemPropertyMissing() throws Exception {
public void propertyPlaceholderLocationWithSystemPropertyMissing() {
try {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-location-placeholder.xml", getClass());
@ -140,7 +140,7 @@ public class ContextNamespaceHandlerTests { @@ -140,7 +140,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyPlaceholderIgnored() throws Exception {
public void propertyPlaceholderIgnored() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-replace-ignore.xml", getClass());
assertEquals("${bar}", applicationContext.getBean("string"));
@ -148,7 +148,7 @@ public class ContextNamespaceHandlerTests { @@ -148,7 +148,7 @@ public class ContextNamespaceHandlerTests {
}
@Test
public void propertyOverride() throws Exception {
public void propertyOverride() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"contextNamespaceHandlerTests-override.xml", getClass());
Date date = (Date) applicationContext.getBean("date");

2
spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "https://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>

4
spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder/>

Loading…
Cancel
Save