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
95c8af46
Commit
95c8af46
authored
Sep 15, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gh-3955'
parents
b79ca614
2fd8a581
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
EmbeddedMongoAutoConfiguration.java
...figure/mongo/embedded/EmbeddedMongoAutoConfiguration.java
+5
-5
EmbeddedMongoAutoConfigurationTests.java
...e/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java
+24
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java
View file @
95c8af46
...
@@ -154,9 +154,9 @@ public class EmbeddedMongoAutoConfiguration {
...
@@ -154,9 +154,9 @@ public class EmbeddedMongoAutoConfiguration {
setPortProperty
(
this
.
context
,
port
);
setPortProperty
(
this
.
context
,
port
);
}
}
private
void
setPortProperty
(
ApplicationContext
context
,
int
port
)
{
private
void
setPortProperty
(
ApplicationContext
c
urrentC
ontext
,
int
port
)
{
if
(
context
instanceof
ConfigurableApplicationContext
)
{
if
(
c
urrentC
ontext
instanceof
ConfigurableApplicationContext
)
{
ConfigurableEnvironment
environment
=
((
ConfigurableApplicationContext
)
context
)
ConfigurableEnvironment
environment
=
((
ConfigurableApplicationContext
)
c
urrentC
ontext
)
.
getEnvironment
();
.
getEnvironment
();
MutablePropertySources
sources
=
environment
.
getPropertySources
();
MutablePropertySources
sources
=
environment
.
getPropertySources
();
Map
<
String
,
Object
>
map
;
Map
<
String
,
Object
>
map
;
...
@@ -173,8 +173,8 @@ public class EmbeddedMongoAutoConfiguration {
...
@@ -173,8 +173,8 @@ public class EmbeddedMongoAutoConfiguration {
}
}
map
.
put
(
"local.mongo.port"
,
port
);
map
.
put
(
"local.mongo.port"
,
port
);
}
}
if
(
this
.
c
ontext
.
getParent
()
!=
null
)
{
if
(
currentC
ontext
.
getParent
()
!=
null
)
{
setPortProperty
(
this
.
c
ontext
.
getParent
(),
port
);
setPortProperty
(
currentC
ontext
.
getParent
(),
port
);
}
}
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java
View file @
95c8af46
...
@@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoDataAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoDataAutoConfiguration
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -38,6 +39,8 @@ import de.flapdoodle.embed.mongo.distribution.Feature;
...
@@ -38,6 +39,8 @@ import de.flapdoodle.embed.mongo.distribution.Feature;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
hasItems
;
import
static
org
.
hamcrest
.
Matchers
.
hasItems
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
/**
...
@@ -93,6 +96,27 @@ public class EmbeddedMongoAutoConfigurationTests {
...
@@ -93,6 +96,27 @@ public class EmbeddedMongoAutoConfigurationTests {
"local.mongo.port"
))));
"local.mongo.port"
))));
}
}
@Test
public
void
portIsAvailableInParentContext
()
{
ConfigurableApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
parent
.
refresh
();
try
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
setParent
(
parent
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.mongodb.port=0"
);
this
.
context
.
register
(
EmbeddedMongoAutoConfiguration
.
class
,
MongoClientConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertThat
(
parent
.
getEnvironment
().
getProperty
(
"local.mongo.port"
),
is
(
notNullValue
()));
}
finally
{
parent
.
close
();
}
}
private
void
assertVersionConfiguration
(
String
configuredVersion
,
private
void
assertVersionConfiguration
(
String
configuredVersion
,
String
expectedVersion
)
{
String
expectedVersion
)
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
...
...
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