Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
cf1bf3d9
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,发现更多精彩内容 >>
提交
cf1bf3d9
编写于
8月 20, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish parameterized tests
上级
617863ae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
85 addition
and
85 deletion
+85
-85
spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java
...upport/GenericXmlContextLoaderResourceLocationsTests.java
+59
-59
spring-test/src/test/resources/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml
...sts$ClasspathExistentDefaultLocationsTestCase-context.xml
+0
-0
spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
...ingframework/web/client/RestTemplateIntegrationTests.java
+2
-2
spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java
...eb/context/request/ServletWebRequestHttpMethodsTests.java
+24
-24
未找到文件。
spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java
浏览文件 @
cf1bf3d9
...
...
@@ -16,12 +16,12 @@
package
org.springframework.test.context.support
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.stream.Stream
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.Arguments
;
import
org.junit.jupiter.params.provider.MethodSource
;
import
org.springframework.core.annotation.AnnotationUtils
;
...
...
@@ -31,6 +31,7 @@ import org.springframework.util.ClassUtils;
import
org.springframework.util.ObjectUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
jupiter
.
params
.
provider
.
Arguments
.
arguments
;
/**
* Unit test which verifies proper
...
...
@@ -50,83 +51,82 @@ class GenericXmlContextLoaderResourceLocationsTests {
private
static
final
Log
logger
=
LogFactory
.
getLog
(
GenericXmlContextLoaderResourceLocationsTests
.
class
);
static
Collection
<
Object
[]>
contextConfigurationLocationsData
()
{
@ContextConfiguration
class
ClasspathNonExistentDefaultLocationsTestCase
{
}
@ContextConfiguration
class
ClasspathExistentDefaultLocationsTestCase
{
}
@ContextConfiguration
({
"context1.xml"
,
"context2.xml"
})
class
ImplicitClasspathLocationsTestCase
{
}
@ParameterizedTest
(
name
=
"{0}"
)
@MethodSource
(
"contextConfigurationLocationsData"
)
void
assertContextConfigurationLocations
(
String
testClassName
,
String
[]
expectedLocations
)
throws
Exception
{
Class
<?>
testClass
=
ClassUtils
.
forName
(
getClass
().
getName
()
+
"$"
+
testClassName
,
getClass
().
getClassLoader
());
@ContextConfiguration
(
"classpath:context.xml"
)
class
ExplicitClasspathLocationsTestCase
{
}
final
ContextConfiguration
contextConfig
=
testClass
.
getAnnotation
(
ContextConfiguration
.
class
);
final
ContextLoader
contextLoader
=
new
GenericXmlContextLoader
();
final
String
[]
configuredLocations
=
(
String
[])
AnnotationUtils
.
getValue
(
contextConfig
);
final
String
[]
processedLocations
=
contextLoader
.
processLocations
(
testClass
,
configuredLocations
);
@ContextConfiguration
(
"file:/testing/directory/context.xml"
)
class
ExplicitFileLocationsTestCase
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"----------------------------------------------------------------------"
);
logger
.
debug
(
"Configured locations: "
+
ObjectUtils
.
nullSafeToString
(
configuredLocations
));
logger
.
debug
(
"Expected locations: "
+
ObjectUtils
.
nullSafeToString
(
expectedLocations
));
logger
.
debug
(
"Processed locations: "
+
ObjectUtils
.
nullSafeToString
(
processedLocations
));
}
@ContextConfiguration
(
"https://example.com/context.xml"
)
class
ExplicitUrlLocationsTestCase
{
}
assertThat
(
processedLocations
).
as
(
"Verifying locations for test ["
+
testClass
+
"]."
).
isEqualTo
(
expectedLocations
);
}
@ContextConfiguration
({
"context1.xml"
,
"classpath:context2.xml"
,
"/context3.xml"
,
"file:/testing/directory/context.xml"
,
"https://example.com/context.xml"
})
class
ExplicitMixedPathTypesLocationsTestCase
{
}
static
Stream
<
Arguments
>
contextConfigurationLocationsData
()
{
return
Stream
.
of
(
arguments
(
ClasspathNonExistentDefaultLocationsTestCase
.
class
.
getSimpleName
(),
array
()),
return
Arrays
.
asList
(
new
Object
[][]
{
arguments
(
ClasspathExistentDefaultLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml"
)),
{
ClasspathNonExistentDefaultLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{}
},
arguments
(
ImplicitClasspathLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"classpath:/org/springframework/test/context/support/context1.xml"
,
"classpath:/org/springframework/test/context/support/context2.xml"
)),
{
ClasspathExistentDefaultLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$1ClasspathExistentDefaultLocationsTestCase-context.xml"
}
},
arguments
(
ExplicitClasspathLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"classpath:context.xml"
)),
{
ImplicitClasspathLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"classpath:/org/springframework/test/context/support/context1.xml"
,
"classpath:/org/springframework/test/context/support/context2.xml"
}
},
arguments
(
ExplicitFileLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"file:/testing/directory/context.xml"
)),
{
ExplicitClasspathLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"classpath:context.xml"
}
}
,
arguments
(
ExplicitUrlLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"https://example.com/context.xml"
))
,
{
ExplicitFileLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"file:/testing/directory/context.xml"
}
},
arguments
(
ExplicitMixedPathTypesLocationsTestCase
.
class
.
getSimpleName
(),
array
(
"classpath:/org/springframework/test/context/support/context1.xml"
,
"classpath:context2.xml"
,
"classpath:/context3.xml"
,
"file:/testing/directory/context.xml"
,
"https://example.com/context.xml"
))
);
}
{
ExplicitUrlLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"https://example.com/context.xml"
}
},
private
static
String
[]
array
(
String
...
elements
)
{
return
elements
;
}
{
ExplicitMixedPathTypesLocationsTestCase
.
class
.
getSimpleName
(),
new
String
[]
{
"classpath:/org/springframework/test/context/support/context1.xml"
,
"classpath:context2.xml"
,
"classpath:/context3.xml"
,
"file:/testing/directory/context.xml"
,
"https://example.com/context.xml"
}
}
@ContextConfiguration
class
ClasspathNonExistentDefaultLocationsTestCase
{
}
});
@ContextConfiguration
class
ClasspathExistentDefaultLocationsTestCase
{
}
@ContextConfiguration
({
"context1.xml"
,
"context2.xml"
})
class
ImplicitClasspathLocationsTestCase
{
}
@ParameterizedTest
(
name
=
"{0}"
)
@MethodSource
(
"contextConfigurationLocationsData"
)
void
assertContextConfigurationLocations
(
String
testClassName
,
String
[]
expectedLocations
)
throws
Exception
{
Class
<?>
testClass
=
ClassUtils
.
forName
(
getClass
().
getName
()
+
"$1"
+
testClassName
,
getClass
().
getClassLoader
());
@ContextConfiguration
(
"classpath:context.xml"
)
class
ExplicitClasspathLocationsTestCase
{
}
final
ContextConfiguration
contextConfig
=
testClass
.
getAnnotation
(
ContextConfiguration
.
class
);
final
ContextLoader
contextLoader
=
new
GenericXmlContextLoader
();
final
String
[]
configuredLocations
=
(
String
[])
AnnotationUtils
.
getValue
(
contextConfig
);
final
String
[]
processedLocations
=
contextLoader
.
processLocations
(
testClass
,
configuredLocations
);
@ContextConfiguration
(
"file:/testing/directory/context.xml"
)
class
ExplicitFileLocationsTestCase
{
}
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"----------------------------------------------------------------------"
);
logger
.
debug
(
"Configured locations: "
+
ObjectUtils
.
nullSafeToString
(
configuredLocations
));
logger
.
debug
(
"Expected locations: "
+
ObjectUtils
.
nullSafeToString
(
expectedLocations
));
logger
.
debug
(
"Processed locations: "
+
ObjectUtils
.
nullSafeToString
(
processedLocations
));
}
@ContextConfiguration
(
"https://example.com/context.xml"
)
class
ExplicitUrlLocationsTestCase
{
}
assertThat
(
processedLocations
).
as
(
"Verifying locations for test ["
+
testClass
+
"]."
).
isEqualTo
(
expectedLocations
);
@ContextConfiguration
({
"context1.xml"
,
"classpath:context2.xml"
,
"/context3.xml"
,
"file:/testing/directory/context.xml"
,
"https://example.com/context.xml"
})
class
ExplicitMixedPathTypesLocationsTestCase
{
}
}
spring-test/src/test/resources/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$
1
ClasspathExistentDefaultLocationsTestCase-context.xml
→
spring-test/src/test/resources/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml
浏览文件 @
cf1bf3d9
文件已移动
spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
浏览文件 @
cf1bf3d9
...
...
@@ -82,13 +82,13 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
@ParameterizedTest
@ParameterizedTest
(
name
=
"{0}"
)
@MethodSource
(
"clientHttpRequestFactories"
)
@interface
ParameterizedRestTemplateTest
{
}
@SuppressWarnings
(
"deprecation"
)
static
Stream
<
?
extends
ClientHttpRequestFactory
>
clientHttpRequestFactories
()
{
static
Stream
<
ClientHttpRequestFactory
>
clientHttpRequestFactories
()
{
return
Stream
.
of
(
new
SimpleClientHttpRequestFactory
(),
new
HttpComponentsClientHttpRequestFactory
(),
...
...
spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java
浏览文件 @
cf1bf3d9
...
...
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Markus Malkusch
* @author Sam Brannen
*/
public
class
ServletWebRequestHttpMethodsTests
{
class
ServletWebRequestHttpMethodsTests
{
private
static
final
String
CURRENT_TIME
=
"Wed, 9 Apr 2014 09:57:42 GMT"
;
...
...
@@ -54,7 +54,7 @@ public class ServletWebRequestHttpMethodsTests {
@ParameterizedHttpMethodTest
public
void
checkNotModifiedNon2xxStatus
(
String
method
)
{
void
checkNotModifiedNon2xxStatus
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
currentDate
.
getTime
();
...
...
@@ -67,7 +67,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
// SPR-13516
public
void
checkNotModifiedInvalidStatus
(
String
method
)
{
void
checkNotModifiedInvalidStatus
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
currentDate
.
getTime
();
...
...
@@ -78,7 +78,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
// SPR-14559
public
void
checkNotModifiedInvalidIfNoneMatchHeader
(
String
method
)
{
void
checkNotModifiedInvalidIfNoneMatchHeader
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"etagvalue\""
;
...
...
@@ -89,7 +89,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedHeaderAlreadySet
(
String
method
)
{
void
checkNotModifiedHeaderAlreadySet
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
currentDate
.
getTime
();
...
...
@@ -103,7 +103,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedTimestamp
(
String
method
)
{
void
checkNotModifiedTimestamp
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
currentDate
.
getTime
();
...
...
@@ -115,7 +115,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkModifiedTimestamp
(
String
method
)
{
void
checkModifiedTimestamp
(
String
method
)
{
setUpRequest
(
method
);
long
oneMinuteAgo
=
currentDate
.
getTime
()
-
(
1000
*
60
);
...
...
@@ -127,7 +127,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedETag
(
String
method
)
{
void
checkNotModifiedETag
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -139,7 +139,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedETagWithSeparatorChars
(
String
method
)
{
void
checkNotModifiedETagWithSeparatorChars
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo, Bar\""
;
...
...
@@ -152,7 +152,7 @@ public class ServletWebRequestHttpMethodsTests {
@ParameterizedHttpMethodTest
public
void
checkModifiedETag
(
String
method
)
{
void
checkModifiedETag
(
String
method
)
{
setUpRequest
(
method
);
String
currentETag
=
"\"Foo\""
;
...
...
@@ -165,7 +165,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedUnpaddedETag
(
String
method
)
{
void
checkNotModifiedUnpaddedETag
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"Foo"
;
...
...
@@ -178,7 +178,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkModifiedUnpaddedETag
(
String
method
)
{
void
checkModifiedUnpaddedETag
(
String
method
)
{
setUpRequest
(
method
);
String
currentETag
=
"Foo"
;
...
...
@@ -191,7 +191,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedWildcardIsIgnored
(
String
method
)
{
void
checkNotModifiedWildcardIsIgnored
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -203,7 +203,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedETagAndTimestamp
(
String
method
)
{
void
checkNotModifiedETagAndTimestamp
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -217,7 +217,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
// SPR-14224
public
void
checkNotModifiedETagAndModifiedTimestamp
(
String
method
)
{
void
checkNotModifiedETagAndModifiedTimestamp
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -233,7 +233,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkModifiedETagAndNotModifiedTimestamp
(
String
method
)
{
void
checkModifiedETagAndNotModifiedTimestamp
(
String
method
)
{
setUpRequest
(
method
);
String
currentETag
=
"\"Foo\""
;
...
...
@@ -249,7 +249,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedETagWeakStrong
(
String
method
)
{
void
checkNotModifiedETagWeakStrong
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -262,7 +262,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedETagStrongWeak
(
String
method
)
{
void
checkNotModifiedETagStrongWeak
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Foo\""
;
...
...
@@ -274,7 +274,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedMultipleETags
(
String
method
)
{
void
checkNotModifiedMultipleETags
(
String
method
)
{
setUpRequest
(
method
);
String
etag
=
"\"Bar\""
;
...
...
@@ -287,7 +287,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedTimestampWithLengthPart
(
String
method
)
{
void
checkNotModifiedTimestampWithLengthPart
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
ZonedDateTime
.
parse
(
CURRENT_TIME
,
RFC_1123_DATE_TIME
).
toInstant
().
toEpochMilli
();
...
...
@@ -300,7 +300,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkModifiedTimestampWithLengthPart
(
String
method
)
{
void
checkModifiedTimestampWithLengthPart
(
String
method
)
{
setUpRequest
(
method
);
long
epochTime
=
ZonedDateTime
.
parse
(
CURRENT_TIME
,
RFC_1123_DATE_TIME
).
toInstant
().
toEpochMilli
();
...
...
@@ -313,7 +313,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedTimestampConditionalPut
(
String
method
)
{
void
checkNotModifiedTimestampConditionalPut
(
String
method
)
{
setUpRequest
(
method
);
long
currentEpoch
=
currentDate
.
getTime
();
...
...
@@ -327,7 +327,7 @@ public class ServletWebRequestHttpMethodsTests {
}
@ParameterizedHttpMethodTest
public
void
checkNotModifiedTimestampConditionalPutConflict
(
String
method
)
{
void
checkNotModifiedTimestampConditionalPutConflict
(
String
method
)
{
setUpRequest
(
method
);
long
currentEpoch
=
currentDate
.
getTime
();
...
...
@@ -348,7 +348,7 @@ public class ServletWebRequestHttpMethodsTests {
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
@ParameterizedTest
@ParameterizedTest
(
name
=
"{0}"
)
@ValueSource
(
strings
=
{
"GET"
,
"HEAD"
})
@interface
ParameterizedHttpMethodTest
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录