Skip to content

Commit e5149f0

Browse files
committed
Fix deprecation warnings
1 parent 4c089ed commit e5149f0

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ protected Mono<InstanceId> registerInstance(ServiceInstance instance) {
146146

147147
protected String toString(ServiceInstance instance) {
148148
String httpScheme = instance.isSecure() ? "https" : "http";
149-
return String.format(
150-
"serviceId=%s, url= %s://%s:%d",
151-
instance.getServiceId(),
149+
return String.format("serviceId=%s, instanceId=%s, url= %s://%s:%d",
150+
instance.getServiceId(), instance.getInstanceId(),
152151
instance.getScheme() != null ? instance.getScheme() : httpScheme,
153152
instance.getHost(),
154153
instance.getPort()

spring-boot-admin-server-cloud/src/test/java/de/codecentric/boot/admin/server/cloud/discovery/DefaultServiceInstanceConverterTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ public class DefaultServiceInstanceConverterTest {
3030

3131
@Test
3232
public void test_convert_with_defaults() {
33-
ServiceInstance service = new DefaultServiceInstance("test", "localhost", 80, false);
33+
ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
3434
Registration registration = new DefaultServiceInstanceConverter().convert(service);
3535

3636
assertThat(registration.getName()).isEqualTo("test");
@@ -45,7 +45,7 @@ public void test_convert_with_custom_defaults() {
4545
converter.setHealthEndpointPath("ping");
4646
converter.setManagementContextPath("mgmt");
4747

48-
ServiceInstance service = new DefaultServiceInstance("test", "localhost", 80, false);
48+
ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
4949
Registration registration = converter.convert(service);
5050

5151
assertThat(registration.getName()).isEqualTo("test");
@@ -56,7 +56,7 @@ public void test_convert_with_custom_defaults() {
5656

5757
@Test
5858
public void test_convert_with_metadata() {
59-
ServiceInstance service = new DefaultServiceInstance("test", "localhost", 80, false);
59+
ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
6060
Map<String, String> metadata = new HashMap<>();
6161
metadata.put("health.path", "ping");
6262
metadata.put("management.context-path", "mgmt");

spring-boot-admin-server-cloud/src/test/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListenerTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public void setup() {
6464
@Test
6565
public void should_discover_instances_when_application_is_ready() {
6666
when(discovery.getServices()).thenReturn(Collections.singletonList("service"));
67-
when(discovery.getInstances("service")).thenReturn(Collections.singletonList(new DefaultServiceInstance("service",
67+
when(discovery.getInstances("service")).thenReturn(Collections.singletonList(new DefaultServiceInstance("test-1",
68+
"service",
6869
"localhost",
6970
80,
7071
false
@@ -81,7 +82,7 @@ public void should_discover_instances_when_application_is_ready() {
8182
@Test
8283
public void should_not_register_instance_when_serviceId_is_ignored() {
8384
when(discovery.getServices()).thenReturn(singletonList("service"));
84-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
85+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
8586
"localhost",
8687
80,
8788
false
@@ -96,7 +97,7 @@ public void should_not_register_instance_when_serviceId_is_ignored() {
9697
@Test
9798
public void should_register_instance_when_serviceId_is_not_ignored() {
9899
when(discovery.getServices()).thenReturn(singletonList("service"));
99-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
100+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
100101
"localhost",
101102
80,
102103
false
@@ -111,7 +112,7 @@ public void should_register_instance_when_serviceId_is_not_ignored() {
111112
@Test
112113
public void should_not_register_instance_when_serviceId_matches_ignored_pattern() {
113114
when(discovery.getServices()).thenReturn(asList("service", "rabbit-1", "rabbit-2"));
114-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
115+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
115116
"localhost",
116117
80,
117118
false
@@ -128,7 +129,7 @@ public void should_not_register_instance_when_serviceId_matches_ignored_pattern(
128129
@Test
129130
public void should_register_instances_when_serviceId_matches_wanted_pattern() {
130131
when(discovery.getServices()).thenReturn(asList("service", "rabbit-1", "rabbit-2"));
131-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
132+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
132133
"localhost",
133134
80,
134135
false
@@ -145,12 +146,13 @@ public void should_register_instances_when_serviceId_matches_wanted_pattern() {
145146
@Test
146147
public void should_register_instances_when_serviceId_matches_wanted_pattern_and_igonred_pattern() {
147148
when(discovery.getServices()).thenReturn(asList("service-1", "service", "rabbit-1", "rabbit-2"));
148-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
149+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
149150
"localhost",
150151
80,
151152
false
152153
)));
153-
when(discovery.getInstances("service-1")).thenReturn(singletonList(new DefaultServiceInstance("service-1",
154+
when(discovery.getInstances("service-1")).thenReturn(singletonList(new DefaultServiceInstance("test-1",
155+
"service-1",
154156
"localhost",
155157
80,
156158
false
@@ -168,7 +170,7 @@ public void should_register_instances_when_serviceId_matches_wanted_pattern_and_
168170
@Test
169171
public void should_register_instance_when_new_service_instance_is_discovered() {
170172
when(discovery.getServices()).thenReturn(singletonList("service"));
171-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
173+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
172174
"localhost",
173175
80,
174176
false
@@ -191,7 +193,7 @@ public void should_only_discover_new_instances_when_new_heartbeat_is_emitted() {
191193
listener.onParentHeartbeat(new ParentHeartbeatEvent(new Object(), heartbeat));
192194

193195
when(discovery.getServices()).thenReturn(singletonList("service"));
194-
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("service",
196+
when(discovery.getInstances("service")).thenReturn(singletonList(new DefaultServiceInstance("test-1", "service",
195197
"localhost",
196198
80,
197199
false
@@ -217,8 +219,8 @@ public void should_remove_instances_when_they_are_no_longer_available_in_discove
217219
listener.setIgnoredServices(singleton("ignored"));
218220

219221
List<ServiceInstance> instances = new ArrayList<>();
220-
instances.add(new DefaultServiceInstance("service", "localhost", 80, false));
221-
instances.add(new DefaultServiceInstance("service", "example.net", 80, false));
222+
instances.add(new DefaultServiceInstance("test-1", "service", "localhost", 80, false));
223+
instances.add(new DefaultServiceInstance("test-1", "service", "example.net", 80, false));
222224

223225
when(discovery.getServices()).thenReturn(singletonList("service"));
224226
when(discovery.getInstances("service")).thenReturn(instances);
@@ -264,11 +266,11 @@ public void should_remove_instances_when_they_are_no_longer_available_in_discove
264266
@Test
265267
public void should_not_throw_error_when_conversion_fails_and_proceed_with_next_instance() {
266268
when(discovery.getServices()).thenReturn(singletonList("service"));
267-
when(discovery.getInstances("service")).thenReturn(asList(new DefaultServiceInstance("service",
269+
when(discovery.getInstances("service")).thenReturn(asList(new DefaultServiceInstance("test-1", "service",
268270
"localhost",
269271
80,
270272
false
271-
), new DefaultServiceInstance("error", "localhost", 80, false)));
273+
), new DefaultServiceInstance("error-1", "error", "localhost", 80, false)));
272274
listener.setConverter(instance -> {
273275
if (instance.getServiceId().equals("error")) {
274276
throw new IllegalStateException("Test-Error");

0 commit comments

Comments
 (0)