Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
d4360db4
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 搜索 >>
提交
d4360db4
编写于
8月 23, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish ReflectionTestUtilsTests
上级
50decc43
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
25 deletion
+24
-25
spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
...g/springframework/test/util/ReflectionTestUtilsTests.java
+24
-25
未找到文件。
spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
浏览文件 @
d4360db4
...
@@ -61,50 +61,50 @@ class ReflectionTestUtilsTests {
...
@@ -61,50 +61,50 @@ class ReflectionTestUtilsTests {
@Test
@Test
void
setFieldWithNullTargetObject
()
throws
Exception
{
void
setFieldWithNullTargetObject
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
setField
((
Object
)
null
,
"id"
,
Long
.
valueOf
(
99
)))
.
isThrownBy
(()
->
setField
((
Object
)
null
,
"id"
,
Long
.
valueOf
(
99
)))
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
}
}
@Test
@Test
void
getFieldWithNullTargetObject
()
throws
Exception
{
void
getFieldWithNullTargetObject
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
getField
((
Object
)
null
,
"id"
))
.
isThrownBy
(()
->
getField
((
Object
)
null
,
"id"
))
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
}
}
@Test
@Test
void
setFieldWithNullTargetClass
()
throws
Exception
{
void
setFieldWithNullTargetClass
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
setField
((
Class
<?>)
null
,
"id"
,
Long
.
valueOf
(
99
)))
.
isThrownBy
(()
->
setField
((
Class
<?>)
null
,
"id"
,
Long
.
valueOf
(
99
)))
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
}
}
@Test
@Test
void
getFieldWithNullTargetClass
()
throws
Exception
{
void
getFieldWithNullTargetClass
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
getField
((
Class
<?>)
null
,
"id"
))
.
isThrownBy
(()
->
getField
((
Class
<?>)
null
,
"id"
))
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
.
withMessageStartingWith
(
"Either targetObject or targetClass"
);
}
}
@Test
@Test
void
setFieldWithNullNameAndNullType
()
throws
Exception
{
void
setFieldWithNullNameAndNullType
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
setField
(
person
,
null
,
Long
.
valueOf
(
99
),
null
))
.
isThrownBy
(()
->
setField
(
person
,
null
,
Long
.
valueOf
(
99
),
null
))
.
withMessageStartingWith
(
"Either name or type"
);
.
withMessageStartingWith
(
"Either name or type"
);
}
}
@Test
@Test
void
setFieldWithBogusName
()
throws
Exception
{
void
setFieldWithBogusName
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
setField
(
person
,
"bogus"
,
Long
.
valueOf
(
99
),
long
.
class
))
.
isThrownBy
(()
->
setField
(
person
,
"bogus"
,
Long
.
valueOf
(
99
),
long
.
class
))
.
withMessageStartingWith
(
"Could not find field 'bogus'"
);
.
withMessageStartingWith
(
"Could not find field 'bogus'"
);
}
}
@Test
@Test
void
setFieldWithWrongType
()
throws
Exception
{
void
setFieldWithWrongType
()
throws
Exception
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
assertThatIllegalArgumentException
()
setField
(
person
,
"id"
,
Long
.
valueOf
(
99
),
String
.
class
))
.
isThrownBy
(()
->
setField
(
person
,
"id"
,
Long
.
valueOf
(
99
),
String
.
class
))
.
withMessageStartingWith
(
"Could not find field"
);
.
withMessageStartingWith
(
"Could not find field"
);
}
}
...
@@ -316,8 +316,7 @@ class ReflectionTestUtilsTests {
...
@@ -316,8 +316,7 @@ class ReflectionTestUtilsTests {
@Test
@Test
void
invokeSetterMethodWithNullValueForPrimitiveBoolean
()
throws
Exception
{
void
invokeSetterMethodWithNullValueForPrimitiveBoolean
()
throws
Exception
{
assertThatIllegalArgumentException
().
isThrownBy
(()
->
assertThatIllegalArgumentException
().
isThrownBy
(()
->
invokeSetterMethod
(
person
,
"likesPets"
,
null
,
boolean
.
class
));
invokeSetterMethod
(
person
,
"likesPets"
,
null
,
boolean
.
class
));
}
}
@Test
@Test
...
@@ -364,29 +363,29 @@ class ReflectionTestUtilsTests {
...
@@ -364,29 +363,29 @@ class ReflectionTestUtilsTests {
@Test
@Test
void
invokeInitMethodBeforeAutowiring
()
{
void
invokeInitMethodBeforeAutowiring
()
{
assertThatIllegalStateException
()
.
isThrownBy
(()
->
assertThatIllegalStateException
()
invokeMethod
(
component
,
"init"
))
.
isThrownBy
(()
->
invokeMethod
(
component
,
"init"
))
.
withMessageStartingWith
(
"number must not be null"
);
.
withMessageStartingWith
(
"number must not be null"
);
}
}
@Test
@Test
void
invokeMethodWithIncompatibleArgumentTypes
()
{
void
invokeMethodWithIncompatibleArgumentTypes
()
{
assertThatIllegalStateException
()
.
isThrownBy
(()
->
assertThatIllegalStateException
()
invokeMethod
(
component
,
"subtract"
,
"foo"
,
2.0
))
.
isThrownBy
(()
->
invokeMethod
(
component
,
"subtract"
,
"foo"
,
2.0
))
.
withMessageStartingWith
(
"Method not found"
);
.
withMessageStartingWith
(
"Method not found"
);
}
}
@Test
@Test
void
invokeMethodWithTooFewArguments
()
{
void
invokeMethodWithTooFewArguments
()
{
assertThatIllegalStateException
()
.
isThrownBy
(()
->
assertThatIllegalStateException
()
invokeMethod
(
component
,
"configure"
,
Integer
.
valueOf
(
42
)))
.
isThrownBy
(()
->
invokeMethod
(
component
,
"configure"
,
Integer
.
valueOf
(
42
)))
.
withMessageStartingWith
(
"Method not found"
);
.
withMessageStartingWith
(
"Method not found"
);
}
}
@Test
@Test
void
invokeMethodWithTooManyArguments
()
{
void
invokeMethodWithTooManyArguments
()
{
assertThatIllegalStateException
()
.
isThrownBy
(()
->
assertThatIllegalStateException
()
invokeMethod
(
component
,
"configure"
,
Integer
.
valueOf
(
42
),
"enigma"
,
"baz"
,
"quux"
))
.
isThrownBy
(()
->
invokeMethod
(
component
,
"configure"
,
Integer
.
valueOf
(
42
),
"enigma"
,
"baz"
,
"quux"
))
.
withMessageStartingWith
(
"Method not found"
);
.
withMessageStartingWith
(
"Method not found"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录