Merge branch '2.0.x'

This commit is contained in:
Spencer Gibb
2018-11-19 12:28:26 -05:00
2 changed files with 19 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ public class ConsulDiscoveryProperties {
private boolean enabled = true;
/** Tags to use when registering management service */
private List<String> managementTags = Arrays.asList(MANAGEMENT);
private List<String> managementTags = new ArrayList<>();
/** Alternate server path to invoke for health checking */
private String healthCheckPath = "/actuator/health";
@@ -175,9 +175,12 @@ public class ConsulDiscoveryProperties {
private int order = 0;
@SuppressWarnings("unused")
private ConsulDiscoveryProperties() {}
private ConsulDiscoveryProperties() {
this.managementTags.add(MANAGEMENT);
}
public ConsulDiscoveryProperties(InetUtils inetUtils) {
this();
this.hostInfo = inetUtils.findFirstNonLoopbackHostInfo();
this.ipAddress = this.hostInfo.getIpAddress();
this.hostname = this.hostInfo.getHostname();

View File

@@ -1,13 +1,15 @@
package org.springframework.cloud.consul.discovery;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.commons.util.InetUtilsProperties;
import java.util.Collections;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.commons.util.InetUtilsProperties;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -56,4 +58,11 @@ public class ConsulDiscoveryPropertiesTests {
public void testGetDcReturnsMapValueWhenInMap() {
assertEquals(MAP_DC, properties.getDatacenters().get(SERVICE_NAME_IN_MAP));
}
@Test
public void testAddManagementTag() {
properties.getManagementTags().add("newTag");
assertThat(properties.getManagementTags())
.containsOnly(ConsulDiscoveryProperties.MANAGEMENT, "newTag");
}
}