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
3aea2301
Commit
3aea2301
authored
Feb 09, 2017
by
Mike Liu
Committed by
Johannes Edmeier
Feb 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose registered id in ApplicationRegistrator
closes #404
parent
94aec760
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
ApplicationRegistrator.java
...oot/admin/client/registration/ApplicationRegistrator.java
+10
-0
ApplicationRegistratorTest.java
...c/boot/admin/registration/ApplicationRegistratorTest.java
+8
-0
No files found.
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/client/registration/ApplicationRegistrator.java
View file @
3aea2301
...
@@ -112,6 +112,16 @@ public class ApplicationRegistrator {
...
@@ -112,6 +112,16 @@ public class ApplicationRegistrator {
}
}
}
}
/**
* Returns the id of this client as given by the admin server.
* Returns null if the client has not registered against the admin server yet.
*
* @return
*/
public
String
getRegisteredId
()
{
return
registeredId
.
get
();
}
protected
Application
createApplication
()
{
protected
Application
createApplication
()
{
return
applicationFactory
.
createApplication
();
return
applicationFactory
.
createApplication
();
}
}
...
...
spring-boot-admin-starter-client/src/test/java/de/codecentric/boot/admin/registration/ApplicationRegistratorTest.java
View file @
3aea2301
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
de
.
codecentric
.
boot
.
admin
.
registration
;
package
de
.
codecentric
.
boot
.
admin
.
registration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Matchers
.
eq
;
...
@@ -77,6 +78,7 @@ public class ApplicationRegistratorTest {
...
@@ -77,6 +78,7 @@ public class ApplicationRegistratorTest {
HttpStatus
.
CREATED
));
HttpStatus
.
CREATED
));
assertTrue
(
registrator
.
register
());
assertTrue
(
registrator
.
register
());
assertEquals
(
"-id-"
,
registrator
.
getRegisteredId
());
verify
(
restTemplate
)
verify
(
restTemplate
)
.
postForEntity
(
"http://sba:8080/api/applications"
,
.
postForEntity
(
"http://sba:8080/api/applications"
,
new
HttpEntity
<>(
Application
.
create
(
"AppName"
)
new
HttpEntity
<>(
Application
.
create
(
"AppName"
)
...
@@ -92,6 +94,7 @@ public class ApplicationRegistratorTest {
...
@@ -92,6 +94,7 @@ public class ApplicationRegistratorTest {
eq
(
Application
.
class
))).
thenThrow
(
new
RestClientException
(
"Error"
));
eq
(
Application
.
class
))).
thenThrow
(
new
RestClientException
(
"Error"
));
assertFalse
(
registrator
.
register
());
assertFalse
(
registrator
.
register
());
assertEquals
(
null
,
registrator
.
getRegisteredId
());
}
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
...
@@ -104,6 +107,7 @@ public class ApplicationRegistratorTest {
...
@@ -104,6 +107,7 @@ public class ApplicationRegistratorTest {
HttpStatus
.
CREATED
));
HttpStatus
.
CREATED
));
assertTrue
(
registrator
.
register
());
assertTrue
(
registrator
.
register
());
assertEquals
(
"-id-"
,
registrator
.
getRegisteredId
());
}
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
...
@@ -113,7 +117,9 @@ public class ApplicationRegistratorTest {
...
@@ -113,7 +117,9 @@ public class ApplicationRegistratorTest {
.
thenReturn
(
new
ResponseEntity
<
Map
>(
Collections
.
singletonMap
(
"id"
,
"-id-"
),
.
thenReturn
(
new
ResponseEntity
<
Map
>(
Collections
.
singletonMap
(
"id"
,
"-id-"
),
HttpStatus
.
CREATED
));
HttpStatus
.
CREATED
));
registrator
.
register
();
registrator
.
register
();
assertEquals
(
"-id-"
,
registrator
.
getRegisteredId
());
registrator
.
deregister
();
registrator
.
deregister
();
assertEquals
(
null
,
registrator
.
getRegisteredId
());
verify
(
restTemplate
).
delete
(
"http://sba:8080/api/applications/-id-"
);
verify
(
restTemplate
).
delete
(
"http://sba:8080/api/applications/-id-"
);
}
}
...
@@ -128,6 +134,7 @@ public class ApplicationRegistratorTest {
...
@@ -128,6 +134,7 @@ public class ApplicationRegistratorTest {
HttpStatus
.
CREATED
));
HttpStatus
.
CREATED
));
assertTrue
(
registrator
.
register
());
assertTrue
(
registrator
.
register
());
assertEquals
(
"-id-"
,
registrator
.
getRegisteredId
());
verify
(
restTemplate
)
verify
(
restTemplate
)
.
postForEntity
(
"http://sba:8080/api/applications"
,
.
postForEntity
(
"http://sba:8080/api/applications"
,
...
@@ -157,6 +164,7 @@ public class ApplicationRegistratorTest {
...
@@ -157,6 +164,7 @@ public class ApplicationRegistratorTest {
.
thenThrow
(
new
RestClientException
(
"Error"
));
.
thenThrow
(
new
RestClientException
(
"Error"
));
assertTrue
(
registrator
.
register
());
assertTrue
(
registrator
.
register
());
assertEquals
(
"-id-"
,
registrator
.
getRegisteredId
());
verify
(
restTemplate
)
verify
(
restTemplate
)
.
postForEntity
(
"http://sba:8080/api/applications"
,
.
postForEntity
(
"http://sba:8080/api/applications"
,
...
...
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