Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
167329ce
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,体验更适合开发者的 AI 搜索 >>
提交
167329ce
编写于
1月 24, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added test for SpringProperties setFlag method
Issue: SPR-9014 Issue: SPR-11297 (cherry picked from commit
23249cda
)
上级
2dcbf4d6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
7 deletion
+16
-7
spring-core/src/main/java/org/springframework/core/SpringProperties.java
.../main/java/org/springframework/core/SpringProperties.java
+4
-2
spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java
...rg/springframework/core/env/StandardEnvironmentTests.java
+12
-5
未找到文件。
spring-core/src/main/java/org/springframework/core/SpringProperties.java
浏览文件 @
167329ce
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -44,6 +44,8 @@ import org.apache.commons.logging.LogFactory;
*/
public
abstract
class
SpringProperties
{
private
static
final
String
PROPERTIES_RESOURCE_LOCATION
=
"spring.properties"
;
private
static
final
Log
logger
=
LogFactory
.
getLog
(
SpringProperties
.
class
);
private
static
final
Properties
localProperties
=
new
Properties
();
...
...
@@ -52,7 +54,7 @@ public abstract class SpringProperties {
static
{
try
{
ClassLoader
cl
=
SpringProperties
.
class
.
getClassLoader
();
URL
url
=
cl
.
getResource
(
"spring.properties"
);
URL
url
=
cl
.
getResource
(
PROPERTIES_RESOURCE_LOCATION
);
if
(
url
!=
null
)
{
logger
.
info
(
"Found 'spring.properties' file in local classpath"
);
InputStream
is
=
url
.
openStream
();
...
...
spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java
浏览文件 @
167329ce
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -59,15 +59,15 @@ public class StandardEnvironmentTests {
child
.
setActiveProfiles
(
"c1"
,
"c2"
);
child
.
getPropertySources
().
addLast
(
new
MockPropertySource
(
"childMock"
)
.
withProperty
(
"childKey"
,
"childVal"
)
.
withProperty
(
"bothKey"
,
"childBothVal"
));
.
withProperty
(
"childKey"
,
"childVal"
)
.
withProperty
(
"bothKey"
,
"childBothVal"
));
ConfigurableEnvironment
parent
=
new
StandardEnvironment
();
parent
.
setActiveProfiles
(
"p1"
,
"p2"
);
parent
.
getPropertySources
().
addLast
(
new
MockPropertySource
(
"parentMock"
)
.
withProperty
(
"parentKey"
,
"parentVal"
)
.
withProperty
(
"bothKey"
,
"parentBothVal"
));
.
withProperty
(
"parentKey"
,
"parentVal"
)
.
withProperty
(
"bothKey"
,
"parentBothVal"
));
assertThat
(
child
.
getProperty
(
"childKey"
),
is
(
"childVal"
));
assertThat
(
child
.
getProperty
(
"parentKey"
),
nullValue
());
...
...
@@ -354,6 +354,13 @@ public class StandardEnvironmentTests {
SpringProperties
.
setProperty
(
"spring.getenv.ignore"
,
null
);
}
@Test
public
void
suppressGetenvAccessThroughSpringFlag
()
{
SpringProperties
.
setFlag
(
"spring.getenv.ignore"
);
assertTrue
(
environment
.
getSystemEnvironment
().
isEmpty
());
SpringProperties
.
setProperty
(
"spring.getenv.ignore"
,
null
);
}
@Test
public
void
getSystemProperties_withAndWithoutSecurityManager
()
{
System
.
setProperty
(
ALLOWED_PROPERTY_NAME
,
ALLOWED_PROPERTY_VALUE
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录