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
85b2fe37
Commit
85b2fe37
authored
Oct 25, 2016
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some additional tests
parent
657d9bb8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+1
-1
EurekaClientAutoConfigurationTests.java
...ud/netflix/eureka/EurekaClientAutoConfigurationTests.java
+17
-0
EurekaInstanceConfigBeanTests.java
...k/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
+2
-1
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
85b2fe37
...
...
@@ -113,7 +113,7 @@ public class EurekaClientAutoConfiguration {
EurekaInstanceConfigBean
instance
=
new
EurekaInstanceConfigBean
(
inetUtils
);
instance
.
setNonSecurePort
(
this
.
nonSecurePort
);
instance
.
setInstanceId
(
getDefaultInstanceId
(
this
.
env
));
if
(
springAppName
!=
null
)
{
if
(
StringUtils
.
hasText
(
springAppName
)
)
{
instance
.
setAppname
(
springAppName
);
instance
.
setVirtualHostName
(
springAppName
);
instance
.
setSecureVirtualHostName
(
springAppName
);
...
...
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
View file @
85b2fe37
...
...
@@ -189,6 +189,23 @@ public class EurekaClientAutoConfigurationTests {
// Mockito.verify(http).addFilter(Matchers.any(HTTPBasicAuthFilter.class));
}
@Test
public
void
testDefaultAppName
()
throws
Exception
{
setupContext
();
assertEquals
(
"unknown"
,
getInstanceConfig
().
getAppname
());
assertEquals
(
"unknown"
,
getInstanceConfig
().
getVirtualHostName
());
assertEquals
(
"unknown"
,
getInstanceConfig
().
getSecureVirtualHostName
());
}
@Test
public
void
testAppName
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.application.name=mytest"
);
setupContext
();
assertEquals
(
"mytest"
,
getInstanceConfig
().
getAppname
());
assertEquals
(
"mytest"
,
getInstanceConfig
().
getVirtualHostName
());
assertEquals
(
"mytest"
,
getInstanceConfig
().
getSecureVirtualHostName
());
}
private
void
testNonSecurePort
(
String
propName
)
{
addEnvironment
(
this
.
context
,
propName
+
":8888"
);
setupContext
();
...
...
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java
View file @
85b2fe37
...
...
@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.StringUtils
;
import
com.netflix.appinfo.InstanceInfo.InstanceStatus
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -216,7 +217,7 @@ public class EurekaInstanceConfigBeanTests {
EurekaInstanceConfigBean
configBean
=
new
EurekaInstanceConfigBean
(
new
InetUtils
(
new
InetUtilsProperties
()));
RelaxedPropertyResolver
springPropertyResolver
=
new
RelaxedPropertyResolver
(
env
,
"spring.application."
);
String
springAppName
=
springPropertyResolver
.
getProperty
(
"name"
);
if
(
springAppName
!=
null
)
{
if
(
StringUtils
.
hasText
(
springAppName
)
)
{
configBean
.
setSecureVirtualHostName
(
springAppName
);
configBean
.
setVirtualHostName
(
springAppName
);
configBean
.
setAppname
(
springAppName
);
...
...
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