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
cf93f84e
Commit
cf93f84e
authored
Jan 21, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
acfae2eb
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
44 deletions
+56
-44
AuthenticationAuditListenerTests.java
...ot/actuate/security/AuthenticationAuditListenerTests.java
+1
-0
FlywayAutoConfiguration.java
...rk/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
+11
-10
ConditionalOnEnabledResourceChain.java
.../autoconfigure/web/ConditionalOnEnabledResourceChain.java
+2
-2
OnEnabledResourceChainCondition.java
...ot/autoconfigure/web/OnEnabledResourceChainCondition.java
+3
-3
ResourceProperties.java
...gframework/boot/autoconfigure/web/ResourceProperties.java
+3
-4
WebMvcAutoConfiguration.java
...ework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
+11
-6
FlywayAutoConfigurationTests.java
...ot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+4
-2
ResourcePropertiesTest.java
...mework/boot/autoconfigure/web/ResourcePropertiesTest.java
+5
-5
FullyExecutableJarTests.java
.../springframework/boot/gradle/FullyExecutableJarTests.java
+1
-1
JavaLoggingSystem.java
.../springframework/boot/logging/java/JavaLoggingSystem.java
+3
-3
Log4J2LoggingSystem.java
...ingframework/boot/logging/log4j2/Log4J2LoggingSystem.java
+4
-5
ConverterBindingTests.java
.../org/springframework/boot/bind/ConverterBindingTests.java
+8
-3
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java
View file @
cf93f84e
...
...
@@ -100,4 +100,5 @@ public class AuthenticationAuditListenerTests {
assertThat
(
auditApplicationEvent
.
getValue
().
getAuditEvent
().
getData
(),
hasEntry
(
"details"
,
details
));
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
View file @
cf93f84e
...
...
@@ -183,26 +183,27 @@ public class FlywayAutoConfiguration {
private
static
class
StringOrNumberToMigrationVersionConverter
implements
GenericConverter
{
private
static
final
Set
<
ConvertiblePair
>
CONVERTIBLE_PAIRS
=
createConvertiblePairs
();
private
static
final
Set
<
ConvertiblePair
>
CONVERTIBLE_TYPES
;
static
{
Set
<
ConvertiblePair
>
types
=
new
HashSet
<
ConvertiblePair
>(
2
);
types
.
add
(
new
ConvertiblePair
(
String
.
class
,
MigrationVersion
.
class
));
types
.
add
(
new
ConvertiblePair
(
Number
.
class
,
MigrationVersion
.
class
));
CONVERTIBLE_TYPES
=
Collections
.
unmodifiableSet
(
types
);
}
@Override
public
Set
<
ConvertiblePair
>
getConvertibleTypes
()
{
return
CONVERTIBLE_
PAIR
S
;
return
CONVERTIBLE_
TYPE
S
;
}
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
String
value
=
ObjectUtils
.
nullSafeToString
(
source
);
return
MigrationVersion
.
fromVersion
(
value
);
}
private
static
Set
<
ConvertiblePair
>
createConvertiblePairs
()
{
Set
<
ConvertiblePair
>
convertiblePairs
=
new
HashSet
<
ConvertiblePair
>(
2
);
convertiblePairs
.
add
(
new
ConvertiblePair
(
String
.
class
,
MigrationVersion
.
class
));
convertiblePairs
.
add
(
new
ConvertiblePair
(
Number
.
class
,
MigrationVersion
.
class
));
return
Collections
.
unmodifiableSet
(
convertiblePairs
);
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java
View file @
cf93f84e
...
...
@@ -26,8 +26,8 @@ import org.springframework.context.annotation.Conditional;
/**
* {@link Conditional} that checks whether or not the Spring resource handling chain is
* enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or
*
if
{@code webjars-locator} is on the classpath.
* enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or
if
* {@code webjars-locator} is on the classpath.
*
* @author Stephane Nicoll
* @since 1.3.0
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java
View file @
cf93f84e
...
...
@@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils;
*/
class
OnEnabledResourceChainCondition
extends
SpringBootCondition
{
p
ublic
static
final
String
WEBJAR_ASSERT_LOCATOR
=
"org.webjars.WebJarAssetLocator"
;
p
rivate
static
final
String
WEBJAR_ASSERT_LOCATOR
=
"org.webjars.WebJarAssetLocator"
;
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
...
...
@@ -46,8 +46,8 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
binder
.
bind
(
new
PropertySourcesPropertyValues
(
environment
.
getPropertySources
()));
Boolean
match
=
properties
.
getChain
().
getEnabled
();
if
(
match
==
null
)
{
boolean
webJarsLocatorPresent
=
ClassUtils
.
isPresent
(
WEBJAR_ASSERT_LOCATOR
,
getClass
().
getClassLoader
());
boolean
webJarsLocatorPresent
=
ClassUtils
.
isPresent
(
WEBJAR_ASSERT_LOCATOR
,
getClass
().
getClassLoader
());
return
new
ConditionOutcome
(
webJarsLocatorPresent
,
"Webjars locator ("
+
WEBJAR_ASSERT_LOCATOR
+
") is "
+
(
webJarsLocatorPresent
?
"present"
:
"absent"
));
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
View file @
cf93f84e
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -175,11 +175,10 @@ public class ResourceProperties implements ResourceLoaderAware {
/**
* Return whether the resource chain is enabled. Return {@code null} if no
* specific settings are present.
* @return whether the resource chain is enabled or {@code null} if no
* s
pecified s
ettings are present.
* @return whether the resource chain is enabled or {@code null} if no
specified
* settings are present.
*/
public
Boolean
getEnabled
()
{
// Check if at least one of the available strategy has been enabled
Boolean
strategyEnabled
=
getStrategy
().
getFixed
().
isEnabled
()
||
getStrategy
().
getContent
().
isEnabled
();
return
(
strategyEnabled
?
Boolean
.
TRUE
:
this
.
enabled
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
View file @
cf93f84e
...
...
@@ -258,20 +258,24 @@ public class WebMvcAutoConfiguration {
}
Integer
cachePeriod
=
this
.
resourceProperties
.
getCachePeriod
();
if
(!
registry
.
hasMappingForPattern
(
"/webjars/**"
))
{
customizeResourceHandlerRegistration
(
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
)
customizeResourceHandlerRegistration
(
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
)
.
setCachePeriod
(
cachePeriod
));
}
String
staticPathPattern
=
this
.
mvcProperties
.
getStaticPathPattern
();
if
(!
registry
.
hasMappingForPattern
(
staticPathPattern
))
{
customizeResourceHandlerRegistration
(
registry
.
addResourceHandler
(
staticPathPattern
)
.
addResourceLocations
(
this
.
resourceProperties
.
getStaticLocations
())
customizeResourceHandlerRegistration
(
registry
.
addResourceHandler
(
staticPathPattern
)
.
addResourceLocations
(
this
.
resourceProperties
.
getStaticLocations
())
.
setCachePeriod
(
cachePeriod
));
}
}
private
void
customizeResourceHandlerRegistration
(
ResourceHandlerRegistration
registration
)
{
private
void
customizeResourceHandlerRegistration
(
ResourceHandlerRegistration
registration
)
{
if
(
this
.
resourceHandlerRegistrationCustomizer
!=
null
)
{
this
.
resourceHandlerRegistrationCustomizer
.
customize
(
registration
);
}
...
...
@@ -411,6 +415,7 @@ public class WebMvcAutoConfiguration {
}
return
resolver
;
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
View file @
cf93f84e
...
...
@@ -225,8 +225,10 @@ public class FlywayAutoConfigurationTests {
@Test
public
void
overrideBaselineVersionNumber
()
throws
Exception
{
Map
<
String
,
Object
>
source
=
Collections
.<
String
,
Object
>
singletonMap
(
"flyway.baseline-version"
,
1
);
this
.
context
.
getEnvironment
().
getPropertySources
().
addLast
(
new
MapPropertySource
(
"flyway"
,
source
));
Map
<
String
,
Object
>
source
=
Collections
.<
String
,
Object
>
singletonMap
(
"flyway.baseline-version"
,
1
);
this
.
context
.
getEnvironment
().
getPropertySources
()
.
addLast
(
new
MapPropertySource
(
"flyway"
,
source
));
registerAndRefresh
(
EmbeddedDataSourceConfiguration
.
class
,
FlywayAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java
View file @
cf93f84e
...
...
@@ -18,8 +18,8 @@ package org.springframework.boot.autoconfigure.web;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
nullValue
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
...
...
@@ -34,25 +34,25 @@ public class ResourcePropertiesTest {
@Test
public
void
resourceChainNoCustomization
()
{
System
.
out
.
println
(
this
.
properties
.
getChain
().
getEnabled
());
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
is
(
nullValue
()
));
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
nullValue
(
));
}
@Test
public
void
resourceChainStrategyEnabled
()
{
this
.
properties
.
getChain
().
getStrategy
().
getFixed
().
setEnabled
(
true
);
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
is
(
true
));
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
equalTo
(
true
));
}
@Test
public
void
resourceChainEnabled
()
{
this
.
properties
.
getChain
().
setEnabled
(
true
);
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
is
(
true
));
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
equalTo
(
true
));
}
@Test
public
void
resourceChainDisabled
()
{
this
.
properties
.
getChain
().
setEnabled
(
false
);
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
is
(
false
));
assertThat
(
this
.
properties
.
getChain
().
getEnabled
(),
equalTo
(
false
));
}
}
spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java
View file @
cf93f84e
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java
View file @
cf93f84e
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -111,8 +111,8 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
@Override
public
void
setLogLevel
(
String
loggerName
,
LogLevel
level
)
{
Assert
.
notNull
(
level
,
"Level must not be null"
);
Logger
logger
=
Logger
.
getLogger
(
StringUtils
.
hasText
(
loggerName
)
?
loggerName
:
""
);
String
name
=
(
StringUtils
.
hasText
(
loggerName
)
?
loggerName
:
""
);
Logger
logger
=
Logger
.
getLogger
(
name
);
logger
.
setLevel
(
LEVELS
.
get
(
level
));
}
...
...
spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java
View file @
cf93f84e
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -208,10 +208,9 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
return
getLoggerContext
().
getConfiguration
().
getLoggerConfig
(
""
);
}
private
LoggerConfig
getLoggerConfig
(
String
loggerName
)
{
loggerName
=
StringUtils
.
hasText
(
loggerName
)
?
loggerName
:
LogManager
.
ROOT_LOGGER_NAME
;
return
getLoggerContext
().
getConfiguration
().
getLoggers
().
get
(
loggerName
);
private
LoggerConfig
getLoggerConfig
(
String
name
)
{
name
=
(
StringUtils
.
hasText
(
name
)
?
name
:
LogManager
.
ROOT_LOGGER_NAME
);
return
getLoggerContext
().
getConfiguration
().
getLoggers
().
get
(
name
);
}
private
LoggerContext
getLoggerContext
()
{
...
...
spring-boot/src/test/java/org/springframework/boot/bind/ConverterBindingTests.java
View file @
cf93f84e
...
...
@@ -49,7 +49,7 @@ import static org.junit.Assert.assertThat;
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
TestConfig
.
class
)
@IntegrationTest
({
"foo=one"
,
"bar=two"
})
@IntegrationTest
({
"foo=one"
,
"bar=two"
})
public
class
ConverterBindingTests
{
@Value
(
"${foo:}"
)
...
...
@@ -88,11 +88,13 @@ public class ConverterBindingTests {
return
new
GenericConverter
()
{
@Override
public
Set
<
ConvertiblePair
>
getConvertibleTypes
()
{
return
Collections
.
singleton
(
new
ConvertiblePair
(
String
.
class
,
Bar
.
class
));
return
Collections
.
singleton
(
new
ConvertiblePair
(
String
.
class
,
Bar
.
class
));
}
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
new
Bar
((
String
)
source
);
}
};
...
...
@@ -112,6 +114,7 @@ public class ConverterBindingTests {
public
Foo
(
String
name
)
{
this
.
name
=
name
;
}
}
public
static
class
Bar
{
...
...
@@ -121,6 +124,7 @@ public class ConverterBindingTests {
public
Bar
(
String
name
)
{
this
.
name
=
name
;
}
}
@ConfigurationProperties
...
...
@@ -145,6 +149,7 @@ public class ConverterBindingTests {
public
void
setBar
(
Bar
bar
)
{
this
.
bar
=
bar
;
}
}
}
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