Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
96e1fbc3
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 搜索 >>
提交
96e1fbc3
编写于
6月 08, 2013
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish @Conditional Javadoc and tests
上级
239ce146
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
10 deletion
+11
-10
spring-context/src/main/java/org/springframework/context/annotation/Conditional.java
...a/org/springframework/context/annotation/Conditional.java
+1
-1
spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java
...text/annotation/ConfigurationClassWithConditionTests.java
+10
-9
未找到文件。
spring-context/src/main/java/org/springframework/context/annotation/Conditional.java
浏览文件 @
96e1fbc3
...
...
@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
import
java.lang.annotation.Target
;
/**
* Indicates that a component is
is
only eligible for registration when all
* Indicates that a component is only eligible for registration when all
* {@linkplain #value() specified conditions} match.
*
* <p>A <em>condition</em> is any state that can be determined programmatically
...
...
spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java
浏览文件 @
96e1fbc3
...
...
@@ -27,6 +27,7 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.junit.After
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
...
...
@@ -36,18 +37,24 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import
org.springframework.stereotype.Component
;
/**
* Test for {@link Conditional} beans.
*
* Test
s
for {@link Conditional} beans.
*
* @author Phillip Webb
*/
public
class
ConfigurationClassWithConditionTests
{
private
final
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
@After
public
void
closeContext
()
{
ctx
.
close
();
}
@Test
public
void
conditionalOnMissingBeanMatch
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
BeanOneConfiguration
.
class
,
BeanTwoConfiguration
.
class
);
ctx
.
refresh
();
assertTrue
(
ctx
.
containsBean
(
"bean1"
));
...
...
@@ -57,7 +64,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
conditionalOnMissingBeanNoMatch
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
BeanTwoConfiguration
.
class
);
ctx
.
refresh
();
assertFalse
(
ctx
.
containsBean
(
"bean1"
));
...
...
@@ -67,7 +73,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
conditionalOnBeanMatch
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
BeanOneConfiguration
.
class
,
BeanThreeConfiguration
.
class
);
ctx
.
refresh
();
assertTrue
(
ctx
.
containsBean
(
"bean1"
));
...
...
@@ -76,7 +81,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
conditionalOnBeanNoMatch
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
BeanThreeConfiguration
.
class
);
ctx
.
refresh
();
assertFalse
(
ctx
.
containsBean
(
"bean1"
));
...
...
@@ -85,7 +89,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
metaConditional
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
ConfigurationWithMetaCondition
.
class
);
ctx
.
refresh
();
assertTrue
(
ctx
.
containsBean
(
"bean"
));
...
...
@@ -93,7 +96,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
nonConfigurationClass
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
NonConfigurationClass
.
class
);
ctx
.
refresh
();
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
...
...
@@ -102,7 +104,6 @@ public class ConfigurationClassWithConditionTests {
@Test
public
void
methodConditional
()
throws
Exception
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
ctx
.
register
(
ConditionOnMethodConfiguration
.
class
);
ctx
.
refresh
();
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录