Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
普通程序员一名
spring-framework
提交
7954dc7a
S
spring-framework
项目概览
普通程序员一名
/
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,发现更多精彩内容 >>
提交
7954dc7a
编写于
3月 20, 2021
作者:
R
Rebwon
提交者:
Sam Brannen
4月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish tests
Closes gh-26708
上级
22d90120
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
32 deletion
+32
-32
spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java
...bstractContainerEntityManagerFactoryIntegrationTests.java
+2
-3
spring-web/src/test/java/org/springframework/http/HttpEntityTests.java
...c/test/java/org/springframework/http/HttpEntityTests.java
+14
-14
spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java
...gframework/http/server/ServletServerHttpRequestTests.java
+16
-15
未找到文件。
spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java
浏览文件 @
7954dc7a
/*
* Copyright 2002-20
19
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -224,8 +224,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
q
.
setFlushMode
(
FlushModeType
.
AUTO
);
List
<
Person
>
people
=
q
.
getResultList
();
assertThat
(
people
.
size
()).
isEqualTo
(
0
);
assertThatExceptionOfType
(
Exception
.
class
).
isThrownBy
(()
->
q
.
getSingleResult
())
assertThatExceptionOfType
(
Exception
.
class
).
isThrownBy
(
q:
:
getSingleResult
)
.
withMessageContaining
(
"closed"
);
// We would typically expect an IllegalStateException, but Hibernate throws a
// PersistenceException. So we assert the contents of the exception message instead.
...
...
spring-web/src/test/java/org/springframework/http/HttpEntityTests.java
浏览文件 @
7954dc7a
/*
* Copyright 2002-20
19
the original author or authors.
* Copyright 2002-20
21
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,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
HttpEntityTests
{
@Test
public
void
noHeaders
()
{
void
noHeaders
()
{
String
body
=
"foo"
;
HttpEntity
<
String
>
entity
=
new
HttpEntity
<>(
body
);
assertThat
(
entity
.
getBody
()).
isSameAs
(
body
);
...
...
@@ -39,7 +39,7 @@ public class HttpEntityTests {
}
@Test
public
void
httpHeaders
()
{
void
httpHeaders
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
TEXT_PLAIN
);
String
body
=
"foo"
;
...
...
@@ -50,7 +50,7 @@ public class HttpEntityTests {
}
@Test
public
void
multiValueMap
()
{
void
multiValueMap
()
{
MultiValueMap
<
String
,
String
>
map
=
new
LinkedMultiValueMap
<>();
map
.
set
(
"Content-Type"
,
"text/plain"
);
String
body
=
"foo"
;
...
...
@@ -61,30 +61,30 @@ public class HttpEntityTests {
}
@Test
public
void
testEquals
()
{
void
testEquals
()
{
MultiValueMap
<
String
,
String
>
map1
=
new
LinkedMultiValueMap
<>();
map1
.
set
(
"Content-Type"
,
"text/plain"
);
MultiValueMap
<
String
,
String
>
map2
=
new
LinkedMultiValueMap
<>();
map2
.
set
(
"Content-Type"
,
"application/json"
);
assertThat
(
new
HttpEntity
<>().
equals
(
new
HttpEntity
<
Object
>())).
isTrue
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<
Object
>())).
isFalse
();
assertThat
(
new
HttpEntity
<>().
equals
(
new
HttpEntity
<
Object
>(
map2
))).
isFalse
();
assertThat
(
new
HttpEntity
<>().
equals
(
new
HttpEntity
<>())).
isTrue
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<>())).
isFalse
();
assertThat
(
new
HttpEntity
<>().
equals
(
new
HttpEntity
<>(
map2
))).
isFalse
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<
Object
>(
map1
))).
isTrue
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<
Object
>(
map2
))).
isFalse
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<>(
map1
))).
isTrue
();
assertThat
(
new
HttpEntity
<>(
map1
).
equals
(
new
HttpEntity
<>(
map2
))).
isFalse
();
assertThat
(
new
HttpEntity
<
String
>(
null
,
null
).
equals
(
new
HttpEntity
<
String
>(
null
,
null
))).
isTrue
();
assertThat
(
new
HttpEntity
<>(
"foo"
,
null
).
equals
(
new
HttpEntity
<
String
>(
null
,
null
))).
isFalse
();
assertThat
(
new
HttpEntity
<
String
>(
null
,
null
).
equals
(
new
HttpEntity
<>(
"bar"
,
null
))).
isFalse
();
assertThat
(
new
HttpEntity
<>(
"foo"
,
map1
).
equals
(
new
HttpEntity
<
String
>(
"foo"
,
map1
))).
isTrue
();
assertThat
(
new
HttpEntity
<>(
"foo"
,
map1
).
equals
(
new
HttpEntity
<
String
>(
"bar"
,
map1
))).
isFalse
();
assertThat
(
new
HttpEntity
<>(
"foo"
,
map1
).
equals
(
new
HttpEntity
<>(
"foo"
,
map1
))).
isTrue
();
assertThat
(
new
HttpEntity
<>(
"foo"
,
map1
).
equals
(
new
HttpEntity
<>(
"bar"
,
map1
))).
isFalse
();
}
@Test
public
void
responseEntity
()
{
void
responseEntity
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
TEXT_PLAIN
);
String
body
=
"foo"
;
...
...
@@ -104,7 +104,7 @@ public class HttpEntityTests {
}
@Test
public
void
requestEntity
()
throws
Exception
{
void
requestEntity
()
throws
Exception
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
TEXT_PLAIN
);
String
body
=
"foo"
;
...
...
spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java
浏览文件 @
7954dc7a
/*
* Copyright 2002-20
19
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -45,20 +45,20 @@ public class ServletServerHttpRequestTests {
@BeforeEach
public
void
create
()
{
void
create
()
{
mockRequest
=
new
MockHttpServletRequest
();
request
=
new
ServletServerHttpRequest
(
mockRequest
);
}
@Test
public
void
getMethod
()
{
void
getMethod
()
{
mockRequest
.
setMethod
(
"POST"
);
assertThat
(
request
.
getMethod
()).
as
(
"Invalid method"
).
isEqualTo
(
HttpMethod
.
POST
);
}
@Test
public
void
getUriForSimplePath
()
throws
URISyntaxException
{
void
getUriForSimplePath
()
throws
URISyntaxException
{
URI
uri
=
new
URI
(
"https://example.com/path"
);
mockRequest
.
setScheme
(
uri
.
getScheme
());
mockRequest
.
setServerName
(
uri
.
getHost
());
...
...
@@ -69,7 +69,7 @@ public class ServletServerHttpRequestTests {
}
@Test
public
void
getUriWithQueryString
()
throws
URISyntaxException
{
void
getUriWithQueryString
()
throws
URISyntaxException
{
URI
uri
=
new
URI
(
"https://example.com/path?query"
);
mockRequest
.
setScheme
(
uri
.
getScheme
());
mockRequest
.
setServerName
(
uri
.
getHost
());
...
...
@@ -80,7 +80,7 @@ public class ServletServerHttpRequestTests {
}
@Test
// SPR-16414
public
void
getUriWithQueryParam
()
throws
URISyntaxException
{
void
getUriWithQueryParam
()
throws
URISyntaxException
{
mockRequest
.
setScheme
(
"https"
);
mockRequest
.
setServerPort
(
443
);
mockRequest
.
setServerName
(
"example.com"
);
...
...
@@ -90,7 +90,7 @@ public class ServletServerHttpRequestTests {
}
@Test
// SPR-16414
public
void
getUriWithMalformedQueryParam
()
throws
URISyntaxException
{
void
getUriWithMalformedQueryParam
()
throws
URISyntaxException
{
mockRequest
.
setScheme
(
"https"
);
mockRequest
.
setServerPort
(
443
);
mockRequest
.
setServerName
(
"example.com"
);
...
...
@@ -100,7 +100,7 @@ public class ServletServerHttpRequestTests {
}
@Test
// SPR-13876
public
void
getUriWithEncoding
()
throws
URISyntaxException
{
void
getUriWithEncoding
()
throws
URISyntaxException
{
URI
uri
=
new
URI
(
"https://example.com/%E4%B8%AD%E6%96%87"
+
"?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework"
);
mockRequest
.
setScheme
(
uri
.
getScheme
());
...
...
@@ -112,7 +112,7 @@ public class ServletServerHttpRequestTests {
}
@Test
public
void
getHeaders
()
{
void
getHeaders
()
{
String
headerName
=
"MyHeader"
;
String
headerValue1
=
"value1"
;
String
headerValue2
=
"value2"
;
...
...
@@ -132,7 +132,7 @@ public class ServletServerHttpRequestTests {
}
@Test
public
void
getHeadersWithEmptyContentTypeAndEncoding
()
{
void
getHeadersWithEmptyContentTypeAndEncoding
()
{
String
headerName
=
"MyHeader"
;
String
headerValue1
=
"value1"
;
String
headerValue2
=
"value2"
;
...
...
@@ -152,8 +152,8 @@ public class ServletServerHttpRequestTests {
}
@Test
public
void
getBody
()
throws
IOException
{
byte
[]
content
=
"Hello World"
.
getBytes
(
"UTF-8"
);
void
getBody
()
throws
IOException
{
byte
[]
content
=
"Hello World"
.
getBytes
(
StandardCharsets
.
UTF_8
);
mockRequest
.
setContent
(
content
);
byte
[]
result
=
FileCopyUtils
.
copyToByteArray
(
request
.
getBody
());
...
...
@@ -161,16 +161,17 @@ public class ServletServerHttpRequestTests {
}
@Test
public
void
getFormBody
()
throws
IOException
{
void
getFormBody
()
throws
IOException
{
// Charset (SPR-8676)
mockRequest
.
setContentType
(
"application/x-www-form-urlencoded; charset=UTF-8"
);
mockRequest
.
setMethod
(
"POST"
);
mockRequest
.
addParameter
(
"name 1"
,
"value 1"
);
mockRequest
.
addParameter
(
"name 2"
,
new
String
[]
{
"value 2+1"
,
"value 2+2"
}
);
mockRequest
.
addParameter
(
"name 2"
,
"value 2+1"
,
"value 2+2"
);
mockRequest
.
addParameter
(
"name 3"
,
(
String
)
null
);
byte
[]
result
=
FileCopyUtils
.
copyToByteArray
(
request
.
getBody
());
byte
[]
content
=
"name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3"
.
getBytes
(
"UTF-8"
);
byte
[]
content
=
"name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3"
.
getBytes
(
StandardCharsets
.
UTF_8
);
assertThat
(
result
).
as
(
"Invalid content returned"
).
isEqualTo
(
content
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录