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
fd368364
Commit
fd368364
authored
Sep 29, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate SessionAutoConfigurationMongoTests to Testcontainers
Closes gh-23512
parent
350ef975
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
pom.xml
spring-boot-project/spring-boot-autoconfigure/pom.xml
+5
-0
SessionAutoConfigurationMongoTests.java
...configure/session/SessionAutoConfigurationMongoTests.java
+14
-9
No files found.
spring-boot-project/spring-boot-autoconfigure/pom.xml
View file @
fd368364
...
@@ -993,6 +993,11 @@
...
@@ -993,6 +993,11 @@
<artifactId>
junit-jupiter
</artifactId>
<artifactId>
junit-jupiter
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.testcontainers
</groupId>
<artifactId>
mongodb
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
org.testcontainers
</groupId>
<groupId>
org.testcontainers
</groupId>
<artifactId>
testcontainers
</artifactId>
<artifactId>
testcontainers
</artifactId>
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationMongoTests.java
View file @
fd368364
/*
/*
* 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,12 +16,16 @@
...
@@ -16,12 +16,16 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
session
;
package
org
.
springframework
.
boot
.
autoconfigure
.
session
;
import
java.time.Duration
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.testcontainers.containers.MongoDBContainer
;
import
org.testcontainers.junit.jupiter.Container
;
import
org.testcontainers.junit.jupiter.Testcontainers
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
;
import
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration
;
import
org.springframework.boot.test.context.FilteredClassLoader
;
import
org.springframework.boot.test.context.FilteredClassLoader
;
import
org.springframework.boot.test.context.assertj.AssertableWebApplicationContext
;
import
org.springframework.boot.test.context.assertj.AssertableWebApplicationContext
;
import
org.springframework.boot.test.context.runner.ContextConsumer
;
import
org.springframework.boot.test.context.runner.ContextConsumer
;
...
@@ -38,16 +42,21 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -38,16 +42,21 @@ import static org.assertj.core.api.Assertions.assertThat;
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
@Testcontainers
(
disabledWithoutDocker
=
true
)
class
SessionAutoConfigurationMongoTests
extends
AbstractSessionAutoConfigurationTests
{
class
SessionAutoConfigurationMongoTests
extends
AbstractSessionAutoConfigurationTests
{
@Container
static
final
MongoDBContainer
mongoDB
=
new
MongoDBContainer
().
withStartupAttempts
(
5
)
.
withStartupTimeout
(
Duration
.
ofMinutes
(
5
));
private
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
private
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
SessionAutoConfiguration
.
class
));
.
withConfiguration
(
AutoConfigurations
.
of
(
MongoAutoConfiguration
.
class
,
MongoDataAutoConfiguration
.
class
,
SessionAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.data.mongodb.uri="
+
mongoDB
.
getReplicaSetUrl
());
@Test
@Test
void
defaultConfig
()
{
void
defaultConfig
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=mongodb"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.session.store-type=mongodb"
)
.
withConfiguration
(
AutoConfigurations
.
of
(
EmbeddedMongoAutoConfiguration
.
class
,
MongoAutoConfiguration
.
class
,
MongoDataAutoConfiguration
.
class
))
.
run
(
validateSpringSessionUsesMongo
(
"sessions"
));
.
run
(
validateSpringSessionUsesMongo
(
"sessions"
));
}
}
...
@@ -56,16 +65,12 @@ class SessionAutoConfigurationMongoTests extends AbstractSessionAutoConfiguratio
...
@@ -56,16 +65,12 @@ class SessionAutoConfigurationMongoTests extends AbstractSessionAutoConfiguratio
this
.
contextRunner
this
.
contextRunner
.
withClassLoader
(
new
FilteredClassLoader
(
HazelcastIndexedSessionRepository
.
class
,
.
withClassLoader
(
new
FilteredClassLoader
(
HazelcastIndexedSessionRepository
.
class
,
JdbcIndexedSessionRepository
.
class
,
RedisIndexedSessionRepository
.
class
))
JdbcIndexedSessionRepository
.
class
,
RedisIndexedSessionRepository
.
class
))
.
withConfiguration
(
AutoConfigurations
.
of
(
EmbeddedMongoAutoConfiguration
.
class
,
MongoAutoConfiguration
.
class
,
MongoDataAutoConfiguration
.
class
))
.
run
(
validateSpringSessionUsesMongo
(
"sessions"
));
.
run
(
validateSpringSessionUsesMongo
(
"sessions"
));
}
}
@Test
@Test
void
mongoSessionStoreWithCustomizations
()
{
void
mongoSessionStoreWithCustomizations
()
{
this
.
contextRunner
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
EmbeddedMongoAutoConfiguration
.
class
,
MongoAutoConfiguration
.
class
,
MongoDataAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.session.store-type=mongodb"
,
"spring.session.mongodb.collection-name=foo"
)
.
withPropertyValues
(
"spring.session.store-type=mongodb"
,
"spring.session.mongodb.collection-name=foo"
)
.
run
(
validateSpringSessionUsesMongo
(
"foo"
));
.
run
(
validateSpringSessionUsesMongo
(
"foo"
));
}
}
...
...
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