Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
8db73c80
S
spring-framework
项目概览
sesemomo
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
8db73c80
编写于
7月 18, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish MockRestServiceServer internals regarding "effectively final"
上级
42f033e4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
38 deletion
+38
-38
spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java
...work/test/web/client/MockMvcClientHttpRequestFactory.java
+2
-2
spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java
...amework/test/web/client/match/ContentRequestMatchers.java
+12
-12
spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java
...mework/test/web/client/match/JsonPathRequestMatchers.java
+4
-4
spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java
...mework/test/web/client/match/MockRestRequestMatchers.java
+11
-11
spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java
...framework/test/web/client/match/XpathRequestMatchers.java
+9
-9
未找到文件。
spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java
浏览文件 @
8db73c80
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -62,7 +62,7 @@ public class MockMvcClientHttpRequestFactory
@Override
public
ClientHttpRequest
createRequest
(
final
URI
uri
,
final
HttpMethod
httpMethod
)
{
public
ClientHttpRequest
createRequest
(
URI
uri
,
HttpMethod
httpMethod
)
{
return
new
MockClientHttpRequest
(
httpMethod
,
uri
)
{
@Override
public
ClientHttpResponse
executeInternal
()
throws
IOException
{
...
...
spring-test/src/main/java/org/springframework/test/web/client/match/ContentRequestMatchers.java
浏览文件 @
8db73c80
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -74,7 +74,7 @@ public class ContentRequestMatchers {
/**
* Assert the request content type as a {@link MediaType}.
*/
public
RequestMatcher
contentType
(
final
MediaType
expectedContentType
)
{
public
RequestMatcher
contentType
(
MediaType
expectedContentType
)
{
return
request
->
{
MediaType
actualContentType
=
request
.
getHeaders
().
getContentType
();
assertTrue
(
"Content type not set"
,
actualContentType
!=
null
);
...
...
@@ -94,7 +94,7 @@ public class ContentRequestMatchers {
* Assert the request content type is compatible with the given
* content type as defined by {@link MediaType#isCompatibleWith(MediaType)}.
*/
public
RequestMatcher
contentTypeCompatibleWith
(
final
MediaType
contentType
)
{
public
RequestMatcher
contentTypeCompatibleWith
(
MediaType
contentType
)
{
return
request
->
{
MediaType
actualContentType
=
request
.
getHeaders
().
getContentType
();
assertTrue
(
"Content type not set"
,
actualContentType
!=
null
);
...
...
@@ -108,7 +108,7 @@ public class ContentRequestMatchers {
/**
* Get the body of the request as a UTF-8 string and apply the given {@link Matcher}.
*/
public
RequestMatcher
string
(
final
Matcher
<?
super
String
>
matcher
)
{
public
RequestMatcher
string
(
Matcher
<?
super
String
>
matcher
)
{
return
request
->
{
MockClientHttpRequest
mockRequest
=
(
MockClientHttpRequest
)
request
;
assertThat
(
"Request content"
,
mockRequest
.
getBodyAsString
(),
matcher
);
...
...
@@ -118,7 +118,7 @@ public class ContentRequestMatchers {
/**
* Get the body of the request as a UTF-8 string and compare it to the given String.
*/
public
RequestMatcher
string
(
final
String
expectedContent
)
{
public
RequestMatcher
string
(
String
expectedContent
)
{
return
request
->
{
MockClientHttpRequest
mockRequest
=
(
MockClientHttpRequest
)
request
;
assertEquals
(
"Request content"
,
expectedContent
,
mockRequest
.
getBodyAsString
());
...
...
@@ -128,7 +128,7 @@ public class ContentRequestMatchers {
/**
* Compare the body of the request to the given byte array.
*/
public
RequestMatcher
bytes
(
final
byte
[]
expectedContent
)
{
public
RequestMatcher
bytes
(
byte
[]
expectedContent
)
{
return
request
->
{
MockClientHttpRequest
mockRequest
=
(
MockClientHttpRequest
)
request
;
assertEquals
(
"Request content"
,
expectedContent
,
mockRequest
.
getBodyAsBytes
());
...
...
@@ -139,7 +139,7 @@ public class ContentRequestMatchers {
* Parse the body as form data and compare to the given {@code MultiValueMap}.
* @since 4.3
*/
public
RequestMatcher
formData
(
final
MultiValueMap
<
String
,
String
>
expectedContent
)
{
public
RequestMatcher
formData
(
MultiValueMap
<
String
,
String
>
expectedContent
)
{
return
request
->
{
HttpInputMessage
inputMessage
=
new
HttpInputMessage
()
{
@Override
...
...
@@ -165,7 +165,7 @@ public class ContentRequestMatchers {
* <a href="http://xmlunit.sourceforge.net/">XMLUnit</a> library is available.
* @param expectedXmlContent the expected XML content
*/
public
RequestMatcher
xml
(
final
String
expectedXmlContent
)
{
public
RequestMatcher
xml
(
String
expectedXmlContent
)
{
return
new
AbstractXmlRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -177,7 +177,7 @@ public class ContentRequestMatchers {
/**
* Parse the request content as {@link Node} and apply the given {@link Matcher}.
*/
public
RequestMatcher
node
(
final
Matcher
<?
super
Node
>
matcher
)
{
public
RequestMatcher
node
(
Matcher
<?
super
Node
>
matcher
)
{
return
new
AbstractXmlRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -190,7 +190,7 @@ public class ContentRequestMatchers {
* Parse the request content as {@link DOMSource} and apply the given {@link Matcher}.
* @see <a href="https://code.google.com/p/xml-matchers/">https://code.google.com/p/xml-matchers/</a>
*/
public
RequestMatcher
source
(
final
Matcher
<?
super
Source
>
matcher
)
{
public
RequestMatcher
source
(
Matcher
<?
super
Source
>
matcher
)
{
return
new
AbstractXmlRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -209,7 +209,7 @@ public class ContentRequestMatchers {
* @param expectedJsonContent the expected JSON content
* @since 5.0.5
*/
public
RequestMatcher
json
(
final
String
expectedJsonContent
)
{
public
RequestMatcher
json
(
String
expectedJsonContent
)
{
return
json
(
expectedJsonContent
,
false
);
}
...
...
@@ -228,7 +228,7 @@ public class ContentRequestMatchers {
* @param strict enables strict checking
* @since 5.0.5
*/
public
RequestMatcher
json
(
final
String
expectedJsonContent
,
final
boolean
strict
)
{
public
RequestMatcher
json
(
String
expectedJsonContent
,
boolean
strict
)
{
return
request
->
{
try
{
MockClientHttpRequest
mockRequest
=
(
MockClientHttpRequest
)
request
;
...
...
spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java
浏览文件 @
8db73c80
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -61,7 +61,7 @@ public class JsonPathRequestMatchers {
* Evaluate the JSON path expression against the request content and
* assert the resulting value with the given Hamcrest {@link Matcher}.
*/
public
<
T
>
RequestMatcher
value
(
final
Matcher
<
T
>
matcher
)
{
public
<
T
>
RequestMatcher
value
(
Matcher
<
T
>
matcher
)
{
return
new
AbstractJsonPathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
IOException
,
ParseException
{
...
...
@@ -78,7 +78,7 @@ public class JsonPathRequestMatchers {
* to coerce an integer into a double.
* @since 4.3.3
*/
public
<
T
>
RequestMatcher
value
(
final
Matcher
<
T
>
matcher
,
final
Class
<
T
>
targetType
)
{
public
<
T
>
RequestMatcher
value
(
Matcher
<
T
>
matcher
,
Class
<
T
>
targetType
)
{
return
new
AbstractJsonPathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
IOException
,
ParseException
{
...
...
@@ -92,7 +92,7 @@ public class JsonPathRequestMatchers {
* Evaluate the JSON path expression against the request content and
* assert that the result is equal to the supplied value.
*/
public
RequestMatcher
value
(
final
Object
expectedValue
)
{
public
RequestMatcher
value
(
Object
expectedValue
)
{
return
new
AbstractJsonPathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
IOException
,
ParseException
{
...
...
spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java
浏览文件 @
8db73c80
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -62,7 +62,7 @@ public abstract class MockRestRequestMatchers {
* @param method the HTTP method
* @return the request matcher
*/
public
static
RequestMatcher
method
(
final
HttpMethod
method
)
{
public
static
RequestMatcher
method
(
HttpMethod
method
)
{
Assert
.
notNull
(
method
,
"'method' must not be null"
);
return
request
->
assertEquals
(
"Unexpected HttpMethod"
,
method
,
request
.
getMethod
());
}
...
...
@@ -72,7 +72,7 @@ public abstract class MockRestRequestMatchers {
* @param matcher the String matcher for the expected URI
* @return the request matcher
*/
public
static
RequestMatcher
requestTo
(
final
Matcher
<
String
>
matcher
)
{
public
static
RequestMatcher
requestTo
(
Matcher
<
String
>
matcher
)
{
Assert
.
notNull
(
matcher
,
"'matcher' must not be null"
);
return
request
->
assertThat
(
"Request URI"
,
request
.
getURI
().
toString
(),
matcher
);
}
...
...
@@ -82,7 +82,7 @@ public abstract class MockRestRequestMatchers {
* @param expectedUri the expected URI
* @return the request matcher
*/
public
static
RequestMatcher
requestTo
(
final
String
expectedUri
)
{
public
static
RequestMatcher
requestTo
(
String
expectedUri
)
{
Assert
.
notNull
(
expectedUri
,
"'uri' must not be null"
);
return
request
->
assertEquals
(
"Request URI"
,
expectedUri
,
request
.
getURI
().
toString
());
}
...
...
@@ -95,7 +95,7 @@ public abstract class MockRestRequestMatchers {
* @param uriVars zero or more URI variables to populate the expected URI
* @return the request matcher
*/
public
static
RequestMatcher
requestToUriTemplate
(
final
String
expectedUri
,
final
Object
...
uriVars
)
{
public
static
RequestMatcher
requestToUriTemplate
(
String
expectedUri
,
Object
...
uriVars
)
{
Assert
.
notNull
(
expectedUri
,
"'uri' must not be null"
);
URI
uri
=
UriComponentsBuilder
.
fromUriString
(
expectedUri
).
buildAndExpand
(
uriVars
).
encode
().
toUri
();
return
requestTo
(
uri
);
...
...
@@ -106,7 +106,7 @@ public abstract class MockRestRequestMatchers {
* @param uri the expected URI
* @return the request matcher
*/
public
static
RequestMatcher
requestTo
(
final
URI
uri
)
{
public
static
RequestMatcher
requestTo
(
URI
uri
)
{
Assert
.
notNull
(
uri
,
"'uri' must not be null"
);
return
request
->
assertEquals
(
"Unexpected request"
,
uri
,
request
.
getURI
());
}
...
...
@@ -115,7 +115,7 @@ public abstract class MockRestRequestMatchers {
* Assert request query parameter values with the given Hamcrest matcher(s).
*/
@SafeVarargs
public
static
RequestMatcher
queryParam
(
final
String
name
,
final
Matcher
<?
super
String
>...
matchers
)
{
public
static
RequestMatcher
queryParam
(
String
name
,
Matcher
<?
super
String
>...
matchers
)
{
return
request
->
{
MultiValueMap
<
String
,
String
>
params
=
getQueryParams
(
request
);
assertValueCount
(
"query param"
,
name
,
params
,
matchers
.
length
);
...
...
@@ -128,7 +128,7 @@ public abstract class MockRestRequestMatchers {
/**
* Assert request query parameter values.
*/
public
static
RequestMatcher
queryParam
(
final
String
name
,
final
String
...
expectedValues
)
{
public
static
RequestMatcher
queryParam
(
String
name
,
String
...
expectedValues
)
{
return
request
->
{
MultiValueMap
<
String
,
String
>
params
=
getQueryParams
(
request
);
assertValueCount
(
"query param"
,
name
,
params
,
expectedValues
.
length
);
...
...
@@ -143,7 +143,7 @@ public abstract class MockRestRequestMatchers {
}
private
static
void
assertValueCount
(
String
valueType
,
final
String
name
,
MultiValueMap
<
String
,
String
>
map
,
int
count
)
{
String
valueType
,
String
name
,
MultiValueMap
<
String
,
String
>
map
,
int
count
)
{
List
<
String
>
values
=
map
.
get
(
name
);
String
message
=
"Expected "
+
valueType
+
" <"
+
name
+
">"
;
...
...
@@ -159,7 +159,7 @@ public abstract class MockRestRequestMatchers {
* Assert request header values with the given Hamcrest matcher(s).
*/
@SafeVarargs
public
static
RequestMatcher
header
(
final
String
name
,
final
Matcher
<?
super
String
>...
matchers
)
{
public
static
RequestMatcher
header
(
String
name
,
Matcher
<?
super
String
>...
matchers
)
{
return
request
->
{
assertValueCount
(
"header"
,
name
,
request
.
getHeaders
(),
matchers
.
length
);
List
<
String
>
headerValues
=
request
.
getHeaders
().
get
(
name
);
...
...
@@ -173,7 +173,7 @@ public abstract class MockRestRequestMatchers {
/**
* Assert request header values.
*/
public
static
RequestMatcher
header
(
final
String
name
,
final
String
...
expectedValues
)
{
public
static
RequestMatcher
header
(
String
name
,
String
...
expectedValues
)
{
return
request
->
{
assertValueCount
(
"header"
,
name
,
request
.
getHeaders
(),
expectedValues
.
length
);
List
<
String
>
headerValues
=
request
.
getHeaders
().
get
(
name
);
...
...
spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java
浏览文件 @
8db73c80
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -64,7 +64,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert it with the given {@code Matcher<Node>}.
*/
public
<
T
>
RequestMatcher
node
(
final
Matcher
<?
super
Node
>
matcher
)
{
public
<
T
>
RequestMatcher
node
(
Matcher
<?
super
Node
>
matcher
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -101,7 +101,7 @@ public class XpathRequestMatchers {
* Apply the XPath and assert the number of nodes found with the given
* {@code Matcher<Integer>}.
*/
public
<
T
>
RequestMatcher
nodeCount
(
final
Matcher
<
Integer
>
matcher
)
{
public
<
T
>
RequestMatcher
nodeCount
(
Matcher
<
Integer
>
matcher
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -113,7 +113,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the number of nodes found.
*/
public
<
T
>
RequestMatcher
nodeCount
(
final
int
expectedCount
)
{
public
<
T
>
RequestMatcher
nodeCount
(
int
expectedCount
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -125,7 +125,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the String content found with the given matcher.
*/
public
<
T
>
RequestMatcher
string
(
final
Matcher
<?
super
String
>
matcher
)
{
public
<
T
>
RequestMatcher
string
(
Matcher
<?
super
String
>
matcher
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -137,7 +137,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the String content found.
*/
public
RequestMatcher
string
(
final
String
value
)
{
public
RequestMatcher
string
(
String
value
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -149,7 +149,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the number found with the given matcher.
*/
public
<
T
>
RequestMatcher
number
(
final
Matcher
<?
super
Double
>
matcher
)
{
public
<
T
>
RequestMatcher
number
(
Matcher
<?
super
Double
>
matcher
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -161,7 +161,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the number of nodes found.
*/
public
RequestMatcher
number
(
final
Double
value
)
{
public
RequestMatcher
number
(
Double
value
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
@@ -173,7 +173,7 @@ public class XpathRequestMatchers {
/**
* Apply the XPath and assert the boolean value found.
*/
public
<
T
>
RequestMatcher
booleanValue
(
final
Boolean
value
)
{
public
<
T
>
RequestMatcher
booleanValue
(
Boolean
value
)
{
return
new
AbstractXpathRequestMatcher
()
{
@Override
protected
void
matchInternal
(
MockClientHttpRequest
request
)
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录