Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
74ccfe35
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 搜索 >>
提交
74ccfe35
编写于
8月 19, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish Spring's internal TestGroup support
上级
3fa4d638
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
90 addition
and
161 deletion
+90
-161
spring-core/src/test/java/org/springframework/tests/Assume.java
...-core/src/test/java/org/springframework/tests/Assume.java
+2
-19
spring-core/src/test/java/org/springframework/tests/AssumeTests.java
.../src/test/java/org/springframework/tests/AssumeTests.java
+18
-25
spring-core/src/test/java/org/springframework/tests/TestGroup.java
...re/src/test/java/org/springframework/tests/TestGroup.java
+26
-1
spring-core/src/test/java/org/springframework/tests/TestGroupTests.java
...c/test/java/org/springframework/tests/TestGroupTests.java
+16
-19
spring-core/src/test/java/org/springframework/tests/TestGroups.java
...e/src/test/java/org/springframework/tests/TestGroups.java
+0
-58
spring-core/src/test/java/org/springframework/tests/TestGroupsCondition.java
...t/java/org/springframework/tests/TestGroupsCondition.java
+1
-1
spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java
...text/junit4/concurrency/SpringJUnit4ConcurrencyTests.java
+1
-3
spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
...st/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
+12
-16
spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java
...htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java
+14
-19
未找到文件。
spring-core/src/test/java/org/springframework/tests/Assume.java
浏览文件 @
74ccfe35
...
...
@@ -43,10 +43,8 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
* @author Sam Brannen
* @since 3.2
* @see EnabledForTestGroups @EnabledForTestGroups
* @see #group(TestGroup)
* @see #group(TestGroup, Executable)
* @see #notLogging(Log)
* @see TestGroup
* @see TestGroups
*/
public
abstract
class
Assume
{
...
...
@@ -61,26 +59,11 @@ public abstract class Assume {
*/
@Deprecated
public
static
void
group
(
TestGroup
group
)
{
Set
<
TestGroup
>
testGroups
=
TestGroup
s
.
loadTestGroups
();
Set
<
TestGroup
>
testGroups
=
TestGroup
.
loadTestGroups
();
assumeTrue
(
testGroups
.
contains
(
group
),
()
->
"Requires inactive test group "
+
group
+
"; active test groups: "
+
testGroups
);
}
/**
* Assume that a particular {@link TestGroup} is active before executing the
* supplied {@link Executable}.
* <p>If the assumption fails, the executable will not be executed, but
* no {@link org.opentest4j.TestAbortedException} will be thrown.
* @param group the group that must be active
* @param executable the executable to execute if the test group is active
* @since 4.2
*/
public
static
void
group
(
TestGroup
group
,
Executable
executable
)
throws
Exception
{
if
(
TestGroups
.
loadTestGroups
().
contains
(
group
))
{
executable
.
execute
();
}
}
/**
* Assume that the specified log is not set to Trace or Debug.
* @param log the log to test
...
...
spring-core/src/test/java/org/springframework/tests/AssumeTests.java
浏览文件 @
74ccfe35
...
...
@@ -25,7 +25,9 @@ import org.opentest4j.TestAbortedException;
import
static
java
.
util
.
stream
.
Collectors
.
joining
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
fail
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatCode
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalStateException
;
import
static
org
.
springframework
.
tests
.
Assume
.
TEST_GROUPS_SYSTEM_PROPERTY
;
import
static
org
.
springframework
.
tests
.
TestGroup
.
CI
;
import
static
org
.
springframework
.
tests
.
TestGroup
.
LONG_RUNNING
;
...
...
@@ -61,28 +63,24 @@ class AssumeTests {
@SuppressWarnings
(
"deprecation"
)
void
assumeGroupWithNoActiveTestGroups
()
{
setTestGroups
(
""
);
Assume
.
group
(
LONG_RUNNING
);
fail
(
"assumption should have failed"
);
assertThatExceptionOfType
(
TestAbortedException
.
class
).
isThrownBy
(()
->
Assume
.
group
(
LONG_RUNNING
)
);
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
assumeGroupWithNoMatchingActiveTestGroup
()
{
setTestGroups
(
PERFORMANCE
,
CI
);
Assume
.
group
(
LONG_RUNNING
);
fail
(
"assumption should have failed"
);
assertThatExceptionOfType
(
TestAbortedException
.
class
).
isThrownBy
(()
->
Assume
.
group
(
LONG_RUNNING
));
}
@Test
@SuppressWarnings
(
"deprecation"
)
void
assumeGroupWithMatchingActiveTestGroup
()
{
setTestGroups
(
LONG_RUNNING
);
try
{
Assume
.
group
(
LONG_RUNNING
);
}
catch
(
TestAbortedException
ex
)
{
fail
(
"assumption should NOT have failed"
);
}
assertThatCode
(()
->
Assume
.
group
(
LONG_RUNNING
))
.
as
(
"assumption should NOT have failed"
)
.
doesNotThrowAnyException
();
}
@Test
...
...
@@ -101,22 +99,17 @@ class AssumeTests {
//
// java.lang.IllegalStateException: Failed to parse 'testGroups' system property:
// Unable to find test group 'bogus' when parsing testGroups value: 'all-bogus'.
// Available groups include: [LONG_RUNNING,PERFORMANCE,
JMXMP,
CI]
// Available groups include: [LONG_RUNNING,PERFORMANCE,CI]
setTestGroups
(
testGroups
);
try
{
Assume
.
group
(
LONG_RUNNING
);
fail
(
"assumption should have failed"
);
}
catch
(
IllegalStateException
ex
)
{
assertThat
(
ex
.
getMessage
()).
startsWith
(
"Failed to parse '"
+
TEST_GROUPS_SYSTEM_PROPERTY
+
"' system property: "
);
assertThat
(
ex
.
getCause
()).
isInstanceOf
(
IllegalArgumentException
.
class
);
assertThat
(
ex
.
getCause
().
getMessage
()).
isEqualTo
(
"Unable to find test group 'bogus' when parsing testGroups value: '"
+
testGroups
+
"'. Available groups include: [LONG_RUNNING,PERFORMANCE,CI]"
);
}
assertThatIllegalStateException
()
.
isThrownBy
(()
->
Assume
.
group
(
LONG_RUNNING
))
.
withMessageStartingWith
(
"Failed to parse '"
+
TEST_GROUPS_SYSTEM_PROPERTY
+
"' system property: "
)
.
withCauseInstanceOf
(
IllegalArgumentException
.
class
)
.
satisfies
(
ex
->
assertThat
(
ex
.
getCause
().
getMessage
()).
isEqualTo
(
"Unable to find test group 'bogus' when parsing testGroups value: '"
+
testGroups
+
"'. Available groups include: [LONG_RUNNING,PERFORMANCE,CI]"
));
}
private
void
setTestGroups
(
TestGroup
...
testGroups
)
{
...
...
spring-core/src/test/java/org/springframework/tests/TestGroup.java
浏览文件 @
74ccfe35
...
...
@@ -57,6 +57,31 @@ public enum TestGroup {
CI
;
/**
* Determine if this {@link TestGroup} is active.
* @since 5.2
*/
public
boolean
isActive
()
{
return
loadTestGroups
().
contains
(
this
);
}
private
static
final
String
TEST_GROUPS_SYSTEM_PROPERTY
=
"testGroups"
;
/**
* Load test groups dynamically instead of during static initialization in
* order to avoid a {@link NoClassDefFoundError} being thrown while attempting
* to load collaborator classes.
*/
static
Set
<
TestGroup
>
loadTestGroups
()
{
try
{
return
TestGroup
.
parse
(
System
.
getProperty
(
TEST_GROUPS_SYSTEM_PROPERTY
));
}
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
"Failed to parse '"
+
TEST_GROUPS_SYSTEM_PROPERTY
+
"' system property: "
+
ex
.
getMessage
(),
ex
);
}
}
/**
* Parse the specified comma separated string of groups.
* @param value the comma separated string of groups
...
...
@@ -64,7 +89,7 @@ public enum TestGroup {
* @throws IllegalArgumentException if any specified group name is not a
* valid {@link TestGroup}
*/
public
static
Set
<
TestGroup
>
parse
(
String
value
)
throws
IllegalArgumentException
{
static
Set
<
TestGroup
>
parse
(
String
value
)
throws
IllegalArgumentException
{
if
(!
StringUtils
.
hasText
(
value
))
{
return
Collections
.
emptySet
();
}
...
...
spring-core/src/test/java/org/springframework/tests/TestGroupTests.java
浏览文件 @
74ccfe35
...
...
@@ -25,67 +25,64 @@ import org.junit.jupiter.api.Test;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
/**
* Tests for {@link TestGroup}.
*
* @author Phillip Webb
* @author Sam Brannen
*/
public
class
TestGroupTests
{
class
TestGroupTests
{
@Test
public
void
parseNull
()
{
void
parseNull
()
{
assertThat
(
TestGroup
.
parse
(
null
)).
isEqualTo
(
Collections
.
emptySet
());
}
@Test
public
void
parseEmptyString
()
{
void
parseEmptyString
()
{
assertThat
(
TestGroup
.
parse
(
""
)).
isEqualTo
(
Collections
.
emptySet
());
}
@Test
public
void
parseBlankString
()
{
void
parseBlankString
()
{
assertThat
(
TestGroup
.
parse
(
" "
)).
isEqualTo
(
Collections
.
emptySet
());
}
@Test
public
void
parseWithSpaces
()
{
assertThat
(
TestGroup
.
parse
(
" PERFORMANCE, PERFORMANCE "
)).
containsOnly
(
TestGroup
.
PERFORMANCE
);
void
parseWithSpaces
()
{
assertThat
(
TestGroup
.
parse
(
" PERFORMANCE, PERFORMANCE "
)).
containsOnly
(
TestGroup
.
PERFORMANCE
);
}
@Test
public
void
parseInMixedCase
()
{
assertThat
(
TestGroup
.
parse
(
"performance, PERFormaNCE"
)).
containsOnly
(
TestGroup
.
PERFORMANCE
);
void
parseInMixedCase
()
{
assertThat
(
TestGroup
.
parse
(
"performance, PERFormaNCE"
)).
containsOnly
(
TestGroup
.
PERFORMANCE
);
}
@Test
public
void
parseMissing
()
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
TestGroup
.
parse
(
"performance, missing"
))
void
parseMissing
()
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
TestGroup
.
parse
(
"performance, missing"
))
.
withMessageContaining
(
"Unable to find test group 'missing' when parsing "
+
"testGroups value: 'performance, missing'. Available groups include: "
+
"[LONG_RUNNING,PERFORMANCE,CI]"
);
}
@Test
public
void
parseAll
()
{
void
parseAll
()
{
assertThat
(
TestGroup
.
parse
(
"all"
)).
isEqualTo
(
EnumSet
.
allOf
(
TestGroup
.
class
));
}
@Test
public
void
parseAllExceptPerformance
()
{
void
parseAllExceptPerformance
()
{
Set
<
TestGroup
>
expected
=
EnumSet
.
allOf
(
TestGroup
.
class
);
expected
.
remove
(
TestGroup
.
PERFORMANCE
);
assertThat
(
TestGroup
.
parse
(
"all-performance"
)).
isEqualTo
(
expected
);
}
@Test
public
void
parseAllExceptMissing
()
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
TestGroup
.
parse
(
"all-missing"
))
void
parseAllExceptMissing
()
{
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
TestGroup
.
parse
(
"all-missing"
))
.
withMessageContaining
(
"Unable to find test group 'missing' when parsing "
+
"testGroups value: 'all-missing'. Available groups include: "
+
"[LONG_RUNNING,PERFORMANCE,CI]"
);
...
...
spring-core/src/test/java/org/springframework/tests/TestGroups.java
已删除
100644 → 0
浏览文件 @
3fa4d638
/*
* Copyright 2002-2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.tests
;
import
java.util.Set
;
/**
* Utility methods for working with {@link TestGroup}s.
*
* @author Sam Brannen
* @author Rob Winch
* @author Phillip Webb
* @since 5.2
*/
public
abstract
class
TestGroups
{
static
final
String
TEST_GROUPS_SYSTEM_PROPERTY
=
"testGroups"
;
/**
* Determine if the provided {@link TestGroup} is active.
* @param group the group to check
* @since 5.2
*/
public
static
boolean
isGroupActive
(
TestGroup
group
)
{
return
loadTestGroups
().
contains
(
group
);
}
/**
* Load test groups dynamically instead of during static initialization in
* order to avoid a {@link NoClassDefFoundError} being thrown while attempting
* to load the {@link Assume} class.
*/
static
Set
<
TestGroup
>
loadTestGroups
()
{
try
{
return
TestGroup
.
parse
(
System
.
getProperty
(
TEST_GROUPS_SYSTEM_PROPERTY
));
}
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
"Failed to parse '"
+
TEST_GROUPS_SYSTEM_PROPERTY
+
"' system property: "
+
ex
.
getMessage
(),
ex
);
}
}
}
spring-core/src/test/java/org/springframework/tests/TestGroupsCondition.java
浏览文件 @
74ccfe35
...
...
@@ -49,7 +49,7 @@ class TestGroupsCondition implements ExecutionCondition {
}
TestGroup
[]
testGroups
=
optional
.
get
().
value
();
Assert
.
state
(
testGroups
.
length
>
0
,
"You must declare at least one TestGroup in @EnabledForTestGroups"
);
return
(
Arrays
.
stream
(
testGroups
).
anyMatch
(
TestGroup
s:
:
isGroup
Active
))
?
return
(
Arrays
.
stream
(
testGroups
).
anyMatch
(
TestGroup
:
:
is
Active
))
?
enabled
(
"Enabled for TestGroups: "
+
Arrays
.
toString
(
testGroups
))
:
disabled
(
"Disabled for TestGroups: "
+
Arrays
.
toString
(
testGroups
));
}
...
...
spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java
浏览文件 @
74ccfe35
...
...
@@ -35,7 +35,6 @@ import org.springframework.test.context.junit4.rules.BasicAnnotationConfigWacSpr
import
org.springframework.test.context.junit4.rules.SpringClassRule
;
import
org.springframework.test.context.junit4.rules.SpringMethodRule
;
import
org.springframework.tests.TestGroup
;
import
org.springframework.tests.TestGroups
;
import
org.springframework.util.ReflectionUtils
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
...
...
@@ -86,8 +85,7 @@ public class SpringJUnit4ConcurrencyTests {
@BeforeClass
public
static
void
abortIfLongRunningTestGroupIsNotEnabled
()
{
assumeTrue
(
"TestGroup "
+
TestGroup
.
LONG_RUNNING
+
" is not active."
,
TestGroups
.
isGroupActive
(
TestGroup
.
LONG_RUNNING
));
assumeTrue
(
"TestGroup "
+
TestGroup
.
LONG_RUNNING
+
" is not active."
,
TestGroup
.
LONG_RUNNING
.
isActive
());
}
@Test
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
浏览文件 @
74ccfe35
...
...
@@ -26,15 +26,12 @@ import com.gargoylesoftware.htmlunit.WebClient;
import
com.gargoylesoftware.htmlunit.WebRequest
;
import
com.gargoylesoftware.htmlunit.WebResponse
;
import
com.gargoylesoftware.htmlunit.util.Cookie
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.tests.Assume
;
import
org.springframework.tests.TestGroup
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
...
...
@@ -59,28 +56,21 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
@SpringJUnitWebConfig
class
MockMvcWebClientBuilderTests
{
@Autowired
private
WebApplicationContext
wac
;
private
MockMvc
mockMvc
;
@BeforeEach
void
setup
()
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
MockMvcWebClientBuilderTests
(
WebApplicationContext
wac
)
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
wac
).
build
();
}
@Test
void
mockMvcSetupNull
()
{
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcWebClientBuilder
.
mockMvcSetup
(
null
));
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcWebClientBuilder
.
mockMvcSetup
(
null
));
}
@Test
void
webAppContextSetupNull
()
{
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcWebClientBuilder
.
webAppContextSetup
(
null
));
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcWebClientBuilder
.
webAppContextSetup
(
null
));
}
@Test
...
...
@@ -88,7 +78,10 @@ class MockMvcWebClientBuilderTests {
WebClient
client
=
MockMvcWebClientBuilder
.
mockMvcSetup
(
this
.
mockMvc
).
build
();
assertMockMvcUsed
(
client
,
"http://localhost/test"
);
Assume
.
group
(
TestGroup
.
PERFORMANCE
,
()
->
assertMockMvcNotUsed
(
client
,
"https://spring.io/"
));
if
(
TestGroup
.
PERFORMANCE
.
isActive
())
{
assertMockMvcNotUsed
(
client
,
"https://spring.io/"
);
}
}
@Test
...
...
@@ -97,7 +90,10 @@ class MockMvcWebClientBuilderTests {
WebClient
client
=
MockMvcWebClientBuilder
.
mockMvcSetup
(
this
.
mockMvc
).
withDelegate
(
otherClient
).
build
();
assertMockMvcUsed
(
client
,
"http://localhost/test"
);
Assume
.
group
(
TestGroup
.
PERFORMANCE
,
()
->
assertMockMvcNotUsed
(
client
,
"https://spring.io/"
));
if
(
TestGroup
.
PERFORMANCE
.
isActive
())
{
assertMockMvcNotUsed
(
client
,
"https://spring.io/"
);
}
}
@Test
// SPR-14066
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/MockMvcHtmlUnitDriverBuilderTests.java
浏览文件 @
74ccfe35
...
...
@@ -20,16 +20,13 @@ import java.io.IOException;
import
javax.servlet.http.HttpServletRequest
;
import
com.gargoylesoftware.htmlunit.util.Cookie
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.htmlunit.HtmlUnitDriver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.tests.Assume
;
import
org.springframework.tests.TestGroup
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -52,30 +49,23 @@ class MockMvcHtmlUnitDriverBuilderTests {
private
static
final
String
EXPECTED_BODY
=
"MockMvcHtmlUnitDriverBuilderTests mvc"
;
@Autowired
private
WebApplicationContext
wac
;
private
MockMvc
mockMvc
;
private
HtmlUnitDriver
driver
;
@BeforeEach
void
setup
()
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
MockMvcHtmlUnitDriverBuilderTests
(
WebApplicationContext
wac
)
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
wac
).
build
();
}
@Test
void
webAppContextSetupNull
()
{
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcHtmlUnitDriverBuilder
.
webAppContextSetup
(
null
));
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcHtmlUnitDriverBuilder
.
webAppContextSetup
(
null
));
}
@Test
void
mockMvcSetupNull
()
{
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
null
));
assertThatIllegalArgumentException
().
isThrownBy
(()
->
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
null
));
}
@Test
...
...
@@ -84,7 +74,10 @@ class MockMvcHtmlUnitDriverBuilderTests {
this
.
driver
=
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
this
.
mockMvc
).
withDelegate
(
otherDriver
).
build
();
assertMockMvcUsed
(
"http://localhost/test"
);
Assume
.
group
(
TestGroup
.
PERFORMANCE
,
()
->
assertMockMvcNotUsed
(
"https://example.com/"
));
if
(
TestGroup
.
PERFORMANCE
.
isActive
())
{
assertMockMvcNotUsed
(
"https://example.com/"
);
}
}
@Test
...
...
@@ -92,7 +85,10 @@ class MockMvcHtmlUnitDriverBuilderTests {
this
.
driver
=
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
this
.
mockMvc
).
build
();
assertMockMvcUsed
(
"http://localhost/test"
);
Assume
.
group
(
TestGroup
.
PERFORMANCE
,
()
->
assertMockMvcNotUsed
(
"https://example.com/"
));
if
(
TestGroup
.
PERFORMANCE
.
isActive
())
{
assertMockMvcNotUsed
(
"https://example.com/"
);
}
}
@Test
...
...
@@ -111,8 +107,7 @@ class MockMvcHtmlUnitDriverBuilderTests {
void
cookieManagerShared
()
throws
Exception
{
WebConnectionHtmlUnitDriver
otherDriver
=
new
WebConnectionHtmlUnitDriver
();
this
.
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
new
CookieController
()).
build
();
this
.
driver
=
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
this
.
mockMvc
)
.
withDelegate
(
otherDriver
).
build
();
this
.
driver
=
MockMvcHtmlUnitDriverBuilder
.
mockMvcSetup
(
this
.
mockMvc
).
withDelegate
(
otherDriver
).
build
();
assertThat
(
get
(
"http://localhost/"
)).
isEqualTo
(
""
);
Cookie
cookie
=
new
Cookie
(
"localhost"
,
"cookie"
,
"cookieManagerShared"
);
...
...
@@ -143,7 +138,7 @@ class MockMvcHtmlUnitDriverBuilderTests {
static
class
ContextPathController
{
@RequestMapping
(
"/test"
)
public
String
contextPath
(
HttpServletRequest
request
)
{
String
contextPath
(
HttpServletRequest
request
)
{
return
EXPECTED_BODY
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录