Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
fac6f08c
Commit
fac6f08c
authored
Jan 30, 2020
by
dreis2211
Committed by
Stephane Nicoll
Jan 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new AssertJ duration assertions
See gh-19985
parent
7de3712e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
108 additions
and
116 deletions
+108
-116
PushRegistryPropertiesConfigAdapterTests.java
.../properties/PushRegistryPropertiesConfigAdapterTests.java
+2
-2
JmsPropertiesTests.java
...gframework/boot/autoconfigure/jms/JmsPropertiesTests.java
+2
-2
SessionAutoConfigurationTests.java
.../autoconfigure/session/SessionAutoConfigurationTests.java
+3
-6
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+5
-6
ServletWebServerFactoryCustomizerTests.java
...e/web/servlet/ServletWebServerFactoryCustomizerTests.java
+3
-4
LocalDevToolsAutoConfigurationTests.java
...ls/autoconfigure/LocalDevToolsAutoConfigurationTests.java
+2
-3
AppSystemPropertiesTests.java
...ocs/context/properties/bind/AppSystemPropertiesTests.java
+7
-8
WebTestClientAutoConfigurationTests.java
...ure/web/reactive/WebTestClientAutoConfigurationTests.java
+3
-4
DurationStyleTests.java
.../org/springframework/boot/convert/DurationStyleTests.java
+38
-38
NumberToDurationConverterTests.java
...ramework/boot/convert/NumberToDurationConverterTests.java
+7
-7
StringToDurationConverterTests.java
...ramework/boot/convert/StringToDurationConverterTests.java
+35
-35
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PushRegistryPropertiesConfigAdapterTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -40,7 +40,7 @@ public abstract class PushRegistryPropertiesConfigAdapterTests<P extends PushReg
...
@@ -40,7 +40,7 @@ public abstract class PushRegistryPropertiesConfigAdapterTests<P extends PushReg
void
whenPropertiesStepIsSetAdapterStepReturnsIt
()
{
void
whenPropertiesStepIsSetAdapterStepReturnsIt
()
{
P
properties
=
createProperties
();
P
properties
=
createProperties
();
properties
.
setStep
(
Duration
.
ofSeconds
(
42
));
properties
.
setStep
(
Duration
.
ofSeconds
(
42
));
assertThat
(
createConfigAdapter
(
properties
).
step
()).
isEqualTo
(
Duration
.
ofSeconds
(
42
)
);
assertThat
(
createConfigAdapter
(
properties
).
step
()).
hasSeconds
(
42
);
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -83,7 +83,7 @@ class JmsPropertiesTests {
...
@@ -83,7 +83,7 @@ class JmsPropertiesTests {
@Test
@Test
void
defaultReceiveTimeoutMatchesListenerContainersDefault
()
{
void
defaultReceiveTimeoutMatchesListenerContainersDefault
()
{
assertThat
(
new
JmsProperties
().
getListener
().
getReceiveTimeout
())
assertThat
(
new
JmsProperties
().
getListener
().
getReceiveTimeout
())
.
isEqualTo
(
Duration
.
ofMillis
(
AbstractPollingMessageListenerContainer
.
DEFAULT_RECEIVE_TIMEOUT
)
);
.
hasMillis
(
AbstractPollingMessageListenerContainer
.
DEFAULT_RECEIVE_TIMEOUT
);
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
session
;
package
org
.
springframework
.
boot
.
autoconfigure
.
session
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
...
@@ -98,8 +97,7 @@ class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTest
...
@@ -98,8 +97,7 @@ class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTest
this
.
contextRunner
this
.
contextRunner
.
withUserConfiguration
(
ServerPropertiesConfiguration
.
class
,
SessionRepositoryConfiguration
.
class
)
.
withUserConfiguration
(
ServerPropertiesConfiguration
.
class
,
SessionRepositoryConfiguration
.
class
)
.
withPropertyValues
(
"server.servlet.session.timeout=1"
,
"spring.session.timeout=3"
)
.
withPropertyValues
(
"server.servlet.session.timeout=1"
,
"spring.session.timeout=3"
)
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
SessionProperties
.
class
).
getTimeout
())
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
SessionProperties
.
class
).
getTimeout
()).
hasSeconds
(
3
));
.
isEqualTo
(
Duration
.
ofSeconds
(
3
)));
}
}
@Test
@Test
...
@@ -107,8 +105,7 @@ class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTest
...
@@ -107,8 +105,7 @@ class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurationTest
this
.
contextRunner
this
.
contextRunner
.
withUserConfiguration
(
ServerPropertiesConfiguration
.
class
,
SessionRepositoryConfiguration
.
class
)
.
withUserConfiguration
(
ServerPropertiesConfiguration
.
class
,
SessionRepositoryConfiguration
.
class
)
.
withPropertyValues
(
"server.servlet.session.timeout=3"
)
.
withPropertyValues
(
"server.servlet.session.timeout=3"
)
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
SessionProperties
.
class
).
getTimeout
())
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
SessionProperties
.
class
).
getTimeout
()).
hasSeconds
(
3
));
.
isEqualTo
(
Duration
.
ofSeconds
(
3
)));
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,7 +20,6 @@ import java.io.IOException;
...
@@ -20,7 +20,6 @@ import java.io.IOException;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.URI
;
import
java.net.URI
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -107,7 +106,7 @@ class ServerPropertiesTests {
...
@@ -107,7 +106,7 @@ class ServerPropertiesTests {
@Test
@Test
void
testConnectionTimeout
()
{
void
testConnectionTimeout
()
{
bind
(
"server.connection-timeout"
,
"60s"
);
bind
(
"server.connection-timeout"
,
"60s"
);
assertThat
(
this
.
properties
.
getConnectionTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
60000
)
);
assertThat
(
this
.
properties
.
getConnectionTimeout
()).
hasMillis
(
60000
);
}
}
@Test
@Test
...
@@ -149,7 +148,7 @@ class ServerPropertiesTests {
...
@@ -149,7 +148,7 @@ class ServerPropertiesTests {
assertThat
(
tomcat
.
getRemoteIpHeader
()).
isEqualTo
(
"Remote-Ip"
);
assertThat
(
tomcat
.
getRemoteIpHeader
()).
isEqualTo
(
"Remote-Ip"
);
assertThat
(
tomcat
.
getProtocolHeader
()).
isEqualTo
(
"X-Forwarded-Protocol"
);
assertThat
(
tomcat
.
getProtocolHeader
()).
isEqualTo
(
"X-Forwarded-Protocol"
);
assertThat
(
tomcat
.
getInternalProxies
()).
isEqualTo
(
"10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
);
assertThat
(
tomcat
.
getInternalProxies
()).
isEqualTo
(
"10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
);
assertThat
(
tomcat
.
getBackgroundProcessorDelay
()).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
tomcat
.
getBackgroundProcessorDelay
()).
hasSeconds
(
10
);
assertThat
(
tomcat
.
getRelaxedPathChars
()).
containsExactly
(
'|'
,
'<'
);
assertThat
(
tomcat
.
getRelaxedPathChars
()).
containsExactly
(
'|'
,
'<'
);
assertThat
(
tomcat
.
getRelaxedQueryChars
()).
containsExactly
(
'^'
,
'|'
);
assertThat
(
tomcat
.
getRelaxedQueryChars
()).
containsExactly
(
'^'
,
'|'
);
}
}
...
@@ -235,7 +234,7 @@ class ServerPropertiesTests {
...
@@ -235,7 +234,7 @@ class ServerPropertiesTests {
@Test
@Test
void
testCustomizeJettyIdleTimeout
()
{
void
testCustomizeJettyIdleTimeout
()
{
bind
(
"server.jetty.thread-idle-timeout"
,
"10s"
);
bind
(
"server.jetty.thread-idle-timeout"
,
"10s"
);
assertThat
(
this
.
properties
.
getJetty
().
getThreadIdleTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
this
.
properties
.
getJetty
().
getThreadIdleTimeout
()).
hasSeconds
(
10
);
}
}
@Test
@Test
...
@@ -308,7 +307,7 @@ class ServerPropertiesTests {
...
@@ -308,7 +307,7 @@ class ServerPropertiesTests {
@Test
@Test
void
tomcatBackgroundProcessorDelayMatchesEngineDefault
()
{
void
tomcatBackgroundProcessorDelayMatchesEngineDefault
()
{
assertThat
(
this
.
properties
.
getTomcat
().
getBackgroundProcessorDelay
())
assertThat
(
this
.
properties
.
getTomcat
().
getBackgroundProcessorDelay
())
.
isEqualTo
(
Duration
.
ofSeconds
((
new
StandardEngine
().
getBackgroundProcessorDelay
()
)));
.
hasSeconds
((
new
StandardEngine
().
getBackgroundProcessorDelay
(
)));
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
.
servlet
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
.
servlet
;
import
java.io.File
;
import
java.io.File
;
import
java.time.Duration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -106,14 +105,14 @@ class ServletWebServerFactoryCustomizerTests {
...
@@ -106,14 +105,14 @@ class ServletWebServerFactoryCustomizerTests {
this
.
customizer
.
customize
(
factory
);
this
.
customizer
.
customize
(
factory
);
ArgumentCaptor
<
Session
>
sessionCaptor
=
ArgumentCaptor
.
forClass
(
Session
.
class
);
ArgumentCaptor
<
Session
>
sessionCaptor
=
ArgumentCaptor
.
forClass
(
Session
.
class
);
verify
(
factory
).
setSession
(
sessionCaptor
.
capture
());
verify
(
factory
).
setSession
(
sessionCaptor
.
capture
());
assertThat
(
sessionCaptor
.
getValue
().
getTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
123
)
);
assertThat
(
sessionCaptor
.
getValue
().
getTimeout
()).
hasSeconds
(
123
);
Cookie
cookie
=
sessionCaptor
.
getValue
().
getCookie
();
Cookie
cookie
=
sessionCaptor
.
getValue
().
getCookie
();
assertThat
(
cookie
.
getName
()).
isEqualTo
(
"testname"
);
assertThat
(
cookie
.
getName
()).
isEqualTo
(
"testname"
);
assertThat
(
cookie
.
getDomain
()).
isEqualTo
(
"testdomain"
);
assertThat
(
cookie
.
getDomain
()).
isEqualTo
(
"testdomain"
);
assertThat
(
cookie
.
getPath
()).
isEqualTo
(
"/testpath"
);
assertThat
(
cookie
.
getPath
()).
isEqualTo
(
"/testpath"
);
assertThat
(
cookie
.
getComment
()).
isEqualTo
(
"testcomment"
);
assertThat
(
cookie
.
getComment
()).
isEqualTo
(
"testcomment"
);
assertThat
(
cookie
.
getHttpOnly
()).
isTrue
();
assertThat
(
cookie
.
getHttpOnly
()).
isTrue
();
assertThat
(
cookie
.
getMaxAge
()).
isEqualTo
(
Duration
.
ofSeconds
(
60
)
);
assertThat
(
cookie
.
getMaxAge
()).
hasSeconds
(
60
);
}
}
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
devtools
.
autoconfigure
;
package
org
.
springframework
.
boot
.
devtools
.
autoconfigure
;
import
java.io.File
;
import
java.io.File
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -115,7 +114,7 @@ class LocalDevToolsAutoConfigurationTests {
...
@@ -115,7 +114,7 @@ class LocalDevToolsAutoConfigurationTests {
void
resourceCachePeriodIsZero
()
throws
Exception
{
void
resourceCachePeriodIsZero
()
throws
Exception
{
this
.
context
=
getContext
(()
->
initializeAndRun
(
WebResourcesConfig
.
class
));
this
.
context
=
getContext
(()
->
initializeAndRun
(
WebResourcesConfig
.
class
));
ResourceProperties
properties
=
this
.
context
.
getBean
(
ResourceProperties
.
class
);
ResourceProperties
properties
=
this
.
context
.
getBean
(
ResourceProperties
.
class
);
assertThat
(
properties
.
getCache
().
getPeriod
()).
is
EqualTo
(
Duration
.
ZERO
);
assertThat
(
properties
.
getCache
().
getPeriod
()).
is
Zero
(
);
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/AppSystemPropertiesTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
docs
.
context
.
properties
.
bind
;
package
org
.
springframework
.
boot
.
docs
.
context
.
properties
.
bind
;
import
java.time.Duration
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -43,8 +42,8 @@ class AppSystemPropertiesTests {
...
@@ -43,8 +42,8 @@ class AppSystemPropertiesTests {
void
bindWithDefaultUnit
()
{
void
bindWithDefaultUnit
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=40"
,
"app.system.read-timeout=5000"
)
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=40"
,
"app.system.read-timeout=5000"
)
.
run
(
assertBinding
((
properties
)
->
{
.
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
40
)
);
assertThat
(
properties
.
getSessionTimeout
()).
hasSeconds
(
40
);
assertThat
(
properties
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
5000
)
);
assertThat
(
properties
.
getReadTimeout
()).
hasMillis
(
5000
);
}));
}));
}
}
...
@@ -52,8 +51,8 @@ class AppSystemPropertiesTests {
...
@@ -52,8 +51,8 @@ class AppSystemPropertiesTests {
void
bindWithExplicitUnit
()
{
void
bindWithExplicitUnit
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=1h"
,
"app.system.read-timeout=5s"
)
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=1h"
,
"app.system.read-timeout=5s"
)
.
run
(
assertBinding
((
properties
)
->
{
.
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofMinutes
(
60
)
);
assertThat
(
properties
.
getSessionTimeout
()).
hasMinutes
(
60
);
assertThat
(
properties
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
5000
)
);
assertThat
(
properties
.
getReadTimeout
()).
hasMillis
(
5000
);
}));
}));
}
}
...
@@ -61,8 +60,8 @@ class AppSystemPropertiesTests {
...
@@ -61,8 +60,8 @@ class AppSystemPropertiesTests {
void
bindWithIso8601Format
()
{
void
bindWithIso8601Format
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=PT15S"
,
"app.system.read-timeout=PT0.5S"
)
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=PT15S"
,
"app.system.read-timeout=PT0.5S"
)
.
run
(
assertBinding
((
properties
)
->
{
.
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
15
)
);
assertThat
(
properties
.
getSessionTimeout
()).
hasSeconds
(
15
);
assertThat
(
properties
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
500
)
);
assertThat
(
properties
.
getReadTimeout
()).
hasMillis
(
500
);
}));
}));
}
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
reactive
;
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
reactive
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.temporal.ChronoUnit
;
import
java.util.List
;
import
java.util.List
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -75,8 +74,8 @@ class WebTestClientAutoConfigurationTests {
...
@@ -75,8 +74,8 @@ class WebTestClientAutoConfigurationTests {
this
.
contextRunner
.
withUserConfiguration
(
BaseConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
BaseConfiguration
.
class
)
.
withPropertyValues
(
"spring.test.webtestclient.timeout=15m"
).
run
((
context
)
->
{
.
withPropertyValues
(
"spring.test.webtestclient.timeout=15m"
).
run
((
context
)
->
{
WebTestClient
webTestClient
=
context
.
getBean
(
WebTestClient
.
class
);
WebTestClient
webTestClient
=
context
.
getBean
(
WebTestClient
.
class
);
Object
duration
=
ReflectionTestUtils
.
getField
(
webTestClient
,
"timeout"
);
Duration
duration
=
(
Duration
)
ReflectionTestUtils
.
getField
(
webTestClient
,
"timeout"
);
assertThat
(
duration
).
isEqualTo
(
Duration
.
of
(
15
,
ChronoUnit
.
MINUTES
)
);
assertThat
(
duration
).
hasMinutes
(
15
);
});
});
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationStyleTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -51,72 +51,72 @@ class DurationStyleTests {
...
@@ -51,72 +51,72 @@ class DurationStyleTests {
@Test
@Test
void
detectAndParseWhenSimpleNanosShouldReturnDuration
()
{
void
detectAndParseWhenSimpleNanosShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10ns"
)).
hasNanos
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10NS"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10NS"
)).
hasNanos
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10ns"
)).
hasNanos
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10ns"
)).
hasNanos
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleMicrosShouldReturnDuration
()
{
void
detectAndParseWhenSimpleMicrosShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10us"
)).
hasNanos
(
10000
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10US"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10US"
)).
hasNanos
(
10000
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10us"
)).
hasNanos
(
10000
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10us"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10000
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10us"
)).
hasNanos
(-
10000
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleMillisShouldReturnDuration
()
{
void
detectAndParseWhenSimpleMillisShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10ms"
)).
hasMillis
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10MS"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10MS"
)).
hasMillis
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10ms"
)).
hasMillis
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10ms"
)).
hasMillis
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleSecondsShouldReturnDuration
()
{
void
detectAndParseWhenSimpleSecondsShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10s"
)).
hasSeconds
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10S"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10S"
)).
hasSeconds
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10s"
)).
hasSeconds
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10s"
)).
hasSeconds
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleMinutesShouldReturnDuration
()
{
void
detectAndParseWhenSimpleMinutesShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10m"
)).
hasMinutes
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10M"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10M"
)).
hasMinutes
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10m"
)).
hasMinutes
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10m"
)).
hasMinutes
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleHoursShouldReturnDuration
()
{
void
detectAndParseWhenSimpleHoursShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10h"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10h"
)).
hasHours
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10H"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10H"
)).
hasHours
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10h"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10h"
)).
hasHours
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10h"
)).
isEqualTo
(
Duration
.
ofHours
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10h"
)).
hasHours
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleDaysShouldReturnDuration
()
{
void
detectAndParseWhenSimpleDaysShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10d"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10d"
)).
hasDays
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10D"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10D"
)).
hasDays
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10d"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10d"
)).
hasDays
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10d"
)).
isEqualTo
(
Duration
.
ofDays
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10d"
)).
hasDays
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleWithoutSuffixShouldReturnDuration
()
{
void
detectAndParseWhenSimpleWithoutSuffixShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10"
)).
hasMillis
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10"
)).
hasMillis
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10"
)).
isEqualTo
(
Duration
.
ofMillis
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10"
)).
hasMillis
(-
10
);
}
}
@Test
@Test
void
detectAndParseWhenSimpleWithoutSuffixButWithChronoUnitShouldReturnDuration
()
{
void
detectAndParseWhenSimpleWithoutSuffixButWithChronoUnitShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10"
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"10"
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10"
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"+10"
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(
10
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10"
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(-
10
)
);
assertThat
(
DurationStyle
.
detectAndParse
(
"-10"
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(-
10
);
}
}
@Test
@Test
...
@@ -191,13 +191,13 @@ class DurationStyleTests {
...
@@ -191,13 +191,13 @@ class DurationStyleTests {
@Test
@Test
void
parseSimpleShouldParse
()
{
void
parseSimpleShouldParse
()
{
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10m"
)).
hasMinutes
(
10
);
}
}
@Test
@Test
void
parseSimpleWithUnitShouldUseUnitAsFallback
()
{
void
parseSimpleWithUnitShouldUseUnitAsFallback
()
{
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10m"
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10m"
,
ChronoUnit
.
SECONDS
)).
hasMinutes
(
10
);
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10"
,
ChronoUnit
.
MINUTES
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
DurationStyle
.
SIMPLE
.
parse
(
"10"
,
ChronoUnit
.
MINUTES
)).
hasMinutes
(
10
);
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/NumberToDurationConverterTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -40,16 +40,16 @@ class NumberToDurationConverterTests {
...
@@ -40,16 +40,16 @@ class NumberToDurationConverterTests {
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleWithoutSuffixShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleWithoutSuffixShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
10
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
10
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
+
10
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
+
10
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
-
10
)).
isEqualTo
(
Duration
.
ofMillis
(-
10
)
);
assertThat
(
convert
(
conversionService
,
-
10
)).
hasMillis
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
10
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
10
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
+
10
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
+
10
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
-
10
,
ChronoUnit
.
SECONDS
)).
isEqualTo
(
Duration
.
ofSeconds
(-
10
)
);
assertThat
(
convert
(
conversionService
,
-
10
,
ChronoUnit
.
SECONDS
)).
hasSeconds
(-
10
);
}
}
private
Duration
convert
(
ConversionService
conversionService
,
Integer
source
)
{
private
Duration
convert
(
ConversionService
conversionService
,
Integer
source
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToDurationConverterTests.java
View file @
fac6f08c
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -50,72 +50,72 @@ class StringToDurationConverterTests {
...
@@ -50,72 +50,72 @@ class StringToDurationConverterTests {
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleNanosShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleNanosShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10ns"
)).
hasNanos
(
10
);
assertThat
(
convert
(
conversionService
,
"10NS"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10NS"
)).
hasNanos
(
10
);
assertThat
(
convert
(
conversionService
,
"+10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10ns"
)).
hasNanos
(
10
);
assertThat
(
convert
(
conversionService
,
"-10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10ns"
)).
hasNanos
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleMicrosShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleMicrosShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
convert
(
conversionService
,
"10us"
)).
hasNanos
(
10000
);
assertThat
(
convert
(
conversionService
,
"10US"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
convert
(
conversionService
,
"10US"
)).
hasNanos
(
10000
);
assertThat
(
convert
(
conversionService
,
"+10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
)
);
assertThat
(
convert
(
conversionService
,
"+10us"
)).
hasNanos
(
10000
);
assertThat
(
convert
(
conversionService
,
"-10us"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10000
)
);
assertThat
(
convert
(
conversionService
,
"-10us"
)).
hasNanos
(-
10000
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleMillisShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleMillisShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10ms"
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
"10MS"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10MS"
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
"+10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10ms"
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
"-10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10ms"
)).
hasMillis
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleSecondsShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleSecondsShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10s"
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
"10S"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10S"
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
"+10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10s"
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
"-10s"
)).
isEqualTo
(
Duration
.
ofSeconds
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10s"
)).
hasSeconds
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleMinutesShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleMinutesShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10m"
)).
hasMinutes
(
10
);
assertThat
(
convert
(
conversionService
,
"10M"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10M"
)).
hasMinutes
(
10
);
assertThat
(
convert
(
conversionService
,
"+10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10m"
)).
hasMinutes
(
10
);
assertThat
(
convert
(
conversionService
,
"-10m"
)).
isEqualTo
(
Duration
.
ofMinutes
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10m"
)).
hasMinutes
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleHoursShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleHoursShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10h"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10h"
)).
hasHours
(
10
);
assertThat
(
convert
(
conversionService
,
"10H"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10H"
)).
hasHours
(
10
);
assertThat
(
convert
(
conversionService
,
"+10h"
)).
isEqualTo
(
Duration
.
ofHours
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10h"
)).
hasHours
(
10
);
assertThat
(
convert
(
conversionService
,
"-10h"
)).
isEqualTo
(
Duration
.
ofHours
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10h"
)).
hasHours
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleDaysShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleDaysShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10d"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10d"
)).
hasDays
(
10
);
assertThat
(
convert
(
conversionService
,
"10D"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10D"
)).
hasDays
(
10
);
assertThat
(
convert
(
conversionService
,
"+10d"
)).
isEqualTo
(
Duration
.
ofDays
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10d"
)).
hasDays
(
10
);
assertThat
(
convert
(
conversionService
,
"-10d"
)).
isEqualTo
(
Duration
.
ofDays
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10d"
)).
hasDays
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleWithoutSuffixShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleWithoutSuffixShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10"
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
"+10"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10"
)).
hasMillis
(
10
);
assertThat
(
convert
(
conversionService
,
"-10"
)).
isEqualTo
(
Duration
.
ofMillis
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10"
)).
hasMillis
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
void
convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDuration
(
ConversionService
conversionService
)
{
void
convertWhenSimpleWithoutSuffixButWithAnnotationShouldReturnDuration
(
ConversionService
conversionService
)
{
assertThat
(
convert
(
conversionService
,
"10"
,
ChronoUnit
.
SECONDS
,
null
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
"10"
,
ChronoUnit
.
SECONDS
,
null
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
"+10"
,
ChronoUnit
.
SECONDS
,
null
)).
isEqualTo
(
Duration
.
ofSeconds
(
10
)
);
assertThat
(
convert
(
conversionService
,
"+10"
,
ChronoUnit
.
SECONDS
,
null
)).
hasSeconds
(
10
);
assertThat
(
convert
(
conversionService
,
"-10"
,
ChronoUnit
.
SECONDS
,
null
)).
isEqualTo
(
Duration
.
ofSeconds
(-
10
)
);
assertThat
(
convert
(
conversionService
,
"-10"
,
ChronoUnit
.
SECONDS
,
null
)).
hasSeconds
(-
10
);
}
}
@ConversionServiceTest
@ConversionServiceTest
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
fac6f08c
...
@@ -676,7 +676,7 @@ public abstract class AbstractServletWebServerFactoryTests {
...
@@ -676,7 +676,7 @@ public abstract class AbstractServletWebServerFactoryTests {
@Test
@Test
void
defaultSessionTimeout
()
{
void
defaultSessionTimeout
()
{
assertThat
(
getFactory
().
getSession
().
getTimeout
()).
isEqualTo
(
Duration
.
ofMinutes
(
30
)
);
assertThat
(
getFactory
().
getSession
().
getTimeout
()).
hasMinutes
(
30
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment