Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9652430f
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 搜索 >>
提交
9652430f
编写于
12月 16, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
581b2b0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
47 deletion
+38
-47
spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultHandlers.java
...mework/test/web/servlet/result/MockMvcResultHandlers.java
+5
-8
spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java
...mework/test/web/servlet/result/MockMvcResultMatchers.java
+33
-39
未找到文件。
spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultHandlers.java
浏览文件 @
9652430f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -31,10 +31,6 @@ import org.springframework.util.CollectionUtils;
*/
public
abstract
class
MockMvcResultHandlers
{
private
MockMvcResultHandlers
()
{
}
/**
* Print {@link MvcResult} details to the "standard" output stream.
*/
...
...
@@ -43,18 +39,18 @@ public abstract class MockMvcResultHandlers {
}
/** An {@link PrintingResultHandler} that writes to the "standard" output stream */
/**
* A {@link PrintingResultHandler} that writes to the "standard" output stream.
*/
private
static
class
ConsolePrintingResultHandler
extends
PrintingResultHandler
{
public
ConsolePrintingResultHandler
()
{
super
(
new
ResultValuePrinter
()
{
@Override
public
void
printHeading
(
String
heading
)
{
System
.
out
.
println
();
System
.
out
.
println
(
String
.
format
(
"%20s:"
,
heading
));
}
@Override
public
void
printValue
(
String
label
,
Object
value
)
{
if
(
value
!=
null
&&
value
.
getClass
().
isArray
())
{
...
...
@@ -65,4 +61,5 @@ public abstract class MockMvcResultHandlers {
});
}
}
}
spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java
浏览文件 @
9652430f
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -28,13 +28,15 @@ import org.springframework.util.AntPathMatcher;
import
static
org
.
springframework
.
test
.
util
.
AssertionErrors
.*;
/**
* Static
,
factory methods for {@link ResultMatcher}-based result actions.
* Static factory methods for {@link ResultMatcher}-based result actions.
*
* <p><strong>Eclipse users:</strong> consider adding this class as a Java editor
* favorite. To navigate, open the Preferences and type "favorites".
* <h3>Eclipse Users</h3>
* <p>Consider adding this class as a Java editor favorite. To navigate to
* this setting, open the Preferences and type "favorites".
*
* @author Rossen Stoyanchev
* @author Brian Clozel
* @author Sam Brannen
* @since 3.2
*/
public
abstract
class
MockMvcResultMatchers
{
...
...
@@ -42,9 +44,6 @@ public abstract class MockMvcResultMatchers {
private
static
final
AntPathMatcher
pathMatcher
=
new
AntPathMatcher
();
private
MockMvcResultMatchers
()
{
}
/**
* Access to request-related assertions.
*/
...
...
@@ -82,12 +81,11 @@ public abstract class MockMvcResultMatchers {
/**
* Asserts the request was forwarded to the given URL.
* This methods accepts only exact matches.
*
<p>
This methods accepts only exact matches.
* @param expectedUrl the exact URL expected
*/
public
static
ResultMatcher
forwardedUrl
(
final
String
expectedUrl
)
{
return
new
ResultMatcher
()
{
@Override
public
void
match
(
MvcResult
result
)
{
assertEquals
(
"Forwarded URL"
,
expectedUrl
,
result
.
getResponse
().
getForwardedUrl
());
...
...
@@ -97,14 +95,14 @@ public abstract class MockMvcResultMatchers {
/**
* Asserts the request was forwarded to the given URL.
* This methods accepts {@link org.springframework.util.AntPathMatcher} expressions.
* <p>This methods accepts {@link org.springframework.util.AntPathMatcher}
* expressions.
* @param urlPattern an AntPath expression to match against
* @see org.springframework.util.AntPathMatcher
* @since 4.0
* @see org.springframework.util.AntPathMatcher
*/
public
static
ResultMatcher
forwardedUrlPattern
(
final
String
urlPattern
)
{
return
new
ResultMatcher
()
{
@Override
public
void
match
(
MvcResult
result
)
{
assertTrue
(
"AntPath expression"
,
pathMatcher
.
isPattern
(
urlPattern
));
...
...
@@ -116,12 +114,11 @@ public abstract class MockMvcResultMatchers {
/**
* Asserts the request was redirected to the given URL.
* This methods accepts only exact matches.
*
<p>
This methods accepts only exact matches.
* @param expectedUrl the exact URL expected
*/
public
static
ResultMatcher
redirectedUrl
(
final
String
expectedUrl
)
{
return
new
ResultMatcher
()
{
@Override
public
void
match
(
MvcResult
result
)
{
assertEquals
(
"Redirected URL"
,
expectedUrl
,
result
.
getResponse
().
getRedirectedUrl
());
...
...
@@ -131,14 +128,14 @@ public abstract class MockMvcResultMatchers {
/**
* Asserts the request was redirected to the given URL.
* This methods accepts {@link org.springframework.util.AntPathMatcher} expressions.
* <p>This method accepts {@link org.springframework.util.AntPathMatcher}
* expressions.
* @param expectedUrl an AntPath expression to match against
* @see org.springframework.util.AntPathMatcher
* @since 4.0
*/
public
static
ResultMatcher
redirectedUrlPattern
(
final
String
expectedUrl
)
{
return
new
ResultMatcher
()
{
@Override
public
void
match
(
MvcResult
result
)
{
assertTrue
(
"AntPath expression"
,
pathMatcher
.
isPattern
(
expectedUrl
));
...
...
@@ -170,13 +167,13 @@ public abstract class MockMvcResultMatchers {
}
/**
* Access to response body assertions using a <a
* href="http://goessner.net/articles/JsonPath/">JSONPath</a> expression to
* inspect a specific subset of the body. The JSON path expression can be a
* parameterized string using formatting specifiers as defined in
* Access to response body assertions using a
* <a href="https://github.com/jayway/JsonPath">JsonPath</a> expression
* to inspect a specific subset of the body.
* <p>The JSON path expression can be a parameterized string using
* formatting specifiers as defined in
* {@link String#format(String, Object...)}.
*
* @param expression the JSON path optionally parameterized with arguments
* @param expression the JSON path expression, optionally parameterized with arguments
* @param args arguments to parameterize the JSON path expression with
*/
public
static
JsonPathResultMatchers
jsonPath
(
String
expression
,
Object
...
args
)
{
...
...
@@ -184,11 +181,10 @@ public abstract class MockMvcResultMatchers {
}
/**
* Access to response body assertions using a <a
* href="http://goessner.net/articles/JsonPath/">JSONPath</a> expression to
* inspect a specific subset of the body and a Hamcrest match for asserting
* the value found at the JSON path.
*
* Access to response body assertions using a
* <a href="https://github.com/jayway/JsonPath">JsonPath</a> expression
* to inspect a specific subset of the body and a Hamcrest matcher for
* asserting the value found at the JSON path.
* @param expression the JSON path expression
* @param matcher a matcher for the value expected at the JSON path
*/
...
...
@@ -197,12 +193,11 @@ public abstract class MockMvcResultMatchers {
}
/**
* Access to response body assertions using an XPath to inspect a specific
* subset of the body. The XPath expression can be a parameterized string
* using formatting specifiers as defined in
* {@link String#format(String, Object...)}.
*
* @param expression the XPath optionally parameterized with arguments
* Access to response body assertions using an XPath expression to
* inspect a specific subset of the body.
* <p>The XPath expression can be a parameterized string using formatting
* specifiers as defined in {@link String#format(String, Object...)}.
* @param expression the XPath expression, optionally parameterized with arguments
* @param args arguments to parameterize the XPath expression with
*/
public
static
XpathResultMatchers
xpath
(
String
expression
,
Object
...
args
)
throws
XPathExpressionException
{
...
...
@@ -210,12 +205,11 @@ public abstract class MockMvcResultMatchers {
}
/**
* Access to response body assertions using an XPath to inspect a specific
* subset of the body. The XPath expression can be a parameterized string
* using formatting specifiers as defined in
* {@link String#format(String, Object...)}.
*
* @param expression the XPath optionally parameterized with arguments
* Access to response body assertions using an XPath expression to
* inspect a specific subset of the body.
* <p>The XPath expression can be a parameterized string using formatting
* specifiers as defined in {@link String#format(String, Object...)}.
* @param expression the XPath expression, optionally parameterized with arguments
* @param namespaces namespaces referenced in the XPath expression
* @param args arguments to parameterize the XPath expression with
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录