Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
73170224
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 搜索 >>
提交
73170224
编写于
5月 22, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish annotation utility tests
上级
91ed5b6b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
15 deletion
+14
-15
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java
...framework/core/annotation/AnnotatedElementUtilsTests.java
+6
-6
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java
...springframework/core/annotation/AnnotationUtilsTests.java
+8
-9
未找到文件。
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java
浏览文件 @
73170224
...
...
@@ -573,7 +573,7 @@ public class AnnotatedElementUtilsTests {
* Mock of {@link org.springframework.test.context.ContextConfiguration}.
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
ContextConfig
{
@interface
ContextConfig
{
@AliasFor
(
attribute
=
"locations"
)
String
[]
value
()
default
{};
...
...
@@ -584,21 +584,21 @@ public class AnnotatedElementUtilsTests {
@ContextConfig
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
ConventionBasedComposedContextConfig
{
@interface
ConventionBasedComposedContextConfig
{
String
[]
locations
()
default
{};
}
@ContextConfig
(
value
=
"duplicateDeclaration"
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
InvalidConventionBasedComposedContextConfig
{
@interface
InvalidConventionBasedComposedContextConfig
{
String
[]
locations
();
}
@ContextConfig
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
AliasedComposedContextConfig
{
@interface
AliasedComposedContextConfig
{
@AliasFor
(
annotation
=
ContextConfig
.
class
,
attribute
=
"locations"
)
String
[]
xmlConfigFiles
();
...
...
@@ -606,7 +606,7 @@ public class AnnotatedElementUtilsTests {
@ContextConfig
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
AliasedValueComposedContextConfig
{
@interface
AliasedValueComposedContextConfig
{
@AliasFor
(
annotation
=
ContextConfig
.
class
,
attribute
=
"value"
)
String
[]
locations
();
...
...
@@ -620,7 +620,7 @@ public class AnnotatedElementUtilsTests {
*/
@ContextConfig
(
value
=
"duplicateDeclaration"
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
static
@interface
InvalidAliasedComposedContextConfig
{
@interface
InvalidAliasedComposedContextConfig
{
@AliasFor
(
annotation
=
ContextConfig
.
class
,
attribute
=
"locations"
)
String
[]
xmlConfigFiles
();
...
...
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java
浏览文件 @
73170224
...
...
@@ -25,7 +25,6 @@ import java.lang.reflect.Method;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -36,6 +35,7 @@ import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ClassUtils
;
import
static
java
.
util
.
stream
.
Collectors
.*;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
core
.
annotation
.
AnnotationUtils
.*;
...
...
@@ -480,7 +480,7 @@ public class AnnotationUtilsTests {
Method
method
=
InterfaceWithRepeated
.
class
.
getMethod
(
"foo"
);
Set
<
MyRepeatable
>
annotations
=
getRepeatableAnnotation
(
method
,
MyRepeatableContainer
.
class
,
MyRepeatable
.
class
);
assertNotNull
(
annotations
);
List
<
String
>
values
=
annotations
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
Collectors
.
toList
());
List
<
String
>
values
=
annotations
.
stream
().
map
(
MyRepeatable:
:
value
).
collect
(
toList
());
assertThat
(
values
,
equalTo
(
Arrays
.
asList
(
"a"
,
"b"
,
"c"
,
"meta"
)));
}
...
...
@@ -489,10 +489,10 @@ public class AnnotationUtilsTests {
Set
<
ContextConfig
>
annotations
=
getRepeatableAnnotation
(
TestCase
.
class
,
Hierarchy
.
class
,
ContextConfig
.
class
);
assertNotNull
(
annotations
);
List
<
String
>
locations
=
annotations
.
stream
().
map
(
ContextConfig:
:
locations
).
collect
(
Collectors
.
toList
());
List
<
String
>
locations
=
annotations
.
stream
().
map
(
ContextConfig:
:
locations
).
collect
(
toList
());
assertThat
(
locations
,
equalTo
(
Arrays
.
asList
(
"A"
,
"B"
)));
List
<
String
>
values
=
annotations
.
stream
().
map
(
ContextConfig:
:
value
).
collect
(
Collectors
.
toList
());
List
<
String
>
values
=
annotations
.
stream
().
map
(
ContextConfig:
:
value
).
collect
(
toList
());
assertThat
(
values
,
equalTo
(
Arrays
.
asList
(
"A"
,
"B"
)));
}
...
...
@@ -646,14 +646,13 @@ public class AnnotationUtilsTests {
ContextConfig
[]
configs
=
synthesizedHierarchy
.
value
();
assertNotNull
(
configs
);
for
(
ContextConfig
contextConfig
:
configs
)
{
assertThat
(
contextConfig
,
instanceOf
(
SynthesizedAnnotation
.
class
));
}
assertTrue
(
"nested annotations must be synthesized"
,
Arrays
.
stream
(
configs
).
allMatch
(
c
->
c
instanceof
SynthesizedAnnotation
));
List
<
String
>
locations
=
Arrays
.
stream
(
configs
).
map
(
ContextConfig:
:
locations
).
collect
(
Collectors
.
toList
());
List
<
String
>
locations
=
Arrays
.
stream
(
configs
).
map
(
ContextConfig:
:
locations
).
collect
(
toList
());
assertThat
(
locations
,
equalTo
(
Arrays
.
asList
(
"A"
,
"B"
)));
List
<
String
>
values
=
Arrays
.
stream
(
configs
).
map
(
ContextConfig:
:
value
).
collect
(
Collectors
.
toList
());
List
<
String
>
values
=
Arrays
.
stream
(
configs
).
map
(
ContextConfig:
:
value
).
collect
(
toList
());
assertThat
(
values
,
equalTo
(
Arrays
.
asList
(
"A"
,
"B"
)));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录