Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
26c9f972
Unverified
Commit
26c9f972
authored
May 10, 2018
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes unused TurbinePortApplicationListener.
parent
97eea5bd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
107 deletions
+0
-107
TurbinePortApplicationListener.java
...etflix/turbine/stream/TurbinePortApplicationListener.java
+0
-44
spring.factories
...rbine-stream/src/main/resources/META-INF/spring.factories
+0
-4
TurbinePortApplicationListenerTests.java
...x/turbine/stream/TurbinePortApplicationListenerTests.java
+0
-59
No files found.
spring-cloud-netflix-turbine-stream/src/main/java/org/springframework/cloud/netflix/turbine/stream/TurbinePortApplicationListener.java
deleted
100644 → 0
View file @
97eea5bd
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.core.env.MapPropertySource
;
public
class
TurbinePortApplicationListener
implements
ApplicationListener
<
ApplicationEnvironmentPreparedEvent
>
{
@Override
public
void
onApplicationEvent
(
ApplicationEnvironmentPreparedEvent
event
)
{
Integer
serverPort
=
event
.
getEnvironment
().
getProperty
(
"server.port"
,
Integer
.
class
);
Integer
managementPort
=
event
.
getEnvironment
().
getProperty
(
"management.port"
,
Integer
.
class
);
Integer
turbinePort
=
event
.
getEnvironment
().
getProperty
(
"turbine.stream.port"
,
Integer
.
class
);
if
(
serverPort
==
null
&&
managementPort
==
null
)
{
return
;
}
if
(
serverPort
!=
Integer
.
valueOf
(-
1
))
{
Map
<
String
,
Object
>
ports
=
new
HashMap
<>();
if
(
turbinePort
==
null
)
{
// The actual server.port used by the application forced to be -1 (no user
// endpoints) because no value was provided for turbine
ports
.
put
(
"server.port"
,
-
1
);
if
(
serverPort
!=
null
)
{
// Turbine port defaults to server port value supplied by user
ports
.
put
(
"turbine.stream.port"
,
serverPort
);
}
}
else
if
(
managementPort
!=
null
&&
managementPort
!=
-
1
&&
serverPort
==
null
)
{
// User wants 2 ports, but hasn't specified server.port explicitly
ports
.
put
(
"server.port"
,
managementPort
);
}
event
.
getEnvironment
().
getPropertySources
()
.
addFirst
(
new
MapPropertySource
(
"ports"
,
ports
));
}
}
}
spring-cloud-netflix-turbine-stream/src/main/resources/META-INF/spring.factories
View file @
26c9f972
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.netflix.turbine.stream.TurbineStreamAutoConfiguration
#org.springframework.context.ApplicationListener=\
#org.springframework.cloud.netflix.turbine.stream.TurbinePortApplicationListener
\ No newline at end of file
spring-cloud-netflix-turbine-stream/src/test/java/org/springframework/cloud/netflix/turbine/stream/TurbinePortApplicationListenerTests.java
deleted
100644 → 0
View file @
97eea5bd
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.StandardEnvironment
;
public
class
TurbinePortApplicationListenerTests
{
private
TurbinePortApplicationListener
listener
=
new
TurbinePortApplicationListener
();
private
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
private
ApplicationEnvironmentPreparedEvent
event
=
new
ApplicationEnvironmentPreparedEvent
(
new
SpringApplication
(),
null
,
environment
);
@Test
public
void
noop
()
{
listener
.
onApplicationEvent
(
event
);
}
@Test
public
void
serverPortOnly
()
{
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"server.port=9999"
);
listener
.
onApplicationEvent
(
event
);
assertEquals
(
"-1"
,
environment
.
resolvePlaceholders
(
"${server.port}"
));
assertEquals
(
"9999"
,
environment
.
resolvePlaceholders
(
"${turbine.stream.port}"
));
}
@Test
public
void
turbinePortOnly
()
{
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"turbine.stream.port=9999"
);
listener
.
onApplicationEvent
(
event
);
assertEquals
(
"9999"
,
environment
.
resolvePlaceholders
(
"${turbine.stream.port}"
));
assertEquals
(
"0"
,
environment
.
resolvePlaceholders
(
"${server.port:0}"
));
}
@Test
public
void
turbineAndManagementPorts
()
{
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"turbine.stream.port=9999"
,
"management.port=9000"
);
listener
.
onApplicationEvent
(
event
);
assertEquals
(
"9999"
,
environment
.
resolvePlaceholders
(
"${turbine.stream.port}"
));
assertEquals
(
"9000"
,
environment
.
resolvePlaceholders
(
"${server.port:0}"
));
assertEquals
(
"9000"
,
environment
.
resolvePlaceholders
(
"${management.port:0}"
));
}
@Test
public
void
turbineAndServerPorts
()
{
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"turbine.stream.port=9999"
,
"server.port=9000"
);
listener
.
onApplicationEvent
(
event
);
assertEquals
(
"9999"
,
environment
.
resolvePlaceholders
(
"${turbine.stream.port}"
));
assertEquals
(
"9000"
,
environment
.
resolvePlaceholders
(
"${server.port:0}"
));
assertEquals
(
"0"
,
environment
.
resolvePlaceholders
(
"${management.port:0}"
));
}
}
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