Fix test that breaks when run as a suite.

This commit is contained in:
Spencer Gibb
2017-11-29 12:21:02 -05:00
parent b1f54c9590
commit cf1bdf647d
3 changed files with 120 additions and 54 deletions

View File

@@ -1,5 +1,22 @@
/*
* Copyright 2013-2017 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.config.server;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -46,54 +63,55 @@ import org.springframework.cloud.config.server.ssh.SshUriPropertyProcessorTest;
* @author Dave Syer
*/
@RunWith(Suite.class)
@SuiteClasses({ TransportConfigurationIntegrationTests.PropertyBasedCallbackTest.class,
ConfigClientOnIntegrationTests.class,
BootstrapConfigServerIntegrationTests.class,
ResourceControllerIntegrationTests.class,
GenericResourceRepositoryTests.class,
ResourceControllerTests.class,
SubversionConfigServerIntegrationTests.class,
TransportConfigurationIntegrationTests.FileBasedCallbackTest.class,
TransportConfigurationTest.class,
ConfigServerHealthIndicatorTests.class,
CustomCompositeEnvironmentRepositoryTests.class,
CustomEnvironmentRepositoryTests.class,
ConfigClientOffIntegrationTests.class,
AwsCodeCommitCredentialsProviderTests.class,
GitCredentialsProviderFactoryTests.class,
PropertyBasedSshSessionFactoryTest.class,
SshUriPropertyProcessorTest.class,
SshPropertyValidatorTest.class,
NativeConfigServerIntegrationTests.class,
EncryptionIntegrationTests.ConfigSymmetricEncryptionIntegrationTests.class,
EnvironmentPrefixHelperTests.class,
EncryptionControllerTests.class,
CipherEnvironmentEncryptorTests.class,
EncryptionIntegrationTests.KeystoreConfigurationIntegrationTests.class,
KeyStoreTextEncryptorLocatorTests.class,
EncryptionIntegrationTests.BootstrapConfigSymmetricEncryptionIntegrationTests.class,
EncryptionControllerMultiTextEncryptorTests.class,
CompositeConfigServerIntegrationTests.class,
VanillaConfigServerIntegrationTests.class,
VaultEnvironmentRepositoryTests.class,
MultipleJGitEnvironmentLabelPlaceholderRepositoryTests.class,
EnvironmentControllerTests.class,
JGitEnvironmentRepositoryIntegrationTests.class,
CompositeEnvironmentRepositoryTests.class,
MultipleJGitEnvironmentApplicationPlaceholderRepositoryTests.class,
EnvironmentControllerIntegrationTests.class,
JGitEnvironmentRepositoryTests.class,
EnvironmentEncryptorEnvironmentRepositoryTests.class,
JdbcEnvironmentRepositoryTests.class,
SVNKitEnvironmentRepositoryTests.class,
MultipleJGitEnvironmentRepositoryTests.class,
NativeEnvironmentRepositoryTests.class,
JGitEnvironmentRepositoryConcurrencyTests.class,
SVNKitEnvironmentRepositoryIntegrationTests.class,
MultipleJGitEnvironmentRepositoryIntegrationTests.class,
MultipleJGitEnvironmentProfilePlaceholderRepositoryTests.class
})
// @Ignore
@SuiteClasses({ NativeConfigServerIntegrationTests.class,
GenericResourceRepositoryTests.class,
ResourceControllerTests.class,
ResourceControllerIntegrationTests.class,
ConfigClientOnIntegrationTests.class,
ConfigServerApplicationTests.class,
VanillaConfigServerIntegrationTests.class,
EnvironmentControllerIntegrationTests.class,
MultipleJGitEnvironmentRepositoryIntegrationTests.class,
EnvironmentEncryptorEnvironmentRepositoryTests.class,
EnvironmentControllerTests.class,
SVNKitEnvironmentRepositoryIntegrationTests.class,
MultipleJGitEnvironmentApplicationPlaceholderRepositoryTests.class,
JdbcEnvironmentRepositoryTests.class,
CompositeEnvironmentRepositoryTests.class,
JGitEnvironmentRepositoryConcurrencyTests.class,
NativeEnvironmentRepositoryTests.class,
JGitEnvironmentRepositoryTests.class,
SVNKitEnvironmentRepositoryTests.class,
VaultEnvironmentRepositoryTests.class,
MultipleJGitEnvironmentRepositoryTests.class,
JGitEnvironmentRepositoryIntegrationTests.class,
MultipleJGitEnvironmentProfilePlaceholderRepositoryTests.class,
MultipleJGitEnvironmentLabelPlaceholderRepositoryTests.class,
GitCredentialsProviderFactoryTests.class,
AwsCodeCommitCredentialsProviderTests.class,
TransportConfigurationIntegrationTests.FileBasedCallbackTest.class,
ConfigClientOffIntegrationTests.class,
TransportConfigurationIntegrationTests.PropertyBasedCallbackTest.class,
EncryptionControllerMultiTextEncryptorTests.class,
CipherEnvironmentEncryptorTests.class,
EncryptionIntegrationTests.BootstrapConfigSymmetricEncryptionIntegrationTests.class,
EncryptionControllerTests.class,
EncryptionIntegrationTests.ConfigSymmetricEncryptionIntegrationTests.class,
EncryptionIntegrationTests.KeystoreConfigurationIntegrationTests.class,
KeyStoreTextEncryptorLocatorTests.class,
EnvironmentPrefixHelperTests.class,
SshUriPropertyProcessorTest.class,
PropertyBasedSshSessionFactoryTest.class,
SshPropertyValidatorTest.class,
CompositeConfigServerIntegrationTests.class,
SubversionConfigServerIntegrationTests.class,
ConfigServerHealthIndicatorTests.class,
CustomCompositeEnvironmentRepositoryTests.class,
CustomEnvironmentRepositoryTests.class,
TransportConfigurationTest.class,
BootstrapConfigServerIntegrationTests.class,
})
@Ignore
public class AdhocTestSuite {
}

View File

@@ -1,13 +1,29 @@
/*
* Copyright 2013-2017 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.config.server;
import java.io.IOException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -21,11 +37,13 @@ import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
@@ -35,8 +53,11 @@ import static org.mockito.Matchers.anyString;
@SpringBootTest(classes = TestConfiguration.class, properties = "spring.cloud.config.enabled:true",
webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@DirtiesContext
public class ConfigClientOnIntegrationTests {
private static String localRepo = null;
@LocalServerPort
private int port;
@@ -45,7 +66,12 @@ public class ConfigClientOnIntegrationTests {
@BeforeClass
public static void init() throws IOException {
ConfigServerTestUtils.prepareLocalRepo();
localRepo = ConfigServerTestUtils.prepareLocalRepo();
}
@AfterClass
public static void after() throws IOException {
ConfigServerTestUtils.deleteLocalRepo(localRepo);
}
@Test
@@ -62,7 +88,8 @@ public class ConfigClientOnIntegrationTests {
}
@Configuration
@Import(ConfigServerApplication.class)
@EnableAutoConfiguration
@EnableConfigServer
protected static class TestConfiguration {
@Bean

View File

@@ -1,5 +1,22 @@
/*
* Copyright 2013-2017 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.config.server;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -11,10 +28,14 @@ import org.springframework.context.ConfigurableApplicationContext;
@ClassPathExclusions("h2-*.jar")
public class ConfigServerApplicationTests {
static {
TomcatURLStreamHandlerFactory.disable();
}
@Test
public void contextLoads() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(ConfigServerApplication.class)
.properties("spring.config.name=configserver").run()) {
.properties("spring.config.name=configserver").run("--server.port=0")) {
}
}