Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
b50ac748
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
b50ac748
编写于
3月 15, 2011
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve or eliminate Environment-related TODOs
Issue: SPR-8031, SPR-7508
上级
d471266d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
34 addition
and
18 deletion
+34
-18
org.springframework.beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java
...ns/factory/config/PropertyPlaceholderConfigurerTests.java
+0
-1
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
...work/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
+3
-1
org.springframework.core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java
...rg/springframework/core/env/EnumerablePropertySource.java
+17
-1
org.springframework.core/src/main/java/org/springframework/core/env/PropertySource.java
...ain/java/org/springframework/core/env/PropertySource.java
+3
-1
org.springframework.core/src/test/java/org/springframework/core/env/EnvironmentTests.java
...t/java/org/springframework/core/env/EnvironmentTests.java
+11
-9
org.springframework.core/src/test/java/org/springframework/core/env/PropertySourceTests.java
...ava/org/springframework/core/env/PropertySourceTests.java
+0
-1
org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java
...springframework/core/env/EnvironmentIntegrationTests.java
+0
-4
未找到文件。
org.springframework.beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java
浏览文件 @
b50ac748
...
...
@@ -243,7 +243,6 @@ public class PropertyPlaceholderConfigurerTests {
}
// TODO SPR-7508: duplicated from EnvironmentPropertyResolutionSearchTests
@SuppressWarnings
(
"unchecked"
)
private
static
Map
<
String
,
String
>
getModifiableSystemEnvironment
()
{
Class
<?>[]
classes
=
Collections
.
class
.
getDeclaredClasses
();
...
...
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
浏览文件 @
b50ac748
...
...
@@ -30,9 +30,11 @@ import org.springframework.core.env.DefaultEnvironment;
import
org.springframework.core.io.ClassPathResource
;
/**
* TODO SPR-7508: document
* Tests various combinations of profile declarations against various profile
* activation and profile default scenarios.
*
* @author Chris Beams
* @since 3.1
*/
public
class
ProfileXmlBeanDefinitionTests
{
...
...
org.springframework.core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java
浏览文件 @
b50ac748
...
...
@@ -19,7 +19,23 @@ package org.springframework.core.env;
import
org.springframework.util.Assert
;
/**
* TODO SPR-7508: document
* A {@link PropertySource} implementation capable of interrogating its
* underlying source object to enumerate all possible property key/value
* pairs. Exposes the {@link #getPropertyNames()} method to allow callers
* to introspect available properties without having to access the underlying
* source object. This also facilitates a more efficient implementation of
* {@link #containsProperty(String)}, in that it can call {@link #getPropertyNames()}
* and iterate through the returned array rather than attempting a call to
* {@link #getProperty(String)} which may be more expensive. Implementations may
* consider caching the result of {@link #getPropertyNames()} to fully exploit this
* performance opportunity.
*
* Most framework-provided {@code PropertySource} implementations are enumerable;
* a counter-example would be {@code JndiPropertySource} where, due to the
* nature of JNDI it is not possible to determine all possible property names at
* any given time; rather it is only possible to try to access a property
* (via {@link #getProperty(String)}) in order to evaluate whether it is present
* or not.
*
* @author Chris Beams
* @since 3.1
...
...
org.springframework.core/src/main/java/org/springframework/core/env/PropertySource.java
浏览文件 @
b50ac748
...
...
@@ -214,9 +214,11 @@ public abstract class PropertySource<T> {
super
(
name
,
new
Object
());
}
/**
* Always return {@code null}.
*/
@Override
public
String
getProperty
(
String
key
)
{
// TODO SPR-7408: logging
return
null
;
}
}
...
...
org.springframework.core/src/test/java/org/springframework/core/env/EnvironmentTests.java
浏览文件 @
b50ac748
...
...
@@ -41,7 +41,6 @@ import java.util.Map;
import
org.junit.Test
;
import
org.springframework.mock.env.MockPropertySource
;
/**
* Unit tests for {@link DefaultEnvironment}.
*
...
...
@@ -230,7 +229,7 @@ public class EnvironmentTests {
}
@Test
public
void
getSystemEnvironment_withAndWithoutSecurityManager
()
throws
Exception
{
public
void
getSystemEnvironment_withAndWithoutSecurityManager
()
{
getModifiableSystemEnvironment
().
put
(
ALLOWED_PROPERTY_NAME
,
ALLOWED_PROPERTY_VALUE
);
getModifiableSystemEnvironment
().
put
(
DISALLOWED_PROPERTY_NAME
,
DISALLOWED_PROPERTY_VALUE
);
...
...
@@ -270,17 +269,20 @@ public class EnvironmentTests {
getModifiableSystemEnvironment
().
remove
(
DISALLOWED_PROPERTY_NAME
);
}
// TODO SPR-7508: duplicated from EnvironmentPropertyResolutionSearchTests
@SuppressWarnings
(
"unchecked"
)
private
static
Map
<
String
,
String
>
getModifiableSystemEnvironment
()
throws
Exception
{
private
static
Map
<
String
,
String
>
getModifiableSystemEnvironment
()
{
Class
<?>[]
classes
=
Collections
.
class
.
getDeclaredClasses
();
Map
<
String
,
String
>
systemE
nv
=
System
.
getenv
();
Map
<
String
,
String
>
e
nv
=
System
.
getenv
();
for
(
Class
<?>
cl
:
classes
)
{
if
(
"java.util.Collections$UnmodifiableMap"
.
equals
(
cl
.
getName
()))
{
Field
field
=
cl
.
getDeclaredField
(
"m"
);
field
.
setAccessible
(
true
);
Object
obj
=
field
.
get
(
systemEnv
);
return
(
Map
<
String
,
String
>)
obj
;
try
{
Field
field
=
cl
.
getDeclaredField
(
"m"
);
field
.
setAccessible
(
true
);
Object
obj
=
field
.
get
(
env
);
return
(
Map
<
String
,
String
>)
obj
;
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
throw
new
IllegalStateException
();
...
...
org.springframework.core/src/test/java/org/springframework/core/env/PropertySourceTests.java
浏览文件 @
b50ac748
...
...
@@ -72,7 +72,6 @@ public class PropertySourceTests {
assertThat
(
propertySources
.
contains
(
ps1
),
is
(
true
));
assertThat
(
propertySources
.
contains
(
PropertySource
.
named
(
"ps1"
)),
is
(
true
));
// TODO SPR-7508: consider disallowing duplicates somehow (in the actual data structure used by environment)
PropertySource
<?>
ps1replacement
=
new
MapPropertySource
(
"ps1"
,
map2
);
// notice - different map
assertThat
(
propertySources
.
add
(
ps1replacement
),
is
(
true
));
// true because linkedlist allows duplicates
assertThat
(
propertySources
.
size
(),
is
(
2
));
...
...
org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java
浏览文件 @
b50ac748
...
...
@@ -354,9 +354,6 @@ public class EnvironmentIntegrationTests {
assertEnvironmentAwareInvoked
(
ctx
,
prodEnv
);
}
// TODO SPR-7508: need to think about how a custom environment / custom property sources
// would be specified in an actual webapp using XmlWebApplicationContext. What do the
// context params look like, etc.
@Test
public
void
xmlWebApplicationContext
()
{
AbstractRefreshableWebApplicationContext
ctx
=
new
XmlWebApplicationContext
();
...
...
@@ -541,7 +538,6 @@ public class EnvironmentIntegrationTests {
public
void
resourceAdapterApplicationContext
()
{
ResourceAdapterApplicationContext
ctx
=
new
ResourceAdapterApplicationContext
(
new
SimpleBootstrapContext
(
new
SimpleTaskWorkManager
()));
// TODO SPR-7508: should be a JCA-specific environment?
assertHasDefaultEnvironment
(
ctx
);
registerEnvironmentBeanDefinition
(
ctx
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录