|
1 | 1 | /* |
2 | | - * Copyright 2013-2021 the original author or authors. |
| 2 | + * Copyright 2013-2024 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -package org.springframework.cloud.kubernetes.configserver; |
| 17 | +package org.springframework.cloud.kubernetes.configserver.it; |
18 | 18 |
|
19 | | -import com.github.tomakehurst.wiremock.WireMockServer; |
20 | 19 | import com.github.tomakehurst.wiremock.client.WireMock; |
21 | 20 | import io.kubernetes.client.util.ClientBuilder; |
22 | | -import org.junit.jupiter.api.AfterAll; |
23 | 21 | import org.junit.jupiter.api.AfterEach; |
24 | | -import org.junit.jupiter.api.BeforeAll; |
| 22 | +import org.junit.jupiter.api.BeforeEach; |
25 | 23 | import org.mockito.MockedStatic; |
26 | 24 |
|
27 | 25 | import org.springframework.boot.test.context.SpringBootTest; |
28 | 26 | import org.springframework.cloud.kubernetes.client.KubernetesClientUtils; |
| 27 | +import org.springframework.cloud.kubernetes.configserver.KubernetesConfigServerApplication; |
| 28 | +import org.springframework.cloud.kubernetes.configserver.TestBootstrapConfig; |
29 | 29 |
|
30 | | -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; |
31 | 30 | import static org.mockito.Mockito.mockStatic; |
32 | 31 |
|
33 | 32 | /** |
|
36 | 35 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, |
37 | 36 | properties = { "spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.client.namespace=default", |
38 | 37 | "spring.profiles.include=kubernetes", "spring.cloud.kubernetes.secrets.enableApi=true" }, |
39 | | - classes = { KubernetesConfigServerApplication.class }) |
40 | | -public class ConfigDataConfigServerIntegrationTest extends ConfigServerIntegrationTest { |
| 38 | + classes = { KubernetesConfigServerApplication.class, TestBootstrapConfig.class }) |
| 39 | +class ConfigDataConfigServerIntegrationTest extends ConfigServerIntegrationTest { |
41 | 40 |
|
42 | | - private static WireMockServer wireMockServer; |
43 | | - |
44 | | - private static MockedStatic<KubernetesClientUtils> clientUtilsMock; |
45 | | - |
46 | | - @BeforeAll |
47 | | - static void setup() { |
48 | | - wireMockServer = new WireMockServer(options().dynamicPort()); |
49 | | - wireMockServer.start(); |
50 | | - WireMock.configureFor(wireMockServer.port()); |
| 41 | + private MockedStatic<KubernetesClientUtils> clientUtilsMock; |
51 | 42 |
|
| 43 | + @BeforeEach |
| 44 | + void setup() { |
52 | 45 | clientUtilsMock = mockStatic(KubernetesClientUtils.class); |
53 | 46 | clientUtilsMock.when(KubernetesClientUtils::kubernetesApiClient) |
54 | 47 | .thenReturn(new ClientBuilder().setBasePath(wireMockServer.baseUrl()).build()); |
55 | 48 | } |
56 | 49 |
|
57 | | - @AfterAll |
58 | | - static void teardown() { |
59 | | - wireMockServer.stop(); |
| 50 | + @AfterEach |
| 51 | + void teardown() { |
60 | 52 | clientUtilsMock.close(); |
61 | 53 | } |
62 | 54 |
|
|
0 commit comments