-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix some deprecations ( 2 ) #2080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| package org.springframework.cloud.kubernetes.client.default_api; | ||
|
|
||
| import java.net.MalformedURLException; | ||
| import java.net.URL; | ||
| import java.net.URI; | ||
| import java.util.Collections; | ||
|
|
||
| import io.kubernetes.client.openapi.ApiClient; | ||
|
|
@@ -53,7 +53,7 @@ void testApiClientUserAgentDefaultHeader() throws MalformedURLException { | |
| assertThat(apiClient).isNotNull(); | ||
| Request.Builder builder = new Request.Builder(); | ||
| apiClient.processHeaderParams(Collections.emptyMap(), builder); | ||
| assertThat(builder.url(new URL("http://example.com")).build().headers().get("User-Agent")) | ||
| assertThat(builder.url(URI.create("http://example.com").toURL()).build().headers().get("User-Agent")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. java-20 deprecated the constructor we are using here |
||
| .isEqualTo("Spring-Cloud-Kubernetes-Application"); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
|
|
||
| import io.kubernetes.client.informer.cache.Cache; | ||
| import io.kubernetes.client.informer.cache.Lister; | ||
| import io.kubernetes.client.openapi.ApiClient; | ||
| import io.kubernetes.client.openapi.apis.CoreV1Api; | ||
| import io.kubernetes.client.openapi.models.CoreV1EndpointPort; | ||
| import io.kubernetes.client.openapi.models.CoreV1EndpointPortBuilder; | ||
|
|
@@ -34,6 +35,7 @@ | |
| import io.kubernetes.client.openapi.models.V1ServicePortBuilder; | ||
| import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder; | ||
| import org.assertj.core.util.Strings; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Mockito; | ||
|
|
@@ -50,14 +52,14 @@ | |
| */ | ||
| class KubernetesClientDiscoveryClientFilterMetadataTest { | ||
|
|
||
| private static final CoreV1Api CORE_V1_API = Mockito.mock(CoreV1Api.class); | ||
|
|
||
| private static final SharedInformerFactoryStub STUB = new SharedInformerFactoryStub(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| private static final SharedInformerStub<V1Service> SERVICE_SHARED_INFORMER_STUB = new SharedInformerStub<>(); | ||
|
|
||
| private static final SharedInformerStub<V1Endpoints> ENDPOINTS_SHARED_INFORMER_STUB = new SharedInformerStub<>(); | ||
|
|
||
| private static CoreV1Api coreV1Api; | ||
|
|
||
| private static SharedInformerFactoryStub sharedInformerFactoryStub; | ||
|
|
||
| private Cache<V1Service> servicesCache; | ||
|
|
||
| private Lister<V1Service> servicesLister; | ||
|
|
@@ -66,6 +68,15 @@ class KubernetesClientDiscoveryClientFilterMetadataTest { | |
|
|
||
| private Lister<V1Endpoints> endpointsLister; | ||
|
|
||
| @BeforeAll | ||
| static void beforeAll() { | ||
| coreV1Api = Mockito.mock(CoreV1Api.class); | ||
| ApiClient apiClient = Mockito.mock(ApiClient.class); | ||
| Mockito.when(coreV1Api.getApiClient()).thenReturn(apiClient); | ||
|
|
||
| sharedInformerFactoryStub = new SharedInformerFactoryStub(apiClient); | ||
| } | ||
|
|
||
| @BeforeEach | ||
| void beforeEach() { | ||
| servicesCache = new Cache<>(); | ||
|
|
@@ -85,8 +96,9 @@ void testAllExtraMetadataDisabled() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "lab"), Map.of("l1", "lab"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -105,8 +117,9 @@ void testLabelsEnabled() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "v1", "l2", "v2"), Map.of("l1", "lab"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -126,8 +139,9 @@ void testLabelsEnabledWithPrefix() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "v1", "l2", "v2"), Map.of("l1", "lab"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -147,8 +161,9 @@ void testAnnotationsEnabled() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "v1"), Map.of("a1", "v1", "a2", "v2"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -168,8 +183,9 @@ void testAnnotationsEnabledWithPrefix() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "v1"), Map.of("a1", "v1", "a2", "v2"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -189,8 +205,9 @@ void testPortsEnabled() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "test", Map.of("l1", "v1"), Map.of("a1", "v1", "a2", "v2"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -210,8 +227,9 @@ void testPortsEnabledWithPrefix() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "v1"), Map.of("a1", "v1", "a2", "v2"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
@@ -231,8 +249,9 @@ void testLabelsAndAnnotationsAndPortsEnabledWithPrefix() { | |
| false, null, Set.of(), Map.of(), null, metadata, 0, true, false, null); | ||
|
|
||
| KubernetesClientInformerDiscoveryClient discoveryClient = new KubernetesClientInformerDiscoveryClient( | ||
| List.of(STUB), List.of(servicesLister), List.of(endpointsLister), List.of(SERVICE_SHARED_INFORMER_STUB), | ||
| List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, CORE_V1_API, x -> true); | ||
| List.of(sharedInformerFactoryStub), List.of(servicesLister), List.of(endpointsLister), | ||
| List.of(SERVICE_SHARED_INFORMER_STUB), List.of(ENDPOINTS_SHARED_INFORMER_STUB), properties, coreV1Api, | ||
| x -> true); | ||
|
|
||
| setup(serviceId, "ns", Map.of("l1", "la1"), Map.of("a1", "an1", "a2", "an2"), Map.of(80, "http", 5555, "")); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to leave this on. I sometimes see a deprecation and don't really know where it comes from