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
e4f0ad21
Commit
e4f0ad21
authored
Dec 18, 2017
by
Johnny Lim
Committed by
Stephane Nicoll
Dec 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
Closes gh-11372
parent
873d88e1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
36 deletions
+38
-36
ResourceProperties.java
...gframework/boot/autoconfigure/web/ResourceProperties.java
+8
-7
JacksonAutoConfigurationTests.java
.../autoconfigure/jackson/JacksonAutoConfigurationTests.java
+1
-2
ResourcePropertiesTests.java
...ework/boot/autoconfigure/web/ResourcePropertiesTests.java
+4
-5
FilteredClassLoaderTests.java
...framework/boot/test/context/FilteredClassLoaderTests.java
+7
-3
TestRestTemplateExtensionsTests.kt
...k/boot/test/web/client/TestRestTemplateExtensionsTests.kt
+12
-12
pom.xml
spring-boot-project/spring-boot/pom.xml
+2
-2
PropertyMapper.java
...ringframework/boot/context/properties/PropertyMapper.java
+2
-2
DurationConverter.java
...ot/context/properties/bind/convert/DurationConverter.java
+2
-2
DurationConverterTests.java
...ntext/properties/bind/convert/DurationConverterTests.java
+0
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
View file @
e4f0ad21
...
...
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.PropertyMapper
;
import
org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit
;
import
org.springframework.http.CacheControl
;
/**
* Properties used to configure resource handling.
...
...
@@ -458,9 +459,9 @@ public class ResourceProperties {
this
.
sMaxAge
=
sMaxAge
;
}
public
org
.
springframework
.
http
.
CacheControl
toHttpCacheControl
()
{
public
CacheControl
toHttpCacheControl
()
{
PropertyMapper
map
=
PropertyMapper
.
get
();
org
.
springframework
.
http
.
CacheControl
control
=
createCacheControl
();
CacheControl
control
=
createCacheControl
();
map
.
from
(
this
::
getMustRevalidate
).
whenTrue
()
.
toCall
(
control:
:
mustRevalidate
);
map
.
from
(
this
::
getNoTransform
).
whenTrue
().
toCall
(
control:
:
noTransform
);
...
...
@@ -478,18 +479,18 @@ public class ResourceProperties {
return
control
;
}
private
org
.
springframework
.
http
.
CacheControl
createCacheControl
()
{
private
CacheControl
createCacheControl
()
{
if
(
Boolean
.
TRUE
.
equals
(
this
.
noStore
))
{
return
org
.
springframework
.
http
.
CacheControl
.
noStore
();
return
CacheControl
.
noStore
();
}
if
(
Boolean
.
TRUE
.
equals
(
this
.
noCache
))
{
return
org
.
springframework
.
http
.
CacheControl
.
noCache
();
return
CacheControl
.
noCache
();
}
if
(
this
.
maxAge
!=
null
)
{
return
org
.
springframework
.
http
.
CacheControl
return
CacheControl
.
maxAge
(
this
.
maxAge
.
getSeconds
(),
TimeUnit
.
SECONDS
);
}
return
org
.
springframework
.
http
.
CacheControl
.
empty
();
return
CacheControl
.
empty
();
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java
View file @
e4f0ad21
...
...
@@ -22,7 +22,6 @@ import java.text.SimpleDateFormat;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.TimeZone
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonCreator.Mode
;
...
...
@@ -457,7 +456,7 @@ public class JacksonAutoConfigurationTests {
ObjectMapper
mapper
=
this
.
context
.
getBean
(
ObjectMapper
.
class
);
DateTime
dateTime
=
new
DateTime
(
1988
,
6
,
25
,
20
,
30
,
DateTimeZone
.
UTC
);
String
expected
=
FormatConfig
.
DEFAULT_DATETIME_PRINTER
.
rawFormatter
()
.
withZone
(
DateTimeZone
.
forTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
))
)
.
withZone
(
DateTimeZone
.
UTC
)
.
print
(
dateTime
);
assertThat
(
mapper
.
writeValueAsString
(
dateTime
)).
isEqualTo
(
"\""
+
expected
+
"\""
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
View file @
e4f0ad21
...
...
@@ -22,6 +22,7 @@ import org.junit.Test;
import
org.springframework.boot.autoconfigure.web.ResourceProperties.Cache
;
import
org.springframework.boot.testsupport.assertj.Matched
;
import
org.springframework.http.CacheControl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
CoreMatchers
.
endsWith
;
...
...
@@ -73,7 +74,7 @@ public class ResourcePropertiesTests {
@Test
public
void
emptyCacheControl
()
{
org
.
springframework
.
http
.
CacheControl
cacheControl
=
this
.
properties
.
getCache
()
CacheControl
cacheControl
=
this
.
properties
.
getCache
()
.
getCachecontrol
().
toHttpCacheControl
();
assertThat
(
cacheControl
.
getHeaderValue
()).
isNull
();
}
...
...
@@ -90,8 +91,7 @@ public class ResourcePropertiesTests {
properties
.
setSMaxAge
(
Duration
.
ofSeconds
(
5
));
properties
.
setStaleIfError
(
Duration
.
ofSeconds
(
6
));
properties
.
setStaleWhileRevalidate
(
Duration
.
ofSeconds
(
7
));
org
.
springframework
.
http
.
CacheControl
cacheControl
=
properties
.
toHttpCacheControl
();
CacheControl
cacheControl
=
properties
.
toHttpCacheControl
();
assertThat
(
cacheControl
.
getHeaderValue
()).
isEqualTo
(
"max-age=4, must-revalidate, no-transform, public, private, proxy-revalidate,"
+
" s-maxage=5, stale-if-error=6, stale-while-revalidate=7"
);
...
...
@@ -102,8 +102,7 @@ public class ResourcePropertiesTests {
Cache
.
Cachecontrol
properties
=
this
.
properties
.
getCache
().
getCachecontrol
();
properties
.
setMaxAge
(
Duration
.
ofSeconds
(
4
));
properties
.
setNoStore
(
true
);
org
.
springframework
.
http
.
CacheControl
cacheControl
=
properties
.
toHttpCacheControl
();
CacheControl
cacheControl
=
properties
.
toHttpCacheControl
();
assertThat
(
cacheControl
.
getHeaderValue
()).
isEqualTo
(
"no-store"
);
}
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/FilteredClassLoaderTests.java
View file @
e4f0ad21
...
...
@@ -46,9 +46,13 @@ public class FilteredClassLoaderTests {
public
void
loadClassWhenFilteredOnClassShouldThrowClassNotFound
()
throws
Exception
{
FilteredClassLoader
classLoader
=
new
FilteredClassLoader
(
FilteredClassLoaderTests
.
class
);
this
.
thrown
.
expect
(
ClassNotFoundException
.
class
);
classLoader
.
loadClass
(
getClass
().
getName
());
classLoader
.
close
();
try
{
this
.
thrown
.
expect
(
ClassNotFoundException
.
class
);
classLoader
.
loadClass
(
getClass
().
getName
());
}
finally
{
classLoader
.
close
();
}
}
@Test
...
...
spring-boot-project/spring-boot-test/src/test/kotlin/org/springframework/boot/test/web/client/TestRestTemplateExtensionsTests.kt
View file @
e4f0ad21
...
...
@@ -72,7 +72,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
getForEntity
with
reified
type
parameters
,
String
and
URI
`
()
{
fun
`
getForEntity
with
reified
type
parameters
and
URI
`
()
{
val
url
=
URI
(
"https://spring.io"
)
template
.
getForEntity
<
Foo
>(
url
)
verify
(
template
,
times
(
1
)).
getForEntity
(
url
,
Foo
::
class
.
java
)
...
...
@@ -88,7 +88,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
getForEntity
with
reified
type
parameters
and
Map
`
()
{
fun
`
getForEntity
with
reified
type
parameters
,
String
and
Map
`
()
{
val
url
=
"https://spring.io"
val
vars
=
mapOf
(
Pair
(
"key1"
,
"value1"
),
Pair
(
"key2"
,
"value2"
))
template
.
getForEntity
<
Foo
>(
url
,
vars
)
...
...
@@ -96,7 +96,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
patchForObject
with
reified
type
parameters
,
String
and
varargs
`
()
{
fun
`
patchForObject
with
reified
type
parameters
,
String
,
Any
and
varargs
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
var1
=
"var1"
...
...
@@ -106,7 +106,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
patchForObject
with
reified
type
parameters
,
String
and
Map
`
()
{
fun
`
patchForObject
with
reified
type
parameters
,
String
,
Any
and
Map
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
vars
=
mapOf
(
Pair
(
"key1"
,
"value1"
),
Pair
(
"key2"
,
"value2"
))
...
...
@@ -115,7 +115,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
patchForObject
with
reified
type
parameters
`
()
{
fun
`
patchForObject
with
reified
type
parameters
,
String
and
Any
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
template
.
patchForObject
<
Foo
>(
url
,
body
)
...
...
@@ -123,7 +123,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForObject
with
reified
type
parameters
,
String
and
varargs
`
()
{
fun
`
postForObject
with
reified
type
parameters
,
String
,
Any
and
varargs
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
var1
=
"var1"
...
...
@@ -133,7 +133,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForObject
with
reified
type
parameters
,
String
and
Map
`
()
{
fun
`
postForObject
with
reified
type
parameters
,
String
,
Any
and
Map
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
vars
=
mapOf
(
Pair
(
"key1"
,
"value1"
),
Pair
(
"key2"
,
"value2"
))
...
...
@@ -142,7 +142,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForObject
with
reified
type
parameters
`
()
{
fun
`
postForObject
with
reified
type
parameters
,
String
and
Any
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
template
.
postForObject
<
Foo
>(
url
,
body
)
...
...
@@ -150,7 +150,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForEntity
with
reified
type
parameters
,
String
and
varargs
`
()
{
fun
`
postForEntity
with
reified
type
parameters
,
String
,
Any
and
varargs
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
var1
=
"var1"
...
...
@@ -160,7 +160,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForEntity
with
reified
type
parameters
,
String
and
Map
`
()
{
fun
`
postForEntity
with
reified
type
parameters
,
String
,
Any
and
Map
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
val
vars
=
mapOf
(
Pair
(
"key1"
,
"value1"
),
Pair
(
"key2"
,
"value2"
))
...
...
@@ -169,7 +169,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
postForEntity
with
reified
type
parameters
`
()
{
fun
`
postForEntity
with
reified
type
parameters
,
String
and
Any
`
()
{
val
url
=
"https://spring.io"
val
body
:
Any
=
"body"
template
.
postForEntity
<
Foo
>(
url
,
body
)
...
...
@@ -210,7 +210,7 @@ class TestRestTemplateExtensionsTests {
}
@Test
fun
`
exchange
with
reified
type
parameters
,
String
,
HttpEntity
`
()
{
fun
`
exchange
with
reified
type
parameters
and
HttpEntity
`
()
{
val
entity
=
mock
<
RequestEntity
<
Foo
>>()
template
.
exchange
<
List
<
Foo
>>(
entity
)
verify
(
template
,
times
(
1
)).
exchange
(
entity
,
...
...
spring-boot-project/spring-boot/pom.xml
View file @
e4f0ad21
...
...
@@ -267,12 +267,12 @@
</dependency>
<dependency>
<groupId>
org.jetbrains.kotlin
</groupId>
<artifactId>
kotlin-
stdlib
</artifactId>
<artifactId>
kotlin-
reflect
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.jetbrains.kotlin
</groupId>
<artifactId>
kotlin-
reflect
</artifactId>
<artifactId>
kotlin-
stdlib
</artifactId>
<optional>
true
</optional>
</dependency>
<!-- Annotation processing -->
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java
View file @
e4f0ad21
...
...
@@ -29,7 +29,7 @@ import org.springframework.util.StringUtils;
/**
* Utility that can be used to map values from a supplied source to a destination.
* Primarily intended to be help when mapping from
* {@link ConfigurationProperties @ConfigrationProperties} to third-party classes.
* {@link ConfigurationProperties @Config
u
rationProperties} to third-party classes.
* <p>
* Can filter values based on predicates and adapt values if needed. For example:
* <pre class="code">
...
...
@@ -176,7 +176,7 @@ public final class PropertyMapper {
private
final
Predicate
<
T
>
predicate
;
private
Source
(
Supplier
<
T
>
supplier
,
Predicate
<
T
>
predicate
)
{
Assert
.
notNull
(
predicate
,
"
Arse
"
);
Assert
.
notNull
(
predicate
,
"
Predicate must not be null
"
);
this
.
supplier
=
supplier
;
this
.
predicate
=
predicate
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java
View file @
e4f0ad21
...
...
@@ -49,9 +49,9 @@ class DurationConverter implements GenericConverter {
TYPES
=
Collections
.
unmodifiableSet
(
types
);
}
private
static
Pattern
ISO8601
=
Pattern
.
compile
(
"^[\\+\\-]?P.*$"
);
private
static
final
Pattern
ISO8601
=
Pattern
.
compile
(
"^[\\+\\-]?P.*$"
);
private
static
Pattern
SIMPLE
=
Pattern
.
compile
(
"^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$"
);
private
static
final
Pattern
SIMPLE
=
Pattern
.
compile
(
"^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$"
);
private
static
final
Map
<
String
,
ChronoUnit
>
UNITS
;
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java
View file @
e4f0ad21
...
...
@@ -51,7 +51,6 @@ public class DurationConverterTests {
assertThat
(
convert
(
"PT10H"
)).
isEqualTo
(
Duration
.
parse
(
"PT10H"
));
assertThat
(
convert
(
"P2D"
)).
isEqualTo
(
Duration
.
parse
(
"P2D"
));
assertThat
(
convert
(
"P2DT3H4M"
)).
isEqualTo
(
Duration
.
parse
(
"P2DT3H4M"
));
assertThat
(
convert
(
"P2DT3H4M"
)).
isEqualTo
(
Duration
.
parse
(
"P2DT3H4M"
));
assertThat
(
convert
(
"-PT6H3M"
)).
isEqualTo
(
Duration
.
parse
(
"-PT6H3M"
));
assertThat
(
convert
(
"-PT-6H+3M"
)).
isEqualTo
(
Duration
.
parse
(
"-PT-6H+3M"
));
}
...
...
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