Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
bb514478
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 搜索 >>
提交
bb514478
编写于
7月 22, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix typos in RequestResultMatchers
上级
f06581f5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
12 deletion
+18
-12
spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java
...mework/test/web/servlet/result/RequestResultMatchers.java
+18
-12
未找到文件。
spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java
浏览文件 @
bb514478
...
...
@@ -36,23 +36,23 @@ import static org.springframework.test.util.AssertionErrors.*;
* {@link MockMvcResultMatchers#request}.
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 3.2
*/
public
class
RequestResultMatchers
{
/**
* Protected constructor.
* Use {@link MockMvcResultMatchers#request()}.
*
<p>
Use {@link MockMvcResultMatchers#request()}.
*/
protected
RequestResultMatchers
()
{
}
/**
* Assert a request attribute value with the given Hamcrest {@link Matcher}.
* Whether asynchronous processing started, usually as a result of a
* Assert whether asynchronous processing started, usually as a result of a
* controller method returning {@link Callable} or {@link DeferredResult}.
* The test will await the completion of a {@code Callable} so that
*
<p>
The test will await the completion of a {@code Callable} so that
* {@link #asyncResult(Matcher)} can be used to assert the resulting value.
* Neither a {@code Callable} nor a {@code DeferredResult} will complete
* processing all the way since a {@link MockHttpServletRequest} does not
...
...
@@ -63,13 +63,13 @@ public class RequestResultMatchers {
@Override
public
void
match
(
MvcResult
result
)
{
HttpServletRequest
request
=
result
.
getRequest
();
assert
Equals
(
"Async started"
,
true
,
request
.
isAsyncStarted
()
);
assert
AsyncStarted
(
request
);
}
};
}
/**
* Assert that asynchronous processing was not start.
* Assert that asynchronous processing was not start
ed
.
* @see #asyncStarted()
*/
public
ResultMatcher
asyncNotStarted
()
{
...
...
@@ -84,6 +84,8 @@ public class RequestResultMatchers {
/**
* Assert the result from asynchronous processing with the given matcher.
* <p>This method can be used when a controller method returns {@link Callable}
* or {@link WebAsyncTask}.
*/
public
<
T
>
ResultMatcher
asyncResult
(
final
Matcher
<
T
>
matcher
)
{
return
new
ResultMatcher
()
{
...
...
@@ -91,7 +93,7 @@ public class RequestResultMatchers {
@SuppressWarnings
(
"unchecked"
)
public
void
match
(
MvcResult
result
)
{
HttpServletRequest
request
=
result
.
getRequest
();
assert
Equals
(
"Async started"
,
true
,
request
.
isAsyncStarted
()
);
assert
AsyncStarted
(
request
);
assertThat
(
"Async result"
,
(
T
)
result
.
getAsyncResult
(),
matcher
);
}
};
...
...
@@ -99,7 +101,7 @@ public class RequestResultMatchers {
/**
* Assert the result from asynchronous processing.
* This method can be used when a controller method returns {@link Callable}
*
<p>
This method can be used when a controller method returns {@link Callable}
* or {@link WebAsyncTask}. The value matched is the value returned from the
* {@code Callable} or the exception raised.
*/
...
...
@@ -108,7 +110,7 @@ public class RequestResultMatchers {
@Override
public
void
match
(
MvcResult
result
)
{
HttpServletRequest
request
=
result
.
getRequest
();
assert
Equals
(
"Async started"
,
true
,
request
.
isAsyncStarted
()
);
assert
AsyncStarted
(
request
);
assertEquals
(
"Async result"
,
expectedResult
,
result
.
getAsyncResult
());
}
};
...
...
@@ -149,21 +151,25 @@ public class RequestResultMatchers {
@SuppressWarnings
(
"unchecked"
)
public
void
match
(
MvcResult
result
)
{
T
value
=
(
T
)
result
.
getRequest
().
getSession
().
getAttribute
(
name
);
assertThat
(
"
Request
attribute"
,
value
,
matcher
);
assertThat
(
"
Session
attribute"
,
value
,
matcher
);
}
};
}
/**
* Assert a session attribute value.
.
* Assert a session attribute value.
*/
public
<
T
>
ResultMatcher
sessionAttribute
(
final
String
name
,
final
Object
value
)
{
return
new
ResultMatcher
()
{
@Override
public
void
match
(
MvcResult
result
)
{
assertEquals
(
"
Request
attribute"
,
value
,
result
.
getRequest
().
getSession
().
getAttribute
(
name
));
assertEquals
(
"
Session
attribute"
,
value
,
result
.
getRequest
().
getSession
().
getAttribute
(
name
));
}
};
}
private
static
void
assertAsyncStarted
(
HttpServletRequest
request
)
{
assertEquals
(
"Async started"
,
true
,
request
.
isAsyncStarted
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录