Merge branch '2.2.x'
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.configuration;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -37,7 +37,7 @@ public class CompatibilityVerifierProperties {
|
||||
* the patch version if you don't want to specify a concrete value. Example:
|
||||
* {@code 3.4.x}
|
||||
*/
|
||||
private List<String> compatibleBootVersions = Collections.singletonList("2.1.x");
|
||||
private List<String> compatibleBootVersions = Arrays.asList("2.2.x", "2.3.x");
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
|
||||
@@ -87,7 +87,8 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Version found in Boot manifest [" + version + "]");
|
||||
}
|
||||
return StringUtils.hasText(version) && version.startsWith(s);
|
||||
return StringUtils.hasText(version)
|
||||
&& version.startsWith(stripWildCardFromVersion(s));
|
||||
}
|
||||
|
||||
String getVersionFromManifest() {
|
||||
@@ -216,7 +217,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
|
||||
else {
|
||||
// 2.0, 2.1
|
||||
CompatibilityPredicate predicate = this.ACCEPTED_VERSIONS
|
||||
.get(acceptedVersionWithoutX(acceptedVersion));
|
||||
.get(stripWildCardFromVersion(acceptedVersion));
|
||||
if (predicate != null && predicate.isCompatible()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Predicate [" + predicate + "] was matched");
|
||||
@@ -228,11 +229,11 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
|
||||
return false;
|
||||
}
|
||||
|
||||
private String acceptedVersionWithoutX(String acceptedVersion) {
|
||||
if (acceptedVersion.endsWith(".x")) {
|
||||
return acceptedVersion.substring(0, acceptedVersion.indexOf(".x"));
|
||||
static String stripWildCardFromVersion(String version) {
|
||||
if (version.endsWith(".x")) {
|
||||
return version.substring(0, version.indexOf(".x"));
|
||||
}
|
||||
return acceptedVersion;
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,17 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootVersion;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.springframework.cloud.configuration.SpringBootVersionVerifier.stripWildCardFromVersion;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -38,11 +42,29 @@ public class CompatibilityVerifierAutoConfigurationTests {
|
||||
@Autowired
|
||||
MyCompatibilityVerifier myMismatchVerifier;
|
||||
|
||||
@Autowired
|
||||
CompatibilityVerifierProperties verifierProperties;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
then(this.myMismatchVerifier.called).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifierPropertiesContainsCurrentBootVersion() {
|
||||
String version = SpringBootVersion.getVersion();
|
||||
assertThat(version).isNotBlank();
|
||||
|
||||
for (String compatibleVersion : verifierProperties.getCompatibleBootVersions()) {
|
||||
if (version.startsWith(stripWildCardFromVersion(compatibleVersion))) {
|
||||
// success we found the current boot version in our list of compatible
|
||||
// versions.
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail(version + " not found in " + verifierProperties.getCompatibleBootVersions());
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableAutoConfiguration
|
||||
static class TestConfiguration {
|
||||
|
||||
@@ -144,7 +144,12 @@ public class SpringBootDependencyTests {
|
||||
|
||||
@Test
|
||||
public void should_match_against_current_manifest() {
|
||||
List<String> acceptedVersions = Collections.singletonList("2.3");
|
||||
verifyCurrentVersionFromManifest("2.3");
|
||||
verifyCurrentVersionFromManifest("2.3.x");
|
||||
}
|
||||
|
||||
private void verifyCurrentVersionFromManifest(String version) {
|
||||
List<String> acceptedVersions = Collections.singletonList(version);
|
||||
SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(
|
||||
acceptedVersions);
|
||||
versionVerifier.ACCEPTED_VERSIONS.clear();
|
||||
|
||||
Reference in New Issue
Block a user