Added checkstyle rules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -22,26 +22,46 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
/**
|
||||
* When both property and consul classes are on the classpath.
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Conditional(ConditionalOnConsulEnabled.OnConsulEnabledCondition.class)
|
||||
public @interface ConditionalOnConsulEnabled {
|
||||
|
||||
/**
|
||||
* Verifies multiple conditions to see if Consul should be enabled.
|
||||
*/
|
||||
class OnConsulEnabledCondition extends AllNestedConditions {
|
||||
|
||||
public OnConsulEnabledCondition() {
|
||||
OnConsulEnabledCondition() {
|
||||
super(ConfigurationPhase.REGISTER_BEAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consul property is enabled.
|
||||
*/
|
||||
@ConditionalOnProperty(value = "spring.cloud.consul.enabled", matchIfMissing = true)
|
||||
static class FoundProperty {}
|
||||
static class FoundProperty {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Consul client class found.
|
||||
*/
|
||||
@ConditionalOnClass(ConsulClient.class)
|
||||
static class FoundClass {}
|
||||
static class FoundClass {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.consul;
|
||||
import com.ecwid.consul.transport.TLSConfig;
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
@@ -33,8 +34,6 @@ import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.retry.interceptor.RetryInterceptorBuilder;
|
||||
import org.springframework.retry.interceptor.RetryOperationsInterceptor;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -61,13 +60,9 @@ public class ConsulAutoConfiguration {
|
||||
|
||||
if (consulProperties.getTls() != null) {
|
||||
ConsulProperties.TLSConfig tls = consulProperties.getTls();
|
||||
TLSConfig tlsConfig = new TLSConfig(
|
||||
tls.getKeyStoreInstanceType(),
|
||||
tls.getCertificatePath(),
|
||||
tls.getCertificatePassword(),
|
||||
tls.getKeyStorePath(),
|
||||
tls.getKeyStorePassword()
|
||||
);
|
||||
TLSConfig tlsConfig = new TLSConfig(tls.getKeyStoreInstanceType(),
|
||||
tls.getCertificatePath(), tls.getCertificatePassword(),
|
||||
tls.getKeyStorePath(), tls.getKeyStorePassword());
|
||||
return new ConsulClient(agentHost, agentPort, tlsConfig);
|
||||
}
|
||||
return new ConsulClient(agentHost, agentPort);
|
||||
@@ -90,6 +85,7 @@ public class ConsulAutoConfiguration {
|
||||
public ConsulHealthIndicator consulHealthIndicator(ConsulClient consulClient) {
|
||||
return new ConsulHealthIndicator(consulClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ConditionalOnClass({ Retryable.class, Aspect.class, AopAutoConfiguration.class })
|
||||
@@ -103,11 +99,12 @@ public class ConsulAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "consulRetryInterceptor")
|
||||
public RetryOperationsInterceptor consulRetryInterceptor(
|
||||
RetryProperties properties) {
|
||||
return RetryInterceptorBuilder
|
||||
.stateless()
|
||||
return RetryInterceptorBuilder.stateless()
|
||||
.backOffOptions(properties.getInitialInterval(),
|
||||
properties.getMultiplier(), properties.getMaxInterval())
|
||||
.maxAttempts(properties.getMaxAttempts()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -47,25 +47,30 @@ public class ConsulEndpoint {
|
||||
public ConsulData invoke() {
|
||||
ConsulData data = new ConsulData();
|
||||
// data.setKeyValues(kvClient.getKeyValueRecurse());
|
||||
Response<Map<String, Service>> agentServices = consul.getAgentServices();
|
||||
Response<Map<String, Service>> agentServices = this.consul.getAgentServices();
|
||||
data.setAgentServices(agentServices.getValue());
|
||||
|
||||
Response<Map<String, List<String>>> catalogServices = consul
|
||||
Response<Map<String, List<String>>> catalogServices = this.consul
|
||||
.getCatalogServices(QueryParams.DEFAULT);
|
||||
|
||||
for (String serviceId : catalogServices.getValue().keySet()) {
|
||||
Response<List<CatalogService>> response = consul.getCatalogService(serviceId,
|
||||
QueryParams.DEFAULT);
|
||||
Response<List<CatalogService>> response = this.consul
|
||||
.getCatalogService(serviceId, QueryParams.DEFAULT);
|
||||
data.getCatalogServices().put(serviceId, response.getValue());
|
||||
}
|
||||
|
||||
Response<List<Node>> catalogNodes = consul.getCatalogNodes(QueryParams.DEFAULT);
|
||||
Response<List<Node>> catalogNodes = this.consul
|
||||
.getCatalogNodes(QueryParams.DEFAULT);
|
||||
data.setCatalogNodes(catalogNodes.getValue());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents Consul data related to catalog entries and agent servies.
|
||||
*/
|
||||
public static class ConsulData {
|
||||
|
||||
Map<String, List<CatalogService>> catalogServices = new LinkedHashMap<>();
|
||||
|
||||
Map<String, Service> agentServices;
|
||||
@@ -79,22 +84,23 @@ public class ConsulEndpoint {
|
||||
return this.catalogServices;
|
||||
}
|
||||
|
||||
public void setCatalogServices(
|
||||
Map<String, List<CatalogService>> catalogServices) {
|
||||
this.catalogServices = catalogServices;
|
||||
}
|
||||
|
||||
public Map<String, Service> getAgentServices() {
|
||||
return this.agentServices;
|
||||
}
|
||||
|
||||
public List<Node> getCatalogNodes() {
|
||||
return this.catalogNodes;
|
||||
}
|
||||
|
||||
public void setCatalogServices(Map<String, List<CatalogService>> catalogServices) {
|
||||
this.catalogServices = catalogServices;
|
||||
}
|
||||
|
||||
public void setAgentServices(Map<String, Service> agentServices) {
|
||||
this.agentServices = agentServices;
|
||||
}
|
||||
|
||||
public List<Node> getCatalogNodes() {
|
||||
return this.catalogNodes;
|
||||
}
|
||||
|
||||
public void setCatalogNodes(List<Node> catalogNodes) {
|
||||
this.catalogNodes = catalogNodes;
|
||||
}
|
||||
@@ -102,10 +108,11 @@ public class ConsulEndpoint {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("catalogServices", catalogServices)
|
||||
.append("agentServices", agentServices)
|
||||
.append("catalogNodes", catalogNodes)
|
||||
.toString();
|
||||
.append("catalogServices", this.catalogServices)
|
||||
.append("agentServices", this.agentServices)
|
||||
.append("catalogNodes", this.catalogNodes).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -19,13 +19,13 @@ package org.springframework.cloud.consul;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@@ -39,10 +39,11 @@ public class ConsulHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
final Response<String> leaderStatus = consul.getStatusLeader();
|
||||
final Response<Map<String, List<String>>> services = consul
|
||||
final Response<String> leaderStatus = this.consul.getStatusLeader();
|
||||
final Response<Map<String, List<String>>> services = this.consul
|
||||
.getCatalogServices(QueryParams.DEFAULT);
|
||||
builder.up().withDetail("leader", leaderStatus.getValue()).withDetail("services",
|
||||
services.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -30,26 +30,29 @@ import org.springframework.validation.annotation.Validated;
|
||||
@ConfigurationProperties("spring.cloud.consul")
|
||||
@Validated
|
||||
public class ConsulProperties {
|
||||
|
||||
/** Consul agent hostname. Defaults to 'localhost'. */
|
||||
@NotNull
|
||||
private String host = "localhost";
|
||||
|
||||
/** Consul agent scheme (HTTP/HTTPS). If there is no scheme in address - client will use HTTP. */
|
||||
/**
|
||||
* Consul agent scheme (HTTP/HTTPS). If there is no scheme in address - client will
|
||||
* use HTTP.
|
||||
*/
|
||||
private String scheme;
|
||||
|
||||
/** Consul agent port. Defaults to '8500'. */
|
||||
@NotNull
|
||||
private int port = 8500;
|
||||
|
||||
/** Is spring cloud consul enabled */
|
||||
/** Is spring cloud consul enabled. */
|
||||
private boolean enabled = true;
|
||||
|
||||
/** configuration for TLS */
|
||||
/** configuration for TLS. */
|
||||
private TLSConfig tls;
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
@@ -57,7 +60,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
@@ -65,7 +68,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
@@ -73,7 +76,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return scheme;
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
public void setScheme(String scheme) {
|
||||
@@ -81,7 +84,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public TLSConfig getTls() {
|
||||
return tls;
|
||||
return this.tls;
|
||||
}
|
||||
|
||||
public void setTls(TLSConfig tls) {
|
||||
@@ -90,26 +93,26 @@ public class ConsulProperties {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConsulProperties{" +
|
||||
"host='" + host + '\'' +
|
||||
", port=" + port +
|
||||
", scheme=" + scheme +
|
||||
", tls=" + tls +
|
||||
", enabled=" + enabled +
|
||||
'}';
|
||||
return "ConsulProperties{" + "host='" + this.host + '\'' + ", port=" + this.port
|
||||
+ ", scheme=" + this.scheme + ", tls=" + this.tls + ", enabled="
|
||||
+ this.enabled + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* TLS configuration.
|
||||
*/
|
||||
public static class TLSConfig {
|
||||
|
||||
/** Type of key framework to use. */
|
||||
private KeyStoreInstanceType keyStoreInstanceType;
|
||||
|
||||
/** Path to an external keystore */
|
||||
/** Path to an external keystore. */
|
||||
private String keyStorePath;
|
||||
|
||||
/** Password to an external keystore */
|
||||
/** Password to an external keystore. */
|
||||
private String keyStorePassword;
|
||||
|
||||
/**File path to the certificate. */
|
||||
/** File path to the certificate. */
|
||||
private String certificatePath;
|
||||
|
||||
/** Password to open the certificate. */
|
||||
@@ -118,7 +121,9 @@ public class ConsulProperties {
|
||||
public TLSConfig() {
|
||||
}
|
||||
|
||||
public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String keyStorePath, String keyStorePassword, String certificatePath, String certificatePassword) {
|
||||
public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String keyStorePath,
|
||||
String keyStorePassword, String certificatePath,
|
||||
String certificatePassword) {
|
||||
this.keyStoreInstanceType = keyStoreInstanceType;
|
||||
this.keyStorePath = keyStorePath;
|
||||
this.keyStorePassword = keyStorePassword;
|
||||
@@ -127,7 +132,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public KeyStoreInstanceType getKeyStoreInstanceType() {
|
||||
return keyStoreInstanceType;
|
||||
return this.keyStoreInstanceType;
|
||||
}
|
||||
|
||||
public void setKeyStoreInstanceType(KeyStoreInstanceType keyStoreInstanceType) {
|
||||
@@ -135,7 +140,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public String getKeyStorePath() {
|
||||
return keyStorePath;
|
||||
return this.keyStorePath;
|
||||
}
|
||||
|
||||
public void setKeyStorePath(String keyStorePath) {
|
||||
@@ -143,7 +148,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public String getKeyStorePassword() {
|
||||
return keyStorePassword;
|
||||
return this.keyStorePassword;
|
||||
}
|
||||
|
||||
public void setKeyStorePassword(String keyStorePassword) {
|
||||
@@ -151,7 +156,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public String getCertificatePath() {
|
||||
return certificatePath;
|
||||
return this.certificatePath;
|
||||
}
|
||||
|
||||
public void setCertificatePath(String certificatePath) {
|
||||
@@ -159,7 +164,7 @@ public class ConsulProperties {
|
||||
}
|
||||
|
||||
public String getCertificatePassword() {
|
||||
return certificatePassword;
|
||||
return this.certificatePassword;
|
||||
}
|
||||
|
||||
public void setCertificatePassword(String certificatePassword) {
|
||||
@@ -169,12 +174,13 @@ public class ConsulProperties {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("keyStoreInstanceType", keyStoreInstanceType)
|
||||
.append("keyStorePath", keyStorePath)
|
||||
.append("keyStorePassword", keyStorePassword)
|
||||
.append("certificatePath", certificatePath)
|
||||
.append("certificatePassword", certificatePassword)
|
||||
.toString();
|
||||
.append("keyStoreInstanceType", this.keyStoreInstanceType)
|
||||
.append("keyStorePath", this.keyStorePath)
|
||||
.append("keyStorePassword", this.keyStorePassword)
|
||||
.append("certificatePath", this.certificatePath)
|
||||
.append("certificatePassword", this.certificatePassword).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -44,41 +44,40 @@ public class RetryProperties {
|
||||
return this.initialInterval;
|
||||
}
|
||||
|
||||
public double getMultiplier() {
|
||||
return this.multiplier;
|
||||
}
|
||||
|
||||
public long getMaxInterval() {
|
||||
return this.maxInterval;
|
||||
}
|
||||
|
||||
public int getMaxAttempts() {
|
||||
return this.maxAttempts;
|
||||
}
|
||||
|
||||
public void setInitialInterval(long initialInterval) {
|
||||
this.initialInterval = initialInterval;
|
||||
}
|
||||
|
||||
public double getMultiplier() {
|
||||
return this.multiplier;
|
||||
}
|
||||
|
||||
public void setMultiplier(double multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
public long getMaxInterval() {
|
||||
return this.maxInterval;
|
||||
}
|
||||
|
||||
public void setMaxInterval(long maxInterval) {
|
||||
this.maxInterval = maxInterval;
|
||||
}
|
||||
|
||||
public int getMaxAttempts() {
|
||||
return this.maxAttempts;
|
||||
}
|
||||
|
||||
public void setMaxAttempts(int maxAttempts) {
|
||||
this.maxAttempts = maxAttempts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("initialInterval", initialInterval)
|
||||
.append("multiplier", multiplier)
|
||||
.append("maxInterval", maxInterval)
|
||||
.append("maxAttempts", maxAttempts)
|
||||
.toString();
|
||||
return new ToStringCreator(this).append("initialInterval", this.initialInterval)
|
||||
.append("multiplier", this.multiplier)
|
||||
.append("maxInterval", this.maxInterval)
|
||||
.append("maxAttempts", this.maxAttempts).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -18,9 +18,30 @@ package org.springframework.cloud.consul.model;
|
||||
|
||||
/**
|
||||
* Gossip pool (serf) statuses. Created by nicu on 10.03.2015.
|
||||
* @author Nicu Marasoiu
|
||||
*/
|
||||
public enum SerfStatusEnum {
|
||||
StatusAlive(1), StatusLeaving(2), StatusLeft(3), StatusFailed(4);
|
||||
|
||||
/**
|
||||
* Alive status.
|
||||
*/
|
||||
StatusAlive(1),
|
||||
|
||||
/**
|
||||
* Leaving status.
|
||||
*/
|
||||
StatusLeaving(2),
|
||||
|
||||
/**
|
||||
* Left status.
|
||||
*/
|
||||
StatusLeft(3),
|
||||
|
||||
/**
|
||||
* Failed status.
|
||||
*/
|
||||
StatusFailed(4);
|
||||
|
||||
private final int code;
|
||||
|
||||
SerfStatusEnum(int code) {
|
||||
@@ -28,7 +49,7 @@ public enum SerfStatusEnum {
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
return this.code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2019 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 org.springframework.cloud.consul;
|
||||
|
||||
import com.ecwid.consul.transport.DefaultHttpsTransport;
|
||||
@@ -18,11 +34,11 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = {"spring.cloud.consul.tls.key-store-instance-type=JKS",
|
||||
@SpringBootTest(properties = { "spring.cloud.consul.tls.key-store-instance-type=JKS",
|
||||
"spring.cloud.consul.tls.key-store-path=src/test/resources/server.jks",
|
||||
"spring.cloud.consul.tls.key-store-password=letmein",
|
||||
"spring.cloud.consul.tls.certificate-path=src/test/resources/trustStore.jks",
|
||||
"spring.cloud.consul.tls.certificate-password=change_me", })
|
||||
"spring.cloud.consul.tls.certificate-password=change_me" })
|
||||
public class ConsulAutoConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -30,13 +46,19 @@ public class ConsulAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void tlsConfigured() {
|
||||
CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils.getField(consulClient, "catalogClient");
|
||||
ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client, "rawClient");
|
||||
HttpTransport httpTransport = (HttpTransport) ReflectionTestUtils.getField(rawClient, "httpTransport");
|
||||
CatalogConsulClient client = (CatalogConsulClient) ReflectionTestUtils
|
||||
.getField(this.consulClient, "catalogClient");
|
||||
ConsulRawClient rawClient = (ConsulRawClient) ReflectionTestUtils.getField(client,
|
||||
"rawClient");
|
||||
HttpTransport httpTransport = (HttpTransport) ReflectionTestUtils
|
||||
.getField(rawClient, "httpTransport");
|
||||
assertThat(httpTransport).isInstanceOf(DefaultHttpsTransport.class);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
protected static class TestConfig {}
|
||||
protected static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
package org.springframework.cloud.consul;
|
||||
/*
|
||||
* Copyright 2013-2019 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.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
package org.springframework.cloud.consul;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||
@@ -12,6 +27,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Lomesh Patel (lomeshpatel)
|
||||
*/
|
||||
@@ -24,12 +41,14 @@ public class ConsulHealthIndicatorDownTest {
|
||||
|
||||
@Test
|
||||
public void doHealthCheck() {
|
||||
assertEquals("health status was not DOWN", Status.DOWN,
|
||||
healthEndpoint.health().getStatus());
|
||||
assertThat(this.healthEndpoint.health().getStatus())
|
||||
.as("health status was not DOWN").isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
protected static class TestConfig {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
package org.springframework.cloud.consul;
|
||||
/*
|
||||
* Copyright 2013-2019 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.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
package org.springframework.cloud.consul;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||
@@ -12,6 +27,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Lomesh Patel (lomeshpatel)
|
||||
*/
|
||||
@@ -24,12 +41,14 @@ public class ConsulHealthIndicatorUpTest {
|
||||
|
||||
@Test
|
||||
public void doHealthCheck() {
|
||||
assertEquals("health status was not UP", Status.UP,
|
||||
healthEndpoint.health().getStatus());
|
||||
assertThat(this.healthEndpoint.health().getStatus())
|
||||
.as("health status was not UP").isEqualTo(Status.UP);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootConfiguration
|
||||
protected static class TestConfig {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user