Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
7cbb3b06
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7cbb3b06
编写于
3月 06, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent local vs external resolution of https schema references
Closes gh-22504
上级
d034c053
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
78 addition
and
55 deletion
+78
-55
spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java
...g/springframework/beans/factory/xml/BeansDtdResolver.java
+3
-2
spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java
...framework/beans/factory/xml/DelegatingEntityResolver.java
+6
-2
spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java
...gframework/beans/factory/xml/PluggableSchemaResolver.java
+5
-1
spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java
...ngframework/beans/factory/xml/ResourceEntityResolver.java
+18
-4
spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
...pringframework/beans/factory/xml/XmlBeanFactoryTests.java
+33
-33
spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
...ramework/context/config/ContextNamespaceHandlerTests.java
+10
-10
spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
...mework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
+1
-1
spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
...rk/context/config/contextNamespaceHandlerTests-simple.xml
+2
-2
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java
浏览文件 @
7cbb3b06
...
...
@@ -16,6 +16,7 @@
package
org.springframework.beans.factory.xml
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
org.apache.commons.logging.Log
;
...
...
@@ -52,7 +53,7 @@ public class BeansDtdResolver implements EntityResolver {
@Override
@Nullable
public
InputSource
resolveEntity
(
String
publicId
,
@Nullable
String
systemId
)
throws
IOException
{
public
InputSource
resolveEntity
(
@Nullable
String
publicId
,
@Nullable
String
systemId
)
throws
IOException
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Trying to resolve XML entity with public ID ["
+
publicId
+
"] and system ID ["
+
systemId
+
"]"
);
...
...
@@ -76,7 +77,7 @@ public class BeansDtdResolver implements EntityResolver {
}
return
source
;
}
catch
(
IO
Exception
ex
)
{
catch
(
FileNotFound
Exception
ex
)
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Could not resolve beans DTD ["
+
systemId
+
"]: not found in classpath"
,
ex
);
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java
浏览文件 @
7cbb3b06
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -79,7 +79,9 @@ public class DelegatingEntityResolver implements EntityResolver {
@Override
@Nullable
public
InputSource
resolveEntity
(
String
publicId
,
@Nullable
String
systemId
)
throws
SAXException
,
IOException
{
public
InputSource
resolveEntity
(
@Nullable
String
publicId
,
@Nullable
String
systemId
)
throws
SAXException
,
IOException
{
if
(
systemId
!=
null
)
{
if
(
systemId
.
endsWith
(
DTD_SUFFIX
))
{
return
this
.
dtdResolver
.
resolveEntity
(
publicId
,
systemId
);
...
...
@@ -88,6 +90,8 @@ public class DelegatingEntityResolver implements EntityResolver {
return
this
.
schemaResolver
.
resolveEntity
(
publicId
,
systemId
);
}
}
// Fall back to the parser's default behavior.
return
null
;
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java
浏览文件 @
7cbb3b06
...
...
@@ -106,7 +106,7 @@ public class PluggableSchemaResolver implements EntityResolver {
@Override
@Nullable
public
InputSource
resolveEntity
(
String
publicId
,
@Nullable
String
systemId
)
throws
IOException
{
public
InputSource
resolveEntity
(
@Nullable
String
publicId
,
@Nullable
String
systemId
)
throws
IOException
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Trying to resolve XML entity with public id ["
+
publicId
+
"] and system id ["
+
systemId
+
"]"
);
...
...
@@ -114,6 +114,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
{
...
...
spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java
浏览文件 @
7cbb3b06
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -31,9 +31,9 @@ import org.springframework.core.io.ResourceLoader;
import
org.springframework.lang.Nullable
;
/**
*
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,8 +72,11 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
@Override
@Nullable
public
InputSource
resolveEntity
(
String
publicId
,
@Nullable
String
systemId
)
throws
SAXException
,
IOException
{
public
InputSource
resolveEntity
(
@Nullable
String
publicId
,
@Nullable
String
systemId
)
throws
SAXException
,
IOException
{
InputSource
source
=
super
.
resolveEntity
(
publicId
,
systemId
);
if
(
source
==
null
&&
systemId
!=
null
)
{
String
resourcePath
=
null
;
try
{
...
...
@@ -105,7 +108,18 @@ 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
);
}
source
=
new
InputSource
(
url
);
source
.
setPublicId
(
publicId
);
return
source
;
}
}
return
source
;
}
...
...
spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java
浏览文件 @
7cbb3b06
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -123,16 +123,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
);
...
...
@@ -151,7 +151,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
);
...
...
@@ -307,7 +307,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
);
...
...
@@ -323,7 +323,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
);
...
...
@@ -338,7 +338,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
);
...
...
@@ -353,7 +353,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
);
...
...
@@ -373,7 +373,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
);
...
...
@@ -433,7 +433,7 @@ public class XmlBeanFactoryTests {
}
@Test
public
void
testDependenciesMaterializeThis
()
throws
Exception
{
public
void
testDependenciesMaterializeThis
()
{
DefaultListableBeanFactory
xbf
=
new
DefaultListableBeanFactory
();
new
XmlBeanDefinitionReader
(
xbf
).
loadBeanDefinitions
(
DEP_MATERIALIZE_CONTEXT
);
...
...
@@ -452,7 +452,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
);
...
...
@@ -471,7 +471,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
);
...
...
@@ -493,7 +493,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
);
...
...
@@ -658,7 +658,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"
);
...
...
@@ -685,7 +685,7 @@ public class XmlBeanFactoryTests {
}
@Test
public
void
testNoSuchInitMethod
()
throws
Exception
{
public
void
testNoSuchInitMethod
()
{
DefaultListableBeanFactory
xbf
=
new
DefaultListableBeanFactory
();
new
XmlBeanDefinitionReader
(
xbf
).
loadBeanDefinitions
(
INITIALIZERS_CONTEXT
);
try
{
...
...
@@ -704,7 +704,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
);
...
...
@@ -725,7 +725,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
);
...
...
@@ -743,7 +743,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
);
...
...
@@ -759,19 +759,19 @@ 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
);
}
@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
);
...
...
@@ -780,7 +780,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
();
...
...
@@ -793,7 +793,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
...
...
@@ -842,7 +842,7 @@ public class XmlBeanFactoryTests {
}
@Test
public
void
testAutowireWithDefault
()
throws
Exception
{
public
void
testAutowireWithDefault
()
{
DefaultListableBeanFactory
xbf
=
new
DefaultListableBeanFactory
();
new
XmlBeanDefinitionReader
(
xbf
).
loadBeanDefinitions
(
DEFAULT_AUTOWIRE_CONTEXT
);
...
...
@@ -858,7 +858,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"
);
...
...
@@ -896,7 +896,7 @@ public class XmlBeanFactoryTests {
}
@Test
public
void
testAutowireByConstructorWithSimpleValues
()
throws
Exception
{
public
void
testAutowireByConstructorWithSimpleValues
()
{
DefaultListableBeanFactory
xbf
=
new
DefaultListableBeanFactory
();
new
XmlBeanDefinitionReader
(
xbf
).
loadBeanDefinitions
(
CONSTRUCTOR_ARG_CONTEXT
);
...
...
@@ -1014,14 +1014,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
);
...
...
@@ -1372,7 +1372,7 @@ public class XmlBeanFactoryTests {
}
@Test
public
void
serializableMethodReplacerAndSuperclass
()
throws
Exception
{
public
void
serializableMethodReplacerAndSuperclass
()
throws
IO
Exception
{
DefaultListableBeanFactory
xbf
=
new
DefaultListableBeanFactory
();
XmlBeanDefinitionReader
reader
=
new
XmlBeanDefinitionReader
(
xbf
);
reader
.
loadBeanDefinitions
(
DELEGATION_OVERRIDES_CONTEXT
);
...
...
@@ -1571,7 +1571,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
);
...
...
@@ -1583,7 +1583,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
);
...
...
spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java
浏览文件 @
7cbb3b06
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
9
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 {
@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 {
}
@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 {
}
@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 {
}
@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 {
}
@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 {
}
@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 {
}
@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 {
}
@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 {
}
@Test
public
void
propertyOverride
()
throws
Exception
{
public
void
propertyOverride
()
{
ApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
"contextNamespaceHandlerTests-override.xml"
,
getClass
());
Date
date
=
(
Date
)
applicationContext
.
getBean
(
"date"
);
...
...
spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-resource.xml
浏览文件 @
7cbb3b06
<?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" "http
s
://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
...
...
spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
浏览文件 @
7cbb3b06
...
...
@@ -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 http
s
://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http
s
://www.springframework.org/schema/context/spring-context-3.1.xsd"
>
<context:property-placeholder/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录