Adds TestConfigServerApplication for use in tests.

This avoids a classpath scanning issue which popped up with boot 2.7+
This commit is contained in:
spencergibb
2022-05-04 18:11:34 -04:00
parent 106a5e5b03
commit c1bff9c27b
22 changed files with 87 additions and 42 deletions

View File

@@ -72,7 +72,7 @@ public class ApplicationBootstrapTests {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
System.setProperty("repo1", repo);
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
// FIXME: configdata why is use legacy needed here and above?
"--spring.config.use-legacy-processing=true", "--server.port=" + configPort,
"--spring.config.name=compositeserver", "--repo1=" + repo);

View File

@@ -61,7 +61,7 @@ public class ApplicationTests {
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo);
/*

View File

@@ -66,7 +66,7 @@ public class ConfigDataCustomMediaTypeIntegrationTests {
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo);

View File

@@ -59,7 +59,7 @@ public class ConfigDataIntegrationTests {
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo);

View File

@@ -60,7 +60,7 @@ public class ConfigDataOrderingIntegrationTests {
@BeforeClass
public static void startConfigServer() {
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--spring.profiles.active=native", "--server.port=" + configPort, "--spring.config.name=server");
System.setProperty("spring.cloud.config.uri", "http://localhost:" + configPort);

View File

@@ -52,7 +52,7 @@ public class ServerNativeApplicationTests {
@BeforeClass
public static void startConfigServer() throws IOException {
String repo = ConfigServerTestUtils.prepareLocalRepo();
server = SpringApplication.run(org.springframework.cloud.config.server.ConfigServerApplication.class,
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo, "--spring.profiles.active=native");
/*

View File

@@ -24,10 +24,12 @@ import org.springframework.context.annotation.Configuration;
* Configuration server application.
*
* @author Dave Syer
* @deprecated Will be removed in 4.0.0.
*/
@Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration
@EnableConfigServer
@Deprecated
public class ConfigServerApplication {
public static void main(String[] args) {

View File

@@ -31,6 +31,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
@@ -42,7 +43,7 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class, properties = { "spring.cloud.bootstrap.enabled=true",
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.cloud.bootstrap.enabled=true",
"logging.level.org.springframework.boot.context.config=TRACE", "spring.cloud.bootstrap.name:enable-bootstrap",
"encrypt.rsa.algorithm=DEFAULT", "encrypt.rsa.strong=false" },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

View File

@@ -21,6 +21,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.cloud.config.server.composite.CompositeUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.cloud.test.ClassPathExclusions;
import org.springframework.cloud.test.ModifiedClassPathRunner;
@@ -34,7 +35,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -54,7 +55,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -73,7 +74,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -93,7 +94,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -113,7 +114,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:///./target/repos/svn-config-repo",
@@ -133,7 +134,7 @@ public class CompositeClasspathTests {
@Test
public void contextLoads() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.jmx.enabled=false",
"spring.config.name:configserver",
"spring.cloud.config.server.composite[0].uri:https://source.developers.google.com",

View File

@@ -27,6 +27,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
@@ -43,7 +44,7 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
public class CompositeIntegrationTests {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class,
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.svn.uri:file:///./target/repos/svn-config-repo",
"spring.cloud.config.server.svn.order:2",
@@ -94,7 +95,7 @@ public class CompositeIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class,
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
"spring.cloud.config.server.composite[0].type:git",

View File

@@ -31,6 +31,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
@@ -42,7 +43,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class, properties = { "spring.config.name:configserver" },
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.config.name:configserver" },
webEnvironment = RANDOM_PORT)
@ActiveProfiles({ "test", "native" })
public class ConfigClientBackwardsCompatibilityIntegrationTests {

View File

@@ -36,6 +36,7 @@ import org.springframework.cloud.config.server.ConfigClientOffIntegrationTests.T
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
import org.springframework.cloud.config.server.resource.ResourceRepository;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -83,7 +84,7 @@ public class ConfigClientOffIntegrationTests {
}
@Configuration(proxyBeanMethods = false)
@Import(ConfigServerApplication.class)
@Import(TestConfigServerApplication.class)
protected static class TestConfiguration {
@Bean

View File

@@ -23,6 +23,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,7 +33,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* @author Alberto C. Ríos
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class,
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.profiles.active:composite", "spring.cloud.config.server.composite[0].type:credhub",
"spring.cloud.config.server.composite[0].url:https://credhub:8844" },
webEnvironment = RANDOM_PORT)

View File

@@ -23,6 +23,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,7 +33,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
* @author Alberto C. Ríos
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class, properties = { "spring.profiles.active:credhub",
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.profiles.active:credhub",
"spring.cloud.config.server.credhub.url:https://credhub:8844" }, webEnvironment = RANDOM_PORT)
public class CredhubConfigServerIntegrationTests extends CredhubIntegrationTest {

View File

@@ -29,6 +29,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -41,7 +42,7 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.prepareLocalRepo;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class, properties = { "spring.config.name:configserver" },
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.config.name:configserver" },
webEnvironment = RANDOM_PORT)
@ActiveProfiles({ "test", "native" })
public class NativeConfigServerIntegrationTests {

View File

@@ -30,6 +30,7 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.environment.SvnKitEnvironmentRepository;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
@@ -47,7 +48,7 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
* @author Roy Clarkson
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class,
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:configserver",
"spring.cloud.config.server.svn.uri:file:///./target/repos/svn-config-repo",
"logging.level.org.springframework.cloud=DEBUG" },

View File

@@ -36,6 +36,7 @@ import org.springframework.cloud.config.server.environment.MultipleJGitEnvironme
import org.springframework.cloud.config.server.ssh.FileBasedSshTransportConfigCallback;
import org.springframework.cloud.config.server.ssh.PropertiesBasedSshTransportConfigCallback;
import org.springframework.cloud.config.server.ssh.SshPropertyValidator;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@@ -53,7 +54,7 @@ public class TransportConfigurationIntegrationTests {
public static class PropertyBasedCallbackTest {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-private-key-block" })
@@ -73,7 +74,7 @@ public class TransportConfigurationIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-private-key-block-list" })
@@ -97,7 +98,7 @@ public class TransportConfigurationIntegrationTests {
public static class PrivateKeyPropertyWithLineBreaks {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-private-key-newline" })
@@ -120,7 +121,7 @@ public class TransportConfigurationIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-private-key-newline-list" })
@@ -147,7 +148,7 @@ public class TransportConfigurationIntegrationTests {
public static class SshPropertiesWithinNestedRepo {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-nested-settings" })
@@ -175,7 +176,7 @@ public class TransportConfigurationIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
"spring.config.name:ssh-nested-settings-list" })
@@ -207,7 +208,7 @@ public class TransportConfigurationIntegrationTests {
public static class FileBasedCallbackTest {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.cloud.config.server.git.uri=git@gitserver.com:team/repo.git",
"spring.cloud.config.server.git.ignoreLocalSshSettings=false" })
@@ -259,7 +260,7 @@ public class TransportConfigurationIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class, SshPropertyValidator.class },
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.cloud.config.server.composite[0].type=git",
"spring.cloud.config.server.composite[0].uri=git@gitserver.com:team/repo.git",

View File

@@ -30,6 +30,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -43,7 +44,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConfigServerApplication.class, properties = { "spring.config.name:configserver",
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.config.name:configserver",
"spring.cloud.config.server.git.uri:file:./target/repos/config-repo" }, webEnvironment = RANDOM_PORT)
@ActiveProfiles("test")
public class VanillaConfigServerIntegrationTests {

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.cloud.config.server.ConfigServerApplication;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class CompositUtilsTests {
@Test
public void getCompositeTypeListWorks() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver",
"spring.jmx.enabled=false",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -51,7 +51,7 @@ public class CompositUtilsTests {
public void getCompositeTypeListFails() {
this.thrown.expect(IllegalStateException.class);
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver",
"spring.jmx.enabled=false",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",

View File

@@ -23,8 +23,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.config.server.ConfigServerApplication;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class EncryptionIntegrationTests {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class },
@SpringBootTest(classes = { TestConfigServerApplication.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.use-legacy-processing=true", "encrypt.key=foobar" })
@ActiveProfiles({ "test", "native" })
@@ -58,7 +58,7 @@ public class EncryptionIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class },
@SpringBootTest(classes = { TestConfigServerApplication.class },
properties = { "spring.config.use-legacy-processing=true",
"spring.cloud.bootstrap.name:symmetric-key-bootstrap" },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -78,7 +78,7 @@ public class EncryptionIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class },
@SpringBootTest(classes = { TestConfigServerApplication.class },
properties = { "spring.config.use-legacy-processing=true",
"spring.cloud.bootstrap.name:keystore-bootstrap" },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -98,7 +98,7 @@ public class EncryptionIntegrationTests {
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ConfigServerApplication.class },
@SpringBootTest(classes = { TestConfigServerApplication.class },
properties = { "spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:keystore-bootstrap",
"spring.cloud.config.server.encrypt.enabled=false", "encrypt.keyStore.alias=myencryptionkey" },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

View File

@@ -26,8 +26,8 @@ import org.junit.Test;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.cloud.config.server.ConfigServerApplication;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.dao.DataAccessException;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,7 +41,7 @@ public class JdbcEnvironmentRepositoryConfigurationTests {
@Test
public void jdbcEnvironmentRepositoryBeansConfiguredWhenDefault() throws IOException {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active=test,jdbc", "spring.main.web-application-type=none")
.run(context -> {
assertThat(context).hasSingleBean(JdbcEnvironmentRepositoryFactory.class);
@@ -52,7 +52,7 @@ public class JdbcEnvironmentRepositoryConfigurationTests {
@Test
public void jdbcEnvironmentRepositoryBeansConfiguredWitCustomResultSetExtractor() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withBean(CustomResultSetExtractor.class, CustomResultSetExtractor::new)
.withPropertyValues("spring.profiles.active=test,jdbc", "spring.main.web-application-type=none")
.run(context -> {
@@ -85,7 +85,7 @@ public class JdbcEnvironmentRepositoryConfigurationTests {
private void getApplicationContextWithJdbcEnabled(boolean jdbcEnabled,
ContextConsumer<? super AssertableWebApplicationContext> consumer) throws IOException {
String uri = ConfigServerTestUtils.prepareLocalRepo();
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class)
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
.withPropertyValues("spring.profiles.active=test,jdbc", "spring.main.web-application-type=none",
"spring.cloud.config.server.git.uri:" + uri,
"spring.cloud.config.server.jdbc.enabled:" + jdbcEnabled)

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2013-2022 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
*
* https://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.config.server.test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.config.server.EnableConfigServer;
@EnableConfigServer
@SpringBootApplication
public class TestConfigServerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(TestConfigServerApplication.class).properties("spring.config.name=configserver")
.run(args);
}
}