|
| 1 | +/* |
| 2 | + * Copyright 2013-2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.cloud.kubernetes.configserver; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | + |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; |
| 22 | +import org.springframework.boot.test.context.SpringBootTest; |
| 23 | +import org.springframework.cloud.config.server.environment.JGitEnvironmentRepository; |
| 24 | +import org.springframework.context.ConfigurableApplicationContext; |
| 25 | + |
| 26 | +import static org.assertj.core.api.Assertions.assertThat; |
| 27 | + |
| 28 | +/** |
| 29 | + * @author Arjav Dongaonkar |
| 30 | + */ |
| 31 | +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, |
| 32 | + classes = { KubernetesConfigServerApplication.class }, |
| 33 | + properties = { "spring.main.cloud-platform=KUBERNETES", "spring.profiles.include=kubernetes", |
| 34 | + "spring.cloud.kubernetes.client.namespace=default", "spring.profiles.active=composite", |
| 35 | + "spring.cloud.config.server.composite[0].type=git", |
| 36 | + "spring.cloud.config.server.composite[0].uri=https://github.com/spring-cloud-samples/config-repo", |
| 37 | + "spring.cloud.config.server.composite[1].type=kubernetes", |
| 38 | + "spring.cloud.config.server.composite[1].config-map-namespace=default", |
| 39 | + "spring.cloud.config.server.composite[1].secrets-namespace=default" }) |
| 40 | +class CompositeProfileWithGitAndKubernetesConfigSourcesTests { |
| 41 | + |
| 42 | + @Autowired |
| 43 | + private ConfigurableApplicationContext context; |
| 44 | + |
| 45 | + @Test |
| 46 | + void runTest() { |
| 47 | + assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepository.class)).hasSize(2); |
| 48 | + assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepositoryFactory.class)).hasSize(1); |
| 49 | + assertThat(context.getBeanNamesForType(KubernetesPropertySourceSupplier.class)).isNotEmpty(); |
| 50 | + assertThat(context.getBeanNamesForType(JGitEnvironmentRepository.class)).hasSize(1); |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments