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
3882552b
Commit
3882552b
authored
Sep 12, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
449515ce
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
116 additions
and
105 deletions
+116
-105
ManagementContextFactory.java
...t/actuate/autoconfigure/web/ManagementContextFactory.java
+1
-0
CompositeReactiveHealthIndicator.java
...boot/actuate/health/CompositeReactiveHealthIndicator.java
+2
-4
StaticResourceRequest.java
...rk/boot/autoconfigure/security/StaticResourceRequest.java
+6
-6
AbstractSessionAutoConfigurationTests.java
...figure/session/AbstractSessionAutoConfigurationTests.java
+1
-2
SessionAutoConfigurationHazelcastTests.java
...igure/session/SessionAutoConfigurationHazelcastTests.java
+19
-16
SessionAutoConfigurationJdbcTests.java
...oconfigure/session/SessionAutoConfigurationJdbcTests.java
+41
-38
SessionAutoConfigurationRedisTests.java
...configure/session/SessionAutoConfigurationRedisTests.java
+8
-7
SessionAutoConfigurationTests.java
.../autoconfigure/session/SessionAutoConfigurationTests.java
+37
-31
ValidationAutoConfigurationTests.java
...onfigure/validation/ValidationAutoConfigurationTests.java
+1
-1
No files found.
spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java
View file @
3882552b
...
@@ -26,6 +26,7 @@ import org.springframework.context.ConfigurableApplicationContext;
...
@@ -26,6 +26,7 @@ import org.springframework.context.ConfigurableApplicationContext;
* @author Andy Wilkinson
* @author Andy Wilkinson
* @since 2.0.0
* @since 2.0.0
*/
*/
@FunctionalInterface
public
interface
ManagementContextFactory
{
public
interface
ManagementContextFactory
{
/**
/**
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java
View file @
3882552b
...
@@ -93,10 +93,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
...
@@ -93,10 +93,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
@Override
@Override
public
Mono
<
Health
>
health
()
{
public
Mono
<
Health
>
health
()
{
return
Flux
.
fromIterable
(
this
.
indicators
.
entrySet
())
return
Flux
.
fromIterable
(
this
.
indicators
.
entrySet
())
.
flatMap
((
entry
)
->
Mono
.
zip
(
.
flatMap
((
entry
)
->
Mono
.
zip
(
Mono
.
just
(
entry
.
getKey
()),
Mono
.
just
(
entry
.
getKey
()),
entry
.
getValue
().
health
().
compose
(
this
.
timeoutCompose
)))
entry
.
getValue
().
health
().
compose
(
this
.
timeoutCompose
))
)
.
collectMap
(
Tuple2:
:
getT1
,
Tuple2:
:
getT2
)
.
collectMap
(
Tuple2:
:
getT1
,
Tuple2:
:
getT2
)
.
map
(
this
.
healthAggregator
::
aggregate
);
.
map
(
this
.
healthAggregator
::
aggregate
);
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/StaticResourceRequest.java
View file @
3882552b
...
@@ -48,8 +48,8 @@ public final class StaticResourceRequest {
...
@@ -48,8 +48,8 @@ public final class StaticResourceRequest {
/**
/**
* Returns a matcher that includes all commonly used {@link Location Locations}. The
* Returns a matcher that includes all commonly used {@link Location Locations}. The
* {@link StaticResourceRequestMatcher#excluding(Location, Location...) excluding}
method
* {@link StaticResourceRequestMatcher#excluding(Location, Location...) excluding}
* can be used to remove specific locations if required. For example:
*
method
can be used to remove specific locations if required. For example:
* <pre class="code">
* <pre class="code">
* StaticResourceRequest.toCommonLocations().excluding(Location.CSS)
* StaticResourceRequest.toCommonLocations().excluding(Location.CSS)
* </pre>
* </pre>
...
@@ -140,8 +140,8 @@ public final class StaticResourceRequest {
...
@@ -140,8 +140,8 @@ public final class StaticResourceRequest {
}
}
/**
/**
* Return a new {@link StaticResourceRequestMatcher} based on this one but
excluding the
* Return a new {@link StaticResourceRequestMatcher} based on this one but
* specified locations.
*
excluding the
specified locations.
* @param first the first location to exclude
* @param first the first location to exclude
* @param rest additional locations to exclude
* @param rest additional locations to exclude
* @return a new {@link StaticResourceRequestMatcher}
* @return a new {@link StaticResourceRequestMatcher}
...
@@ -151,8 +151,8 @@ public final class StaticResourceRequest {
...
@@ -151,8 +151,8 @@ public final class StaticResourceRequest {
}
}
/**
/**
* Return a new {@link StaticResourceRequestMatcher} based on this one but
excluding the
* Return a new {@link StaticResourceRequestMatcher} based on this one but
* specified locations.
*
excluding the
specified locations.
* @param locations the locations to exclude
* @param locations the locations to exclude
* @return a new {@link StaticResourceRequestMatcher}
* @return a new {@link StaticResourceRequestMatcher}
*/
*/
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/AbstractSessionAutoConfigurationTests.java
View file @
3882552b
...
@@ -30,8 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -30,8 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
abstract
class
AbstractSessionAutoConfigurationTests
{
public
abstract
class
AbstractSessionAutoConfigurationTests
{
protected
<
T
extends
SessionRepository
<?>>
T
validateSessionRepository
(
protected
<
T
extends
SessionRepository
<?>>
T
validateSessionRepository
(
AssertableWebApplicationContext
context
,
AssertableWebApplicationContext
context
,
Class
<
T
>
type
)
{
Class
<
T
>
type
)
{
assertThat
(
context
).
hasSingleBean
(
SessionRepository
.
class
);
assertThat
(
context
).
hasSingleBean
(
SessionRepository
.
class
);
SessionRepository
<?>
repository
=
context
.
getBean
(
SessionRepository
.
class
);
SessionRepository
<?>
repository
=
context
.
getBean
(
SessionRepository
.
class
);
assertThat
(
repository
).
as
(
"Wrong session repository type"
).
isInstanceOf
(
type
);
assertThat
(
repository
).
as
(
"Wrong session repository type"
).
isInstanceOf
(
type
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java
View file @
3882552b
...
@@ -46,7 +46,6 @@ public class SessionAutoConfigurationHazelcastTests
...
@@ -46,7 +46,6 @@ public class SessionAutoConfigurationHazelcastTests
.
withConfiguration
(
AutoConfigurations
.
of
(
SessionAutoConfiguration
.
class
))
.
withConfiguration
(
AutoConfigurations
.
of
(
SessionAutoConfiguration
.
class
))
.
withUserConfiguration
(
HazelcastConfiguration
.
class
);
.
withUserConfiguration
(
HazelcastConfiguration
.
class
);
@Test
@Test
public
void
defaultConfig
()
{
public
void
defaultConfig
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
)
...
@@ -60,25 +59,29 @@ public class SessionAutoConfigurationHazelcastTests
...
@@ -60,25 +59,29 @@ public class SessionAutoConfigurationHazelcastTests
@Test
@Test
public
void
customMapName
()
{
public
void
customMapName
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
,
this
.
contextRunner
"spring.session.hazelcast.map-name=foo:bar:biz"
).
run
((
context
)
->
{
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
,
validateSessionRepository
(
context
,
HazelcastSessionRepository
.
class
);
"spring.session.hazelcast.map-name=foo:bar:biz"
)
HazelcastInstance
hazelcastInstance
=
context
.
run
((
context
)
->
{
.
getBean
(
HazelcastInstance
.
class
);
validateSessionRepository
(
context
,
HazelcastSessionRepository
.
class
);
verify
(
hazelcastInstance
,
times
(
1
)).
getMap
(
"foo:bar:biz"
);
HazelcastInstance
hazelcastInstance
=
context
});
.
getBean
(
HazelcastInstance
.
class
);
verify
(
hazelcastInstance
,
times
(
1
)).
getMap
(
"foo:bar:biz"
);
});
}
}
@Test
@Test
public
void
customFlushMode
()
{
public
void
customFlushMode
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
,
this
.
contextRunner
"spring.session.hazelcast.flush-mode=immediate"
).
run
((
context
)
->
{
.
withPropertyValues
(
"spring.session.store-type=hazelcast"
,
HazelcastSessionRepository
repository
=
validateSessionRepository
(
context
,
"spring.session.hazelcast.flush-mode=immediate"
)
HazelcastSessionRepository
.
class
);
.
run
((
context
)
->
{
assertThat
(
new
DirectFieldAccessor
(
repository
)
HazelcastSessionRepository
repository
=
validateSessionRepository
(
.
getPropertyValue
(
"hazelcastFlushMode"
))
context
,
HazelcastSessionRepository
.
class
);
.
isEqualTo
(
HazelcastFlushMode
.
IMMEDIATE
);
assertThat
(
new
DirectFieldAccessor
(
repository
)
});
.
getPropertyValue
(
"hazelcastFlushMode"
))
.
isEqualTo
(
HazelcastFlushMode
.
IMMEDIATE
);
});
}
}
@Configuration
@Configuration
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java
View file @
3882552b
...
@@ -54,60 +54,63 @@ public class SessionAutoConfigurationJdbcTests
...
@@ -54,60 +54,63 @@ public class SessionAutoConfigurationJdbcTests
@Test
@Test
public
void
defaultConfig
()
{
public
void
defaultConfig
()
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
this
.
contextRunner
JdbcTemplateAutoConfiguration
.
class
))
.
withConfiguration
(
AutoConfigurations
.
of
(
JdbcTemplateAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.session.store-type=jdbc"
).
run
((
context
)
->
{
.
withPropertyValues
(
"spring.session.store-type=jdbc"
).
run
((
context
)
->
{
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
context
,
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
JdbcOperationsSessionRepository
.
class
);
context
,
JdbcOperationsSessionRepository
.
class
);
assertThat
(
new
DirectFieldAccessor
(
repository
).
getPropertyValue
(
"tableName"
))
assertThat
(
new
DirectFieldAccessor
(
repository
)
.
isEqualTo
(
"SPRING_SESSION"
);
.
getPropertyValue
(
"tableName"
)).
isEqualTo
(
"SPRING_SESSION"
);
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
).
getInitializeSchema
())
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
)
.
isEqualTo
(
DatabaseInitializationMode
.
EMBEDDED
);
.
getInitializeSchema
())
assertThat
(
context
.
getBean
(
JdbcOperations
.
class
)
.
isEqualTo
(
DatabaseInitializationMode
.
EMBEDDED
);
.
queryForList
(
"select * from SPRING_SESSION"
)).
isEmpty
();
assertThat
(
context
.
getBean
(
JdbcOperations
.
class
)
});
.
queryForList
(
"select * from SPRING_SESSION"
)).
isEmpty
();
});
}
}
@Test
@Test
public
void
filterOrderCanBeCustomized
()
{
public
void
filterOrderCanBeCustomized
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=jdbc"
,
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=jdbc"
,
"spring.session.servlet.filter-order=123"
).
run
((
context
)
->
{
"spring.session.servlet.filter-order=123"
).
run
((
context
)
->
{
FilterRegistrationBean
<?>
registration
=
context
FilterRegistrationBean
<?>
registration
=
context
.
getBean
(
FilterRegistrationBean
.
class
);
.
getBean
(
FilterRegistrationBean
.
class
);
assertThat
(
registration
.
getOrder
()).
isEqualTo
(
123
);
assertThat
(
registration
.
getOrder
()).
isEqualTo
(
123
);
});
});
}
}
@Test
@Test
public
void
disableDatabaseInitializer
()
{
public
void
disableDatabaseInitializer
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=jdbc"
,
"spring.session.store-type=jdbc"
,
"spring.session.jdbc.initialize-schema=never"
).
run
((
context
)
->
{
"spring.session.jdbc.initialize-schema=never"
).
run
((
context
)
->
{
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
context
,
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
JdbcOperationsSessionRepository
.
class
);
context
,
JdbcOperationsSessionRepository
.
class
);
assertThat
(
new
DirectFieldAccessor
(
repository
).
getPropertyValue
(
"tableName"
))
assertThat
(
new
DirectFieldAccessor
(
repository
)
.
isEqualTo
(
"SPRING_SESSION"
);
.
getPropertyValue
(
"tableName"
)).
isEqualTo
(
"SPRING_SESSION"
);
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
).
getInitializeSchema
())
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
)
.
isEqualTo
(
DatabaseInitializationMode
.
NEVER
);
.
getInitializeSchema
())
this
.
thrown
.
expect
(
BadSqlGrammarException
.
class
);
.
isEqualTo
(
DatabaseInitializationMode
.
NEVER
);
context
.
getBean
(
JdbcOperations
.
class
).
queryForList
(
this
.
thrown
.
expect
(
BadSqlGrammarException
.
class
);
"select * from SPRING_SESSION"
);
context
.
getBean
(
JdbcOperations
.
class
)
});
.
queryForList
(
"select * from SPRING_SESSION"
);
});
}
}
@Test
@Test
public
void
customTableName
()
{
public
void
customTableName
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
"spring.session.store-type=jdbc"
,
.
withPropertyValues
(
"spring.session.store-type=jdbc"
,
"spring.session.jdbc.table-name=FOO_BAR"
,
"spring.session.jdbc.table-name=FOO_BAR"
,
"spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql"
)
"spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
context
,
JdbcOperationsSessionRepository
repository
=
validateSessionRepository
(
JdbcOperationsSessionRepository
.
class
);
context
,
JdbcOperationsSessionRepository
.
class
);
assertThat
(
new
DirectFieldAccessor
(
repository
).
getPropertyValue
(
"tableName"
))
assertThat
(
new
DirectFieldAccessor
(
repository
)
.
isEqualTo
(
"FOO_BAR"
);
.
getPropertyValue
(
"tableName"
)).
isEqualTo
(
"FOO_BAR"
);
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
).
getInitializeSchema
())
assertThat
(
context
.
getBean
(
JdbcSessionProperties
.
class
)
.
isEqualTo
(
DatabaseInitializationMode
.
EMBEDDED
);
.
getInitializeSchema
())
.
isEqualTo
(
DatabaseInitializationMode
.
EMBEDDED
);
assertThat
(
context
.
getBean
(
JdbcOperations
.
class
)
assertThat
(
context
.
getBean
(
JdbcOperations
.
class
)
.
queryForList
(
"select * from FOO_BAR"
)).
isEmpty
();
.
queryForList
(
"select * from FOO_BAR"
)).
isEmpty
();
});
});
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
View file @
3882552b
...
@@ -45,10 +45,10 @@ public class SessionAutoConfigurationRedisTests
...
@@ -45,10 +45,10 @@ public class SessionAutoConfigurationRedisTests
protected
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
protected
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
SessionAutoConfiguration
.
class
));
.
withConfiguration
(
AutoConfigurations
.
of
(
SessionAutoConfiguration
.
class
));
@Test
@Test
public
void
redisSessionStore
()
{
public
void
redisSessionStore
()
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
RedisAutoConfiguration
.
class
))
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
RedisAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.session.store-type=redis"
)
.
withPropertyValues
(
"spring.session.store-type=redis"
)
.
run
(
validateSpringSessionUsesRedis
(
"spring:session:event:created:"
,
.
run
(
validateSpringSessionUsesRedis
(
"spring:session:event:created:"
,
RedisFlushMode
.
ON_SAVE
));
RedisFlushMode
.
ON_SAVE
));
...
@@ -56,7 +56,8 @@ public class SessionAutoConfigurationRedisTests
...
@@ -56,7 +56,8 @@ public class SessionAutoConfigurationRedisTests
@Test
@Test
public
void
redisSessionStoreWithCustomizations
()
{
public
void
redisSessionStoreWithCustomizations
()
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
RedisAutoConfiguration
.
class
))
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
RedisAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.session.store-type=redis"
,
.
withPropertyValues
(
"spring.session.store-type=redis"
,
"spring.session.redis.namespace=foo"
,
"spring.session.redis.namespace=foo"
,
"spring.session.redis.flush-mode=immediate"
)
"spring.session.redis.flush-mode=immediate"
)
...
@@ -67,12 +68,12 @@ public class SessionAutoConfigurationRedisTests
...
@@ -67,12 +68,12 @@ public class SessionAutoConfigurationRedisTests
private
ContextConsumer
<
AssertableWebApplicationContext
>
validateSpringSessionUsesRedis
(
private
ContextConsumer
<
AssertableWebApplicationContext
>
validateSpringSessionUsesRedis
(
String
sessionCreatedChannelPrefix
,
RedisFlushMode
flushMode
)
{
String
sessionCreatedChannelPrefix
,
RedisFlushMode
flushMode
)
{
return
context
->
{
return
context
->
{
RedisOperationsSessionRepository
repository
=
validateSessionRepository
(
context
,
RedisOperationsSessionRepository
repository
=
validateSessionRepository
(
RedisOperationsSessionRepository
.
class
);
context
,
RedisOperationsSessionRepository
.
class
);
assertThat
(
repository
.
getSessionCreatedChannelPrefix
())
assertThat
(
repository
.
getSessionCreatedChannelPrefix
())
.
isEqualTo
(
sessionCreatedChannelPrefix
);
.
isEqualTo
(
sessionCreatedChannelPrefix
);
assertThat
(
new
DirectFieldAccessor
(
repository
)
.
getPropertyValue
(
"redisFlushMode"
))
assertThat
(
new
DirectFieldAccessor
(
repository
)
.
isEqualTo
(
flushMode
);
.
getPropertyValue
(
"redisFlushMode"
)).
isEqualTo
(
flushMode
);
};
};
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java
View file @
3882552b
...
@@ -54,10 +54,10 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
...
@@ -54,10 +54,10 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
public
void
contextFailsIfStoreTypeNotSet
()
{
public
void
contextFailsIfStoreTypeNotSet
()
{
this
.
contextRunner
.
run
((
context
)
->
{
this
.
contextRunner
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
getFailure
()
.
hasMessageContaining
(
assertThat
(
context
).
getFailure
()
"No Spring Session store is configured"
);
.
hasMessageContaining
(
"No Spring Session store is configured"
);
assertThat
(
context
).
getFailure
()
.
hasMessageContaining
(
assertThat
(
context
).
getFailure
()
"set the 'spring.session.store-type' property"
);
.
hasMessageContaining
(
"set the 'spring.session.store-type' property"
);
});
});
}
}
...
@@ -66,11 +66,12 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
...
@@ -66,11 +66,12 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=jdbc"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=jdbc"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
getFailure
().
isInstanceOf
(
BeanCreationException
.
class
);
assertThat
(
context
).
getFailure
()
.
isInstanceOf
(
BeanCreationException
.
class
);
assertThat
(
context
).
getFailure
().
hasMessageContaining
(
assertThat
(
context
).
getFailure
().
hasMessageContaining
(
"No session repository could be auto-configured"
);
"No session repository could be auto-configured"
);
assertThat
(
context
).
getFailure
()
.
hasMessageContaining
(
assertThat
(
context
).
getFailure
()
"session store type is 'jdbc'"
);
.
hasMessageContaining
(
"session store type is 'jdbc'"
);
});
});
}
}
...
@@ -85,35 +86,39 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
...
@@ -85,35 +86,39 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
public
void
backOffIfSessionRepositoryIsPresent
()
{
public
void
backOffIfSessionRepositoryIsPresent
()
{
this
.
contextRunner
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
.
withPropertyValues
(
"spring.session.store-type=redis"
).
run
((
context
)
->
{
.
withPropertyValues
(
"spring.session.store-type=redis"
).
run
((
context
)
->
{
MapSessionRepository
repository
=
validateSessionRepository
(
context
,
MapSessionRepository
repository
=
validateSessionRepository
(
context
,
MapSessionRepository
.
class
);
MapSessionRepository
.
class
);
assertThat
(
context
).
getBean
(
"mySessionRepository"
).
isSameAs
(
repository
);
assertThat
(
context
).
getBean
(
"mySessionRepository"
)
});
.
isSameAs
(
repository
);
});
}
}
@Test
@Test
public
void
springSessionTimeoutIsNotAValidProperty
()
{
public
void
springSessionTimeoutIsNotAValidProperty
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.session.timeout=3000"
)
"spring.session.timeout=3000"
).
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
hasFailed
();
assertThat
(
context
).
getFailure
().
isInstanceOf
(
BeanCreationException
.
class
);
assertThat
(
context
).
getFailure
()
assertThat
(
context
).
getFailure
().
hasMessageContaining
(
"Could not bind"
);
.
isInstanceOf
(
BeanCreationException
.
class
);
});
assertThat
(
context
).
getFailure
()
.
hasMessageContaining
(
"Could not bind"
);
});
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
@Test
@Test
public
void
filterIsRegisteredWithAsyncErrorAndRequestDispatcherTypes
()
{
public
void
filterIsRegisteredWithAsyncErrorAndRequestDispatcherTypes
()
{
this
.
contextRunner
.
withUserConfiguration
(
this
.
contextRunner
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
SessionRepositoryConfiguration
.
class
).
run
((
context
)
->
{
.
run
((
context
)
->
{
FilterRegistrationBean
<?>
registration
=
context
FilterRegistrationBean
<?>
registration
=
context
.
getBean
(
FilterRegistrationBean
.
class
);
.
getBean
(
FilterRegistrationBean
.
class
);
assertThat
(
registration
.
getFilter
())
assertThat
(
registration
.
getFilter
())
.
isSameAs
(
context
.
getBean
(
SessionRepositoryFilter
.
class
));
.
isSameAs
(
context
.
getBean
(
SessionRepositoryFilter
.
class
));
assertThat
((
EnumSet
<
DispatcherType
>)
ReflectionTestUtils
.
getField
(
registration
,
assertThat
((
EnumSet
<
DispatcherType
>)
ReflectionTestUtils
"dispatcherTypes"
)).
containsOnly
(
DispatcherType
.
ASYNC
,
.
getField
(
registration
,
"dispatcherTypes"
)).
containsOnly
(
DispatcherType
.
ERROR
,
DispatcherType
.
REQUEST
);
DispatcherType
.
ASYNC
,
DispatcherType
.
ERROR
,
});
DispatcherType
.
REQUEST
);
});
}
}
@Test
@Test
...
@@ -131,13 +136,14 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
...
@@ -131,13 +136,14 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
@Test
@Test
public
void
filterDispatcherTypesCanBeCustomized
()
{
public
void
filterDispatcherTypesCanBeCustomized
()
{
this
.
contextRunner
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
.
withPropertyValues
(
"spring.session.servlet.filter-dispatcher-types=error, request"
)
.
withPropertyValues
(
"spring.session.servlet.filter-dispatcher-types=error, request"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
FilterRegistrationBean
<?>
registration
=
context
FilterRegistrationBean
<?>
registration
=
context
.
getBean
(
FilterRegistrationBean
.
class
);
.
getBean
(
FilterRegistrationBean
.
class
);
assertThat
((
EnumSet
<
DispatcherType
>)
ReflectionTestUtils
.
getField
(
registration
,
assertThat
((
EnumSet
<
DispatcherType
>)
ReflectionTestUtils
"dispatcherTypes"
)).
containsOnly
(
DispatcherType
.
ERROR
,
.
getField
(
registration
,
"dispatcherTypes"
)).
containsOnly
(
DispatcherType
.
REQUEST
);
DispatcherType
.
ERROR
,
DispatcherType
.
REQUEST
);
});
});
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java
View file @
3882552b
...
@@ -368,7 +368,7 @@ public class ValidationAutoConfigurationTests {
...
@@ -368,7 +368,7 @@ public class ValidationAutoConfigurationTests {
static
class
TestBeanPostProcessor
implements
BeanPostProcessor
{
static
class
TestBeanPostProcessor
implements
BeanPostProcessor
{
private
Set
<
String
>
postProcessed
=
new
HashSet
<
String
>();
private
Set
<
String
>
postProcessed
=
new
HashSet
<>();
@Override
@Override
public
Object
postProcessAfterInitialization
(
Object
bean
,
String
name
)
{
public
Object
postProcessAfterInitialization
(
Object
bean
,
String
name
)
{
...
...
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