Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
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-boot-admin
Commits
52c8fe85
Commit
52c8fe85
authored
Jun 22, 2016
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
9086e00c
f95f7a51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
6 deletions
+38
-6
.gitignore
.gitignore
+1
-0
EurekaServiceInstanceConverter.java
.../boot/admin/discovery/EurekaServiceInstanceConverter.java
+9
-1
EurekaServiceInstanceConverterTest.java
...t/admin/discovery/EurekaServiceInstanceConverterTest.java
+28
-5
No files found.
.gitignore
View file @
52c8fe85
...
...
@@ -5,6 +5,7 @@ target/
.settings/
.classpath
.project
.factorypath
# Intellij
.idea/
...
...
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/discovery/EurekaServiceInstanceConverter.java
View file @
52c8fe85
...
...
@@ -20,6 +20,9 @@ import java.net.URI;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
com.netflix.appinfo.InstanceInfo
;
import
de.codecentric.boot.admin.model.Application
;
...
...
@@ -35,6 +38,11 @@ public class EurekaServiceInstanceConverter extends DefaultServiceInstanceConver
Assert
.
isInstanceOf
(
EurekaServiceInstance
.
class
,
instance
,
"serviceInstance must be of type EurekaServiceInstance"
);
return
URI
.
create
(((
EurekaServiceInstance
)
instance
).
getInstanceInfo
().
getHealthCheckUrl
());
InstanceInfo
instanceInfo
=
((
EurekaServiceInstance
)
instance
).
getInstanceInfo
();
String
healthUrl
=
instanceInfo
.
getSecureHealthCheckUrl
();
if
(
StringUtils
.
isEmpty
(
healthUrl
))
{
healthUrl
=
instanceInfo
.
getHealthCheckUrl
();
}
return
URI
.
create
(
healthUrl
);
}
}
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/discovery/EurekaServiceInstanceConverterTest.java
View file @
52c8fe85
...
...
@@ -8,7 +8,6 @@ import static org.mockito.Mockito.mock;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.net.URI
;
import
java.util.Collections
;
import
org.junit.Test
;
import
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance
;
...
...
@@ -20,8 +19,9 @@ import de.codecentric.boot.admin.model.Application;
public
class
EurekaServiceInstanceConverterTest
{
@Test
public
void
convert
()
{
public
void
convert
_secure
()
{
InstanceInfo
instanceInfo
=
mock
(
InstanceInfo
.
class
);
when
(
instanceInfo
.
getSecureHealthCheckUrl
()).
thenReturn
(
""
);
when
(
instanceInfo
.
getHealthCheckUrl
()).
thenReturn
(
"http://localhost:80/mgmt/ping"
);
EurekaServiceInstance
service
=
mock
(
EurekaServiceInstance
.
class
);
when
(
service
.
getInstanceInfo
()).
thenReturn
(
instanceInfo
);
...
...
@@ -36,10 +36,33 @@ public class EurekaServiceInstanceConverterTest {
assertThat
(
application
.
getServiceUrl
(),
is
(
"http://localhost:80"
));
assertThat
(
application
.
getManagementUrl
(),
is
(
"http://localhost:80/mgmt"
));
assertThat
(
application
.
getHealthUrl
(),
is
(
"http://localhost:80/mgmt/ping"
));
}
@Test
public
void
convert_missing_mgmtpath
()
{
InstanceInfo
instanceInfo
=
mock
(
InstanceInfo
.
class
);
when
(
instanceInfo
.
getHealthCheckUrl
()).
thenReturn
(
"http://localhost:80/mgmt/ping"
);
EurekaServiceInstance
service
=
mock
(
EurekaServiceInstance
.
class
);
when
(
service
.
getInstanceInfo
()).
thenReturn
(
instanceInfo
);
when
(
service
.
getUri
()).
thenReturn
(
URI
.
create
(
"http://localhost:80"
));
when
(
service
.
getServiceId
()).
thenReturn
(
"test"
);
Application
application
=
new
EurekaServiceInstanceConverter
().
convert
(
service
);
// no management url in metadata
when
(
service
.
getMetadata
()).
thenReturn
(
Collections
.<
String
,
String
>
emptyMap
());
application
=
new
EurekaServiceInstanceConverter
().
convert
(
service
);
assertThat
(
application
.
getManagementUrl
(),
is
(
"http://localhost:80"
));
}
@Test
public
void
convert_secure_healthUrl
()
{
InstanceInfo
instanceInfo
=
mock
(
InstanceInfo
.
class
);
when
(
instanceInfo
.
getSecureHealthCheckUrl
()).
thenReturn
(
"https://localhost:80/health"
);
EurekaServiceInstance
service
=
mock
(
EurekaServiceInstance
.
class
);
when
(
service
.
getInstanceInfo
()).
thenReturn
(
instanceInfo
);
when
(
service
.
getUri
()).
thenReturn
(
URI
.
create
(
"http://localhost:80"
));
when
(
service
.
getServiceId
()).
thenReturn
(
"test"
);
Application
application
=
new
EurekaServiceInstanceConverter
().
convert
(
service
);
assertThat
(
application
.
getHealthUrl
(),
is
(
"https://localhost:80/health"
));
}
}
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