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
98629238
Commit
98629238
authored
Jul 13, 2017
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use lombok in spring-boot-admin-client
parent
071e36c7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
331 deletions
+143
-331
pom.xml
spring-boot-admin-starter-client/pom.xml
+21
-0
ClientProperties.java
...odecentric/boot/admin/client/config/ClientProperties.java
+1
-72
InstanceProperties.java
...ecentric/boot/admin/client/config/InstanceProperties.java
+1
-63
Application.java
...decentric/boot/admin/client/registration/Application.java
+31
-149
DefaultApplicationFactory.java
.../admin/client/registration/DefaultApplicationFactory.java
+21
-4
ApplicationRegistratorTest.java
...c/boot/admin/registration/ApplicationRegistratorTest.java
+14
-14
ApplicationTest.java
.../codecentric/boot/admin/registration/ApplicationTest.java
+54
-29
No files found.
spring-boot-admin-starter-client/pom.xml
View file @
98629238
<!--
~ Copyright 2014-2017 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -35,6 +51,11 @@
...
@@ -35,6 +51,11 @@
<artifactId>
jolokia-core
</artifactId>
<artifactId>
jolokia-core
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<!-- Make json-simple non-optional.
<!-- Make json-simple non-optional.
It is marked optional in boot-dependencies, but required by jolokia-core.
It is marked optional in boot-dependencies, but required by jolokia-core.
Without this fix it would be missing when used war-packaging. -->
Without this fix it would be missing when used war-packaging. -->
...
...
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/client/config/ClientProperties.java
View file @
98629238
...
@@ -17,6 +17,7 @@ package de.codecentric.boot.admin.client.config;
...
@@ -17,6 +17,7 @@ package de.codecentric.boot.admin.client.config;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@lombok
.
Data
@ConfigurationProperties
(
prefix
=
"spring.boot.admin.client"
)
@ConfigurationProperties
(
prefix
=
"spring.boot.admin.client"
)
public
class
ClientProperties
{
public
class
ClientProperties
{
...
@@ -65,22 +66,6 @@ public class ClientProperties {
...
@@ -65,22 +66,6 @@ public class ClientProperties {
*/
*/
private
boolean
enabled
=
true
;
private
boolean
enabled
=
true
;
public
void
setUrl
(
String
[]
url
)
{
this
.
url
=
url
.
clone
();
}
public
String
[]
getUrl
()
{
return
url
.
clone
();
}
public
void
setApiPath
(
String
apiPath
)
{
this
.
apiPath
=
apiPath
;
}
public
String
getApiPath
()
{
return
apiPath
;
}
public
String
[]
getAdminUrl
()
{
public
String
[]
getAdminUrl
()
{
String
adminUrls
[]
=
url
.
clone
();
String
adminUrls
[]
=
url
.
clone
();
for
(
int
i
=
0
;
i
<
adminUrls
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
adminUrls
.
length
;
i
++)
{
...
@@ -88,60 +73,4 @@ public class ClientProperties {
...
@@ -88,60 +73,4 @@ public class ClientProperties {
}
}
return
adminUrls
;
return
adminUrls
;
}
}
public
long
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
int
period
)
{
this
.
period
=
period
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getPassword
()
{
return
password
;
}
public
boolean
isAutoDeregistration
()
{
return
autoDeregistration
;
}
public
void
setAutoDeregistration
(
boolean
autoDeregistration
)
{
this
.
autoDeregistration
=
autoDeregistration
;
}
public
boolean
isAutoRegistration
()
{
return
autoRegistration
;
}
public
void
setAutoRegistration
(
boolean
autoRegistration
)
{
this
.
autoRegistration
=
autoRegistration
;
}
public
boolean
isRegisterOnce
()
{
return
registerOnce
;
}
public
void
setRegisterOnce
(
boolean
registerOnce
)
{
this
.
registerOnce
=
registerOnce
;
}
public
boolean
isEnabled
()
{
return
enabled
;
}
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
}
}
}
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/client/config/InstanceProperties.java
View file @
98629238
...
@@ -20,6 +20,7 @@ import java.util.Map;
...
@@ -20,6 +20,7 @@ import java.util.Map;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@lombok
.
Data
@ConfigurationProperties
(
prefix
=
"spring.boot.admin.client.instance"
)
@ConfigurationProperties
(
prefix
=
"spring.boot.admin.client.instance"
)
public
class
InstanceProperties
{
public
class
InstanceProperties
{
/**
/**
...
@@ -66,67 +67,4 @@ public class InstanceProperties {
...
@@ -66,67 +67,4 @@ public class InstanceProperties {
*/
*/
private
Map
<
String
,
String
>
metadata
=
new
HashMap
<>();
private
Map
<
String
,
String
>
metadata
=
new
HashMap
<>();
public
String
getManagementUrl
()
{
return
managementUrl
;
}
public
void
setManagementUrl
(
String
managementUrl
)
{
this
.
managementUrl
=
managementUrl
;
}
public
String
getServiceUrl
()
{
return
serviceUrl
;
}
public
void
setServiceUrl
(
String
serviceUrl
)
{
this
.
serviceUrl
=
serviceUrl
;
}
public
String
getHealthUrl
()
{
return
healthUrl
;
}
public
void
setHealthUrl
(
String
healthUrl
)
{
this
.
healthUrl
=
healthUrl
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
boolean
isPreferIp
()
{
return
preferIp
;
}
public
void
setPreferIp
(
boolean
preferIp
)
{
this
.
preferIp
=
preferIp
;
}
public
Map
<
String
,
String
>
getMetadata
()
{
return
metadata
;
}
public
void
setMetadata
(
Map
<
String
,
String
>
metadata
)
{
this
.
metadata
=
metadata
;
}
public
String
getManagementBaseUrl
()
{
return
managementBaseUrl
;
}
public
void
setManagementBaseUrl
(
String
managementBaseUrl
)
{
this
.
managementBaseUrl
=
managementBaseUrl
;
}
public
String
getServiceBaseUrl
()
{
return
serviceBaseUrl
;
}
public
void
setServiceBaseUrl
(
String
serviceBaseUrl
)
{
this
.
serviceBaseUrl
=
serviceBaseUrl
;
}
}
}
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/client/registration/Application.java
View file @
98629238
/*
/*
* Copyright 2014 the original author or authors.
* Copyright 2014
-2017
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
*
http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
...
@@ -18,7 +18,6 @@ package de.codecentric.boot.admin.client.registration;
...
@@ -18,7 +18,6 @@ package de.codecentric.boot.admin.client.registration;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
/**
/**
...
@@ -26,151 +25,34 @@ import org.springframework.util.Assert;
...
@@ -26,151 +25,34 @@ import org.springframework.util.Assert;
*
*
* @author Johannes Edmeier
* @author Johannes Edmeier
*/
*/
@lombok
.
Data
public
class
Application
{
public
class
Application
{
private
final
String
name
;
private
final
String
name
;
private
final
String
managementUrl
;
private
final
String
managementUrl
;
private
final
String
healthUrl
;
private
final
String
healthUrl
;
private
final
String
serviceUrl
;
private
final
String
serviceUrl
;
private
final
Map
<
String
,
String
>
metadata
;
private
final
Map
<
String
,
String
>
metadata
;
protected
Application
(
Builder
builder
)
{
@lombok
.
Builder
(
builderClassName
=
"Builder"
)
Assert
.
hasText
(
builder
.
name
,
"name must not be empty!"
);
protected
Application
(
String
name
,
Assert
.
hasText
(
builder
.
healthUrl
,
"healthUrl must not be empty!"
);
String
managementUrl
,
this
.
healthUrl
=
builder
.
healthUrl
;
String
healthUrl
,
this
.
managementUrl
=
builder
.
managementUrl
;
String
serviceUrl
,
this
.
serviceUrl
=
builder
.
serviceUrl
;
@lombok
.
Singular
(
"metadata"
)
Map
<
String
,
String
>
metadata
)
{
this
.
name
=
builder
.
name
;
Assert
.
hasText
(
name
,
"name must not be empty!"
);
this
.
metadata
=
Collections
.
unmodifiableMap
(
new
HashMap
<>(
builder
.
metadata
));
Assert
.
hasText
(
healthUrl
,
"healthUrl must not be empty!"
);
}
this
.
name
=
name
;
this
.
managementUrl
=
managementUrl
;
public
static
Builder
create
(
String
name
)
{
this
.
healthUrl
=
healthUrl
;
return
new
Builder
(
name
);
this
.
serviceUrl
=
serviceUrl
;
}
this
.
metadata
=
new
HashMap
<>(
metadata
);
}
public
static
class
Builder
{
private
String
name
;
public
static
Builder
create
(
String
name
)
{
private
String
managementUrl
;
return
Application
.
builder
().
name
(
name
);
private
String
healthUrl
;
}
private
String
serviceUrl
;
private
Map
<
String
,
String
>
metadata
=
new
HashMap
<>();
public
Map
<
String
,
String
>
getMetadata
()
{
return
Collections
.
unmodifiableMap
(
metadata
);
private
Builder
(
String
name
)
{
}
this
.
name
=
name
;
}
public
Builder
withName
(
String
name
)
{
this
.
name
=
name
;
return
this
;
}
public
Builder
withServiceUrl
(
String
serviceUrl
)
{
this
.
serviceUrl
=
serviceUrl
;
return
this
;
}
public
Builder
withHealthUrl
(
String
healthUrl
)
{
this
.
healthUrl
=
healthUrl
;
return
this
;
}
public
Builder
withManagementUrl
(
String
managementUrl
)
{
this
.
managementUrl
=
managementUrl
;
return
this
;
}
public
Builder
withMetadata
(
String
key
,
String
value
)
{
this
.
metadata
.
put
(
key
,
value
);
return
this
;
}
public
Builder
withMetadata
(
Map
<
String
,
String
>
metadata
)
{
this
.
metadata
.
putAll
(
metadata
);
return
this
;
}
public
Application
build
()
{
return
new
Application
(
this
);
}
}
public
String
getName
()
{
return
name
;
}
public
String
getManagementUrl
()
{
return
managementUrl
;
}
public
String
getHealthUrl
()
{
return
healthUrl
;
}
public
String
getServiceUrl
()
{
return
serviceUrl
;
}
public
Map
<
String
,
String
>
getMetadata
()
{
return
metadata
;
}
@Override
public
String
toString
()
{
return
"Application [name="
+
name
+
", managementUrl="
+
managementUrl
+
", healthUrl="
+
healthUrl
+
", serviceUrl="
+
serviceUrl
+
"]"
;
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
healthUrl
==
null
)
?
0
:
healthUrl
.
hashCode
());
result
=
prime
*
result
+
((
managementUrl
==
null
)
?
0
:
managementUrl
.
hashCode
());
result
=
prime
*
result
+
((
name
==
null
)
?
0
:
name
.
hashCode
());
result
=
prime
*
result
+
((
serviceUrl
==
null
)
?
0
:
serviceUrl
.
hashCode
());
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
Application
other
=
(
Application
)
obj
;
if
(
healthUrl
==
null
)
{
if
(
other
.
healthUrl
!=
null
)
{
return
false
;
}
}
else
if
(!
healthUrl
.
equals
(
other
.
healthUrl
))
{
return
false
;
}
if
(
managementUrl
==
null
)
{
if
(
other
.
managementUrl
!=
null
)
{
return
false
;
}
}
else
if
(!
managementUrl
.
equals
(
other
.
managementUrl
))
{
return
false
;
}
if
(
name
==
null
)
{
if
(
other
.
name
!=
null
)
{
return
false
;
}
}
else
if
(!
name
.
equals
(
other
.
name
))
{
return
false
;
}
if
(
serviceUrl
==
null
)
{
if
(
other
.
serviceUrl
!=
null
)
{
return
false
;
}
}
else
if
(!
serviceUrl
.
equals
(
other
.
serviceUrl
))
{
return
false
;
}
return
true
;
}
}
}
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/client/registration/DefaultApplicationFactory.java
View file @
98629238
/*
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
client
.
registration
;
package
de
.
codecentric
.
boot
.
admin
.
client
.
registration
;
import
de.codecentric.boot.admin.client.config.InstanceProperties
;
import
de.codecentric.boot.admin.client.config.InstanceProperties
;
...
@@ -6,6 +22,7 @@ import java.net.InetAddress;
...
@@ -6,6 +22,7 @@ import java.net.InetAddress;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
;
import
org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
...
@@ -46,10 +63,10 @@ public class DefaultApplicationFactory implements ApplicationFactory {
...
@@ -46,10 +63,10 @@ public class DefaultApplicationFactory implements ApplicationFactory {
@Override
@Override
public
Application
createApplication
()
{
public
Application
createApplication
()
{
return
Application
.
create
(
getName
())
return
Application
.
create
(
getName
())
.
withH
ealthUrl
(
getHealthUrl
())
.
h
ealthUrl
(
getHealthUrl
())
.
withM
anagementUrl
(
getManagementUrl
())
.
m
anagementUrl
(
getManagementUrl
())
.
withS
erviceUrl
(
getServiceUrl
())
.
s
erviceUrl
(
getServiceUrl
())
.
withM
etadata
(
getMetadata
())
.
m
etadata
(
getMetadata
())
.
build
();
.
build
();
}
}
...
...
spring-boot-admin-starter-client/src/test/java/de/codecentric/boot/admin/registration/ApplicationRegistratorTest.java
View file @
98629238
/*
/*
* Copyright 2014 the original author or authors.
* Copyright 2014
-2017
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
*
http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
...
@@ -55,9 +55,9 @@ public class ApplicationRegistratorTest {
...
@@ -55,9 +55,9 @@ public class ApplicationRegistratorTest {
ApplicationFactory
factory
=
mock
(
ApplicationFactory
.
class
);
ApplicationFactory
factory
=
mock
(
ApplicationFactory
.
class
);
when
(
factory
.
createApplication
()).
thenReturn
(
Application
.
create
(
"AppName"
)
when
(
factory
.
createApplication
()).
thenReturn
(
Application
.
create
(
"AppName"
)
.
withM
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
m
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
withH
ealthUrl
(
"http://localhost:8080/health"
)
.
h
ealthUrl
(
"http://localhost:8080/health"
)
.
withS
erviceUrl
(
"http://localhost:8080"
)
.
s
erviceUrl
(
"http://localhost:8080"
)
.
build
());
.
build
());
registrator
=
new
ApplicationRegistrator
(
restTemplate
,
client
,
factory
);
registrator
=
new
ApplicationRegistrator
(
restTemplate
,
client
,
factory
);
...
@@ -76,9 +76,9 @@ public class ApplicationRegistratorTest {
...
@@ -76,9 +76,9 @@ public class ApplicationRegistratorTest {
assertThat
(
registrator
.
register
()).
isTrue
();
assertThat
(
registrator
.
register
()).
isTrue
();
Application
applicationRef
=
Application
.
create
(
"AppName"
)
Application
applicationRef
=
Application
.
create
(
"AppName"
)
.
withH
ealthUrl
(
"http://localhost:8080/health"
)
.
h
ealthUrl
(
"http://localhost:8080/health"
)
.
withM
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
m
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
withS
erviceUrl
(
"http://localhost:8080"
)
.
s
erviceUrl
(
"http://localhost:8080"
)
.
build
();
.
build
();
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
...
@@ -127,9 +127,9 @@ public class ApplicationRegistratorTest {
...
@@ -127,9 +127,9 @@ public class ApplicationRegistratorTest {
assertThat
(
registrator
.
register
()).
isTrue
();
assertThat
(
registrator
.
register
()).
isTrue
();
Application
applicationRef
=
Application
.
create
(
"AppName"
)
Application
applicationRef
=
Application
.
create
(
"AppName"
)
.
withH
ealthUrl
(
"http://localhost:8080/health"
)
.
h
ealthUrl
(
"http://localhost:8080/health"
)
.
withM
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
m
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
withS
erviceUrl
(
"http://localhost:8080"
)
.
s
erviceUrl
(
"http://localhost:8080"
)
.
build
();
.
build
();
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
...
@@ -151,9 +151,9 @@ public class ApplicationRegistratorTest {
...
@@ -151,9 +151,9 @@ public class ApplicationRegistratorTest {
assertThat
(
registrator
.
register
()).
isTrue
();
assertThat
(
registrator
.
register
()).
isTrue
();
Application
applicationRef
=
Application
.
create
(
"AppName"
)
Application
applicationRef
=
Application
.
create
(
"AppName"
)
.
withH
ealthUrl
(
"http://localhost:8080/health"
)
.
h
ealthUrl
(
"http://localhost:8080/health"
)
.
withM
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
m
anagementUrl
(
"http://localhost:8080/mgmt"
)
.
withS
erviceUrl
(
"http://localhost:8080"
)
.
s
erviceUrl
(
"http://localhost:8080"
)
.
build
();
.
build
();
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
verify
(
restTemplate
).
postForEntity
(
"http://sba:8080/api/applications"
,
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
new
HttpEntity
<>(
applicationRef
,
headers
),
Map
.
class
);
...
...
spring-boot-admin-starter-client/src/test/java/de/codecentric/boot/admin/registration/ApplicationTest.java
View file @
98629238
/*
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
registration
;
package
de
.
codecentric
.
boot
.
admin
.
registration
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
de.codecentric.boot.admin.client.registration.Application
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
;
import
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.jayway.jsonpath.DocumentContext
;
import
com.jayway.jsonpath.DocumentContext
;
import
com.jayway.jsonpath.JsonPath
;
import
com.jayway.jsonpath.JsonPath
;
import
de.codecentric.boot.admin.client.registration.Application
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
public
class
ApplicationTest
{
public
class
ApplicationTest
{
@Test
@Test
public
void
test_json_format
()
throws
JsonProcessingException
,
IOException
{
public
void
test_json_format
()
throws
IOException
{
ObjectMapper
objectMapper
=
Jackson2ObjectMapperBuilder
.
json
().
build
();
ObjectMapper
objectMapper
=
Jackson2ObjectMapperBuilder
.
json
().
build
();
Application
app
=
Application
.
create
(
"test"
).
withHealthUrl
(
"http://health"
)
Application
app
=
Application
.
create
(
"test"
)
.
withServiceUrl
(
"http://service"
).
withManagementUrl
(
"http://management"
).
build
();
.
healthUrl
(
"http://health"
)
.
serviceUrl
(
"http://service"
)
.
managementUrl
(
"http://management"
)
.
build
();
DocumentContext
json
=
JsonPath
.
parse
(
objectMapper
.
writeValueAsString
(
app
));
DocumentContext
json
=
JsonPath
.
parse
(
objectMapper
.
writeValueAsString
(
app
));
assertThat
((
String
)
json
.
read
(
"$.name"
)).
isEqualTo
(
"test"
);
assertThat
((
String
)
json
.
read
(
"$.name"
)).
isEqualTo
(
"test"
);
assertThat
((
String
)
json
.
read
(
"$.serviceUrl"
)).
isEqualTo
(
"http://service"
);
assertThat
((
String
)
json
.
read
(
"$.serviceUrl"
)).
isEqualTo
(
"http://service"
);
assertThat
((
String
)
json
.
read
(
"$.managementUrl"
)).
isEqualTo
(
"http://management"
);
assertThat
((
String
)
json
.
read
(
"$.managementUrl"
)).
isEqualTo
(
"http://management"
);
assertThat
((
String
)
json
.
read
(
"$.healthUrl"
)).
isEqualTo
(
"http://health"
);
assertThat
((
String
)
json
.
read
(
"$.healthUrl"
)).
isEqualTo
(
"http://health"
);
}
}
@Test
@Test
public
void
test_equals_hashCode
()
{
public
void
test_equals_hashCode
()
{
Application
a1
=
Application
.
create
(
"foo"
).
withHealthUrl
(
"healthUrl"
)
Application
a1
=
Application
.
create
(
"foo"
)
.
withManagementUrl
(
"mgmt"
).
withServiceUrl
(
"svc"
).
build
();
.
healthUrl
(
"healthUrl"
)
Application
a2
=
Application
.
create
(
"foo"
).
withHealthUrl
(
"healthUrl"
)
.
managementUrl
(
"mgmt"
)
.
withManagementUrl
(
"mgmt"
).
withServiceUrl
(
"svc"
).
build
();
.
serviceUrl
(
"svc"
)
.
build
();
Application
a2
=
Application
.
create
(
"foo"
)
.
healthUrl
(
"healthUrl"
)
.
managementUrl
(
"mgmt"
)
.
serviceUrl
(
"svc"
)
.
build
();
assertThat
(
a1
).
isEqualTo
(
a2
);
assertThat
(
a1
).
isEqualTo
(
a2
);
assertThat
(
a1
.
hashCode
()).
isEqualTo
(
a2
.
hashCode
());
assertThat
(
a1
.
hashCode
()).
isEqualTo
(
a2
.
hashCode
());
Application
a3
=
Application
.
create
(
"foo"
).
withHealthUrl
(
"healthUrl2"
)
Application
a3
=
Application
.
create
(
"foo"
)
.
withManagementUrl
(
"mgmt"
).
withServiceUrl
(
"svc"
).
build
();
.
healthUrl
(
"healthUrl2"
)
.
managementUrl
(
"mgmt"
)
.
serviceUrl
(
"svc"
)
.
build
();
assertThat
(
a1
).
isNotEqualTo
(
a3
);
assertThat
(
a1
).
isNotEqualTo
(
a3
);
assertThat
(
a2
).
isNotEqualTo
(
a3
);
assertThat
(
a2
).
isNotEqualTo
(
a3
);
}
}
}
}
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