Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
a3af9e73
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,发现更多精彩内容 >>
提交
a3af9e73
编写于
5月 20, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revised use of id and display name (id may be null; SPR-5761)
上级
da4f1d0e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
10 deletion
+12
-10
org.springframework.context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java
.../support/AbstractRefreshableConfigApplicationContext.java
+2
-1
org.springframework.context/src/test/java/org/springframework/context/access/ContextSingletonBeanFactoryLocatorTests.java
...ntext/access/ContextSingletonBeanFactoryLocatorTests.java
+4
-4
org.springframework.context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java
.../context/support/ClassPathXmlApplicationContextTests.java
+6
-5
未找到文件。
org.springframework.context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java
浏览文件 @
a3af9e73
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
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.
...
...
@@ -137,6 +137,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra
public
void
setBeanName
(
String
name
)
{
if
(!
this
.
setIdCalled
)
{
super
.
setId
(
name
);
setDisplayName
(
"ApplicationContext '"
+
name
+
"'"
);
}
}
...
...
org.springframework.context/src/test/java/org/springframework/context/access/ContextSingletonBeanFactoryLocatorTests.java
浏览文件 @
a3af9e73
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
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.
...
...
@@ -17,8 +17,8 @@
package
org.springframework.context.access
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.access.BeanFactoryLocator
;
import
org.springframework.beans.factory.access.BeanFactoryReference
;
...
...
@@ -58,11 +58,11 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
BeanFactory
fac
=
bfr
.
getFactory
();
assertTrue
(
fac
instanceof
ApplicationContext
);
assertEquals
(
"a.qualified.name.of.some.sort"
,
((
ApplicationContext
)
fac
).
getId
());
assert
Equals
(
"a.qualified.name.of.some.sort"
,
((
ApplicationContext
)
fac
).
getDisplayName
(
));
assert
True
(((
ApplicationContext
)
fac
).
getDisplayName
().
contains
(
"a.qualified.name.of.some.sort"
));
BeanFactoryReference
bfr2
=
facLoc
.
useBeanFactory
(
"another.qualified.name"
);
BeanFactory
fac2
=
bfr2
.
getFactory
();
assertEquals
(
"another.qualified.name"
,
((
ApplicationContext
)
fac2
).
getId
());
assert
Equals
(
"another.qualified.name"
,
((
ApplicationContext
)
fac2
).
getDisplayName
(
));
assert
True
(((
ApplicationContext
)
fac2
).
getDisplayName
().
contains
(
"another.qualified.name"
));
assertTrue
(
fac2
instanceof
ApplicationContext
);
}
...
...
org.springframework.context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java
浏览文件 @
a3af9e73
...
...
@@ -133,8 +133,8 @@ public final class ClassPathXmlApplicationContextTests {
}
catch
(
BeanCreationException
ex
)
{
assertTrue
(
ex
.
contains
(
TypeMismatchException
.
class
));
assertTrue
(
ex
.
toString
().
indexOf
(
"someMessageSource"
)
!=
-
1
);
assertTrue
(
ex
.
toString
().
indexOf
(
"useCodeAsDefaultMessage"
)
!=
-
1
);
assertTrue
(
ex
.
toString
().
contains
(
"someMessageSource"
)
);
assertTrue
(
ex
.
toString
().
contains
(
"useCodeAsDefaultMessage"
)
);
checkExceptionFromInvalidValueType
(
ex
);
checkExceptionFromInvalidValueType
(
new
ExceptionInInitializerError
(
ex
));
assertFalse
(
context
.
isActive
());
...
...
@@ -146,8 +146,8 @@ public final class ClassPathXmlApplicationContextTests {
ex
.
printStackTrace
(
new
PrintStream
(
baos
));
String
dump
=
FileCopyUtils
.
copyToString
(
new
InputStreamReader
(
new
ByteArrayInputStream
(
baos
.
toByteArray
())));
assertTrue
(
dump
.
indexOf
(
"someMessageSource"
)
!=
-
1
);
assertTrue
(
dump
.
indexOf
(
"useCodeAsDefaultMessage"
)
!=
-
1
);
assertTrue
(
dump
.
contains
(
"someMessageSource"
)
);
assertTrue
(
dump
.
contains
(
"useCodeAsDefaultMessage"
)
);
}
@Test
...
...
@@ -381,13 +381,14 @@ public final class ClassPathXmlApplicationContextTests {
public
void
testGenericApplicationContextWithXmlBeanDefinitionsAndSpecifiedId
()
{
GenericApplicationContext
ctx
=
new
GenericApplicationContext
();
ctx
.
setId
(
"testContext"
);
ctx
.
setDisplayName
(
"Test Context"
);
XmlBeanDefinitionReader
reader
=
new
XmlBeanDefinitionReader
(
ctx
);
reader
.
loadBeanDefinitions
(
new
ClassPathResource
(
CONTEXT_B
,
getClass
()));
reader
.
loadBeanDefinitions
(
new
ClassPathResource
(
CONTEXT_C
,
getClass
()));
reader
.
loadBeanDefinitions
(
new
ClassPathResource
(
CONTEXT_A
,
getClass
()));
ctx
.
refresh
();
assertEquals
(
"testContext"
,
ctx
.
getId
());
assertEquals
(
"
test
Context"
,
ctx
.
getDisplayName
());
assertEquals
(
"
Test
Context"
,
ctx
.
getDisplayName
());
assertTrue
(
ctx
.
containsBean
(
"service"
));
assertTrue
(
ctx
.
containsBean
(
"logicOne"
));
assertTrue
(
ctx
.
containsBean
(
"logicTwo"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录