diff --git a/kubernetes-client-api/pom.xml b/kubernetes-client-api/pom.xml index d58310eb902..fc404f59308 100644 --- a/kubernetes-client-api/pom.xml +++ b/kubernetes-client-api/pom.xml @@ -123,7 +123,7 @@ io.fabric8 kubernetes-model-node - + org.slf4j slf4j-api @@ -144,7 +144,7 @@ com.fasterxml.jackson.core jackson-core - + org.bouncycastle bcprov-ext-jdk15on @@ -190,6 +190,11 @@ junit-jupiter-migrationsupport test + + org.junit.jupiter + junit-jupiter-params + test + org.slf4j slf4j-simple diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java index aa9be6ed278..54d8f00319e 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java @@ -29,7 +29,7 @@ */ public interface Indexer extends Store { /** - * Retrieve list of obejcts that match on the named indexing function. + * Retrieve list of objects that match on the named indexing function. * * @param indexName specific indexing function * @param obj object diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java index 1fb38c8d18d..a2e58fa6751 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java @@ -23,11 +23,11 @@ * @param the object type */ public class Lister { - private String namespace; + private final String namespace; - private String indexName; + private final String indexName; - private Indexer indexer; + private final Indexer indexer; public Lister(Indexer indexer) { this(indexer, null, Cache.NAMESPACE_INDEX); diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java index 1fcf3e62b1e..dc715cbde25 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java @@ -23,15 +23,15 @@ import java.net.URL; public class URLUtils { - + public static class URLBuilder { - - private StringBuilder url; - + + private final StringBuilder url; + public URLBuilder(String url) { this.url = new StringBuilder(url); } - + public URLBuilder(URL url) { this(url.toString()); } @@ -53,14 +53,14 @@ public URL build() { throw new IllegalArgumentException(e.getMessage(), e); } } - + @Override public String toString() { return build().toString(); } - + } - + private URLUtils() { throw new IllegalStateException("Utility class"); } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/MockHttpClientUtils.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/MockHttpClientUtils.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/MockHttpClientUtils.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/MockHttpClientUtils.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java similarity index 95% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java index 6c10802dd60..9609a440e97 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilderTest.java @@ -15,7 +15,6 @@ */ package io.fabric8.kubernetes.client.extended.leaderelection; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.ConfigMapLock; import org.junit.jupiter.api.BeforeEach; @@ -30,12 +29,12 @@ class LeaderElectorBuilderTest { - private DefaultKubernetesClient mockKubernetesClient; + private NamespacedKubernetesClient mockKubernetesClient; private LeaderElectionConfigBuilder defaultConfigBuilder; @BeforeEach void setUp() { - mockKubernetesClient = mock(DefaultKubernetesClient.class, Answers.RETURNS_DEEP_STUBS); + mockKubernetesClient = mock(NamespacedKubernetesClient.class, Answers.RETURNS_DEEP_STUBS); defaultConfigBuilder = new LeaderElectionConfigBuilder() .withName("Valid Leader Election configuration") .withLeaseDuration(Duration.ofSeconds(15L)) diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java similarity index 93% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java index 2843226f779..d8bc057b527 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorTest.java @@ -15,7 +15,7 @@ */ package io.fabric8.kubernetes.client.extended.leaderelection; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.LeaderElectionRecord; import io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.Lock; import io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.LockException; @@ -68,7 +68,7 @@ void runShouldAbortAfterRenewDeadlineExpired() throws Exception { }).when(mockedLock).update(any(), any()); // When executor.submit(() -> { - new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).run(); + new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).run(); signal.countDown(); }); signal.await(10, TimeUnit.SECONDS); @@ -96,7 +96,7 @@ void runShouldEndlesslyRun() throws Exception { return null; }).when(mockedLock).update(any(), any()); // When - executor.submit(() -> new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).run()); + executor.submit(() -> new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).run()); signal.await(10, TimeUnit.SECONDS); // Then assertEquals(0, signal.getCount()); @@ -118,7 +118,7 @@ void isLeaderAndIsLeaderShouldReturnTrue() { final LeaderElectionRecord ler = mock(LeaderElectionRecord.class); when(ler.getHolderIdentity()).thenReturn("1337"); // When - final boolean result = new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).isLeader(ler); + final boolean result = new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).isLeader(ler); // Then assertTrue(result); } @@ -131,7 +131,7 @@ void isLeaderAndIsNotLeaderShouldReturnFalse() { final LeaderElectionRecord ler = mock(LeaderElectionRecord.class); when(ler.getHolderIdentity()).thenReturn("1337"); // When - final boolean result = new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).isLeader(ler); + final boolean result = new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).isLeader(ler); // Then assertFalse(result); } @@ -144,7 +144,7 @@ void canBecomeLeaderAndDifferentLeaderWithExpiredLockShouldReturnTrue() { final LeaderElectionRecord ler = mock(LeaderElectionRecord.class); when(ler.getRenewTime()).thenReturn(ZonedDateTime.now(ZoneOffset.UTC).minusHours(1)); // When - final boolean result = new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).canBecomeLeader(ler); + final boolean result = new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).canBecomeLeader(ler); // Then assertTrue(result); } @@ -157,7 +157,7 @@ void canBecomeLeaderAndDifferentLeaderWithActiveLockShouldReturnFalse() { final LeaderElectionRecord ler = mock(LeaderElectionRecord.class); when(ler.getRenewTime()).thenReturn(ZonedDateTime.now(ZoneOffset.UTC)); // When - final boolean result = new LeaderElector<>(mock(DefaultKubernetesClient.class), lec).canBecomeLeader(ler); + final boolean result = new LeaderElector<>(mock(NamespacedKubernetesClient.class), lec).canBecomeLeader(ler); // Then assertFalse(result); } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java similarity index 91% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java index 0d8a0ac57eb..97dad60f80a 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLockTest.java @@ -19,7 +19,7 @@ import io.fabric8.kubernetes.api.model.ConfigMapBuilder; import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.ReplaceDeletable; import io.fabric8.kubernetes.client.dsl.Resource; @@ -28,6 +28,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.mockito.Answers; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; import java.time.Duration; import java.time.ZoneId; @@ -41,6 +43,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -48,17 +51,17 @@ class ConfigMapLockTest { - private DefaultKubernetesClient kc; + private NamespacedKubernetesClient kc; private MixedOperation> configMaps; private ConfigMapBuilder configMapBuilder; private ConfigMapBuilder.MetadataNested metadata; @BeforeEach void setUp() { - kc = mock(DefaultKubernetesClient.class, Answers.RETURNS_DEEP_STUBS); - configMaps = mock(MixedOperation.class, Answers.RETURNS_DEEP_STUBS); - configMapBuilder = mock(ConfigMapBuilder.class, Answers.RETURNS_DEEP_STUBS); - metadata = mock(ConfigMapBuilder.MetadataNested.class, Answers.RETURNS_DEEP_STUBS); + kc = mock(NamespacedKubernetesClient.class, RETURNS_DEEP_STUBS); + configMaps = mock(MixedOperation.class, RETURNS_DEEP_STUBS); + configMapBuilder = Mockito.mock(ConfigMapBuilder.class, RETURNS_DEEP_STUBS); + metadata = mock(ConfigMapBuilder.MetadataNested.class, RETURNS_DEEP_STUBS); when(kc.inNamespace(anyString()).configMaps()).thenReturn(configMaps); when(configMapBuilder.editOrNewMetadata()).thenReturn(metadata); } @@ -99,7 +102,7 @@ void missingIdentityShouldThrowException() { void getWithExistingConfigMapShouldReturnLeaderElectionRecord() { // Given final ConfigMap cm = new ConfigMap(); - when(configMaps.withName(eq("name")).get()).thenReturn(cm); + when(configMaps.withName(ArgumentMatchers.eq("name")).get()).thenReturn(cm); cm.setMetadata(new ObjectMetaBuilder() .withAnnotations( Collections.singletonMap("control-plane.alpha.kubernetes.io/leader", diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java similarity index 92% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java index e1258234bd4..1748eb8228d 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLockTest.java @@ -20,7 +20,7 @@ import io.fabric8.kubernetes.api.model.coordination.v1.LeaseBuilder; import io.fabric8.kubernetes.api.model.coordination.v1.LeaseList; import io.fabric8.kubernetes.api.model.coordination.v1.LeaseSpec; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.NamespacedKubernetesClient; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.ReplaceDeletable; import io.fabric8.kubernetes.client.dsl.Resource; @@ -39,6 +39,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -46,7 +47,7 @@ class LeaseLockTest { - private DefaultKubernetesClient kc; + private NamespacedKubernetesClient kc; private MixedOperation> leases; private LeaseBuilder leaserBuilder; private LeaseBuilder.MetadataNested metadata; @@ -54,11 +55,11 @@ class LeaseLockTest { @BeforeEach void setUp() { - kc = mock(DefaultKubernetesClient.class, Answers.RETURNS_DEEP_STUBS); - leases = mock(MixedOperation.class, Answers.RETURNS_DEEP_STUBS); - leaserBuilder = mock(LeaseBuilder.class, Answers.RETURNS_DEEP_STUBS); - metadata = mock(LeaseBuilder.MetadataNested.class, Answers.RETURNS_DEEP_STUBS); - spec = mock(LeaseBuilder.SpecNested.class, Answers.RETURNS_DEEP_STUBS); + kc = mock(NamespacedKubernetesClient.class, RETURNS_DEEP_STUBS); + leases = mock(MixedOperation.class, RETURNS_DEEP_STUBS); + leaserBuilder = mock(LeaseBuilder.class, RETURNS_DEEP_STUBS); + metadata = mock(LeaseBuilder.MetadataNested.class, RETURNS_DEEP_STUBS); + spec = mock(LeaseBuilder.SpecNested.class, RETURNS_DEEP_STUBS); when(kc.inNamespace(anyString()).leases()).thenReturn(leases); when(leaserBuilder.withNewMetadata()).thenReturn(metadata); when(leaserBuilder.withNewSpec()).thenReturn(spec); diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java new file mode 100644 index 00000000000..b8a44f5c99d --- /dev/null +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * 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 io.fabric8.kubernetes.client.informers.cache; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ListerTest { + + @Test + void testListerWithEmptyIndex() { + final Lister namespacedPodLister = new Lister<>(new MapIndexer<>(), "default"); + assertTrue(namespacedPodLister.list().isEmpty()); + } + + @Test + void testListerWithIndexValues() { + // Given + final MapIndexer indexer = new MapIndexer<>(); + indexer.put("default", "key1", 1); + indexer.put("other", "key2", 1); + indexer.put("other", "key3", 1); + // When + final Lister result = new Lister<>(indexer, "default"); + // Then + assertEquals(1, result.list().size()); + } + + @Test + void testListerWithIndexValuesInOther() { + // Given + final MapIndexer indexer = new MapIndexer<>(); + indexer.put("default", "key1", 1); + indexer.put("other", "key2", 1); + indexer.put("other", "key3", 1); + // When + final Lister result = new Lister<>(indexer, "default"); + // Then + assertEquals(2, result.namespace("other").list().size()); + } + +} diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/MapIndexer.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/MapIndexer.java new file mode 100644 index 00000000000..48840f926ac --- /dev/null +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/informers/cache/MapIndexer.java @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * 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 io.fabric8.kubernetes.client.informers.cache; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class MapIndexer implements Indexer { + private final Map> map; + + public MapIndexer() { + this.map = new HashMap<>(); + } + + @Override + public List index(String indexName, T obj) { + return null; + } + + @Override + public List indexKeys(String indexName, String indexKey) { + return null; + } + + @Override + public List byIndex(String indexName, String indexKey) { + return new ArrayList<>(map.getOrDefault(indexKey, new HashMap<>()).values()); + } + + @Override + public Map>> getIndexers() { + return null; + } + + @Override + public void addIndexers(Map>> indexers) { + + } + + @Override + public List list() { + return map.values().stream().flatMap(m -> m.values().stream()).collect(Collectors.toList()); + } + + @Override + public List listKeys() { + return map.values().stream().flatMap(m -> m.keySet().stream()).collect(Collectors.toList()); + } + + @Override + public T get(T object) { + return object; + } + + @Override + public T getByKey(String key) { + for (Map m : map.values()) { + if (m.containsKey(key)) { + return m.get(key); + } + } + return null; + } + + protected void put(String index, String key, T object) { + map.compute(index, (k, v) -> v == null ? new HashMap<>() : v).put(key, object); + } +} diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java similarity index 89% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java index ccf33572875..801c3a6aa36 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java @@ -15,14 +15,10 @@ */ package io.fabric8.kubernetes.client.internal; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; -import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.utils.IOHelpers; import io.fabric8.kubernetes.client.utils.Utils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; @@ -72,18 +68,6 @@ public void resetSystemPropertiesBack() { System.setProperties(systemProperties); } - @Disabled - @Test - void testLoadingDodgyKubeConfig() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, InvalidKeySpecException { - System.setProperty("kubeconfig", "/tmp/ceposta.kubeconfig"); - KubernetesClient client = new DefaultKubernetesClient(); - Config config = client.getConfiguration(); - KeyStore ts = CertUtils.createTrustStore(config.getCaCertData(), null, null, "changeit"); - KeyStore ks = - CertUtils.createKeyStore(config.getClientCertData(), null, config.getClientKeyData(), null, "RSA", "changeit", null, - "changeit"); - } - @Test void testLoadingMultipleCertsFromSameFile() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { KeyStore ts = CertUtils.createTrustStore( diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/KubeConfigUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/KubeConfigUtilsTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/KubeConfigUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/KubeConfigUtilsTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/KubernetesResourceUtilTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/KubernetesResourceUtilTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/KubernetesResourceUtilTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/KubernetesResourceUtilTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/UtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/UtilsTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/UtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/UtilsTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ApiVersionUtilTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ApiVersionUtilTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ApiVersionUtilTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ApiVersionUtilTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadSchedulerTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadSchedulerTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadSchedulerTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadSchedulerTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/HttpClientUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/HttpClientUtilsTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/HttpClientUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/HttpClientUtilsTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java similarity index 95% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java index 5ec46ffadf2..3d9901c8d90 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java @@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class IpAddressMatcherTest { +class IpAddressMatcherTest { @Test - public void testIpRangeMatcher() { + void testIpRangeMatcher() { assertTrue(new IpAddressMatcher("192.168.10.110").matches("192.168.10.110")); assertTrue(new IpAddressMatcher("192.168.1.0/8").matches("192.168.10.110")); assertTrue(new IpAddressMatcher("192.168.1.0/24").matches("192.168.1.100")); @@ -39,7 +39,7 @@ public void testIpRangeMatcher() { } @Test - public void testIpAddressRegexp() { + void testIpAddressRegexp() { try { Pattern pattern = Pattern.compile(HttpClientUtils.ipv4Pattern, Pattern.CASE_INSENSITIVE); Matcher matcherPlain = pattern.matcher("192.168.0.1"); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java similarity index 78% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java index 4b9937eaec4..6c764ffff64 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactoryTest.java @@ -28,10 +28,10 @@ import static io.fabric8.kubernetes.client.utils.KubernetesVersionFactory.NonKubernetesVersion; import static io.fabric8.kubernetes.client.utils.KubernetesVersionFactory.Version; -public class KubernetesVersionFactoryTest { +class KubernetesVersionFactoryTest { @Test - public void create_should_create_kubernetes_version() { + void create_should_create_kubernetes_version() { // given KubernetesVersionFactory.Version version = KubernetesVersionFactory.create("v42beta1"); // when @@ -40,7 +40,7 @@ public void create_should_create_kubernetes_version() { } @Test - public void create_should_create_non_kubernetes_version() { + void create_should_create_non_kubernetes_version() { // given Version version = KubernetesVersionFactory.create("darthVader"); // when @@ -49,7 +49,7 @@ public void create_should_create_non_kubernetes_version() { } @Test - public void create_should_create_nonkubernetes_version_when_version_has_illegal_qualifier() { + void create_should_create_nonkubernetes_version_when_version_has_illegal_qualifier() { // given Version version = NonKubernetesVersion.FACTORY.create("v1gamma"); // when @@ -59,7 +59,7 @@ public void create_should_create_nonkubernetes_version_when_version_has_illegal_ } @Test - public void create_should_create_nonkubernetes_version_when_version_is_missing_major() { + void create_should_create_nonkubernetes_version_when_version_is_missing_major() { // given Version version = KubernetesVersionFactory.create("vbeta"); // when @@ -69,7 +69,7 @@ public void create_should_create_nonkubernetes_version_when_version_is_missing_m } @Test - public void isKubernetes_should_return_true_for_kubernetes_version() { + void isKubernetes_should_return_true_for_kubernetes_version() { // given Version version = KubernetesVersion.FACTORY.create("v84"); // when @@ -79,7 +79,7 @@ public void isKubernetes_should_return_true_for_kubernetes_version() { } @Test - public void isKubernetes_should_return_false_for_non_kubernetes_version() { + void isKubernetes_should_return_false_for_non_kubernetes_version() { // given Version version = NonKubernetesVersion.FACTORY.create("darthVader"); // when @@ -89,7 +89,7 @@ public void isKubernetes_should_return_false_for_non_kubernetes_version() { } @Test - public void FactoryCreate_should_create_kubernetes_version_when_version_is_kubernetes_version() { + void FactoryCreate_should_create_kubernetes_version_when_version_is_kubernetes_version() { // given Version version = KubernetesVersionFactory.create("v10beta42"); // when @@ -99,7 +99,7 @@ public void FactoryCreate_should_create_kubernetes_version_when_version_is_kuber } @Test - public void isStable_should_report_stable_when_there_is_no_qualifier() { + void isStable_should_report_stable_when_there_is_no_qualifier() { // given KubernetesVersion version = KubernetesVersion.FACTORY.create("v1"); // when @@ -109,7 +109,7 @@ public void isStable_should_report_stable_when_there_is_no_qualifier() { } @Test - public void isStable_should_report_unstable_when_there_is_a_qualifier() { + void isStable_should_report_unstable_when_there_is_a_qualifier() { // given KubernetesVersion version = KubernetesVersion.FACTORY.create("v42alpha"); // when @@ -119,7 +119,7 @@ public void isStable_should_report_unstable_when_there_is_a_qualifier() { } @Test - public void getMajor_should_return_major() { + void getMajor_should_return_major() { // given Integer majorInteger = 1; KubernetesVersion version = KubernetesVersion.FACTORY.create("v" + majorInteger + "beta42"); @@ -130,7 +130,7 @@ public void getMajor_should_return_major() { } @Test - public void getQualifier_should_return_qualifier() { + void getQualifier_should_return_qualifier() { // given String beta = "beta"; KubernetesVersion version = KubernetesVersion.FACTORY.create("v422" + beta + "442"); @@ -141,7 +141,7 @@ public void getQualifier_should_return_qualifier() { } @Test - public void getQualifier_should_return_empty_optional_qualifier_when_there_is_no_qualifier() { + void getQualifier_should_return_empty_optional_qualifier_when_there_is_no_qualifier() { // given KubernetesVersion version = KubernetesVersion.FACTORY.create("v422"); // when @@ -151,7 +151,7 @@ public void getQualifier_should_return_empty_optional_qualifier_when_there_is_no } @Test - public void getMinor_should_return_minor() { + void getMinor_should_return_minor() { // given Integer minorInteger = 42; KubernetesVersion version = KubernetesVersion.FACTORY.create("v1alpha" + minorInteger); @@ -162,7 +162,7 @@ public void getMinor_should_return_minor() { } @Test - public void getMinor_should_return_empty_optional_when_there_is_no_minor() { + void getMinor_should_return_empty_optional_when_there_is_no_minor() { // given KubernetesVersion version = KubernetesVersion.FACTORY.create("v1alpha"); // when @@ -172,7 +172,7 @@ public void getMinor_should_return_empty_optional_when_there_is_no_minor() { } @Test - public void toString_kubernetesVersion_should_return_original_version_for_GA_version() { + void toString_kubernetesVersion_should_return_original_version_for_GA_version() { // given String versionString = "v42"; KubernetesVersion version = KubernetesVersion.FACTORY.create(versionString); @@ -183,7 +183,7 @@ public void toString_kubernetesVersion_should_return_original_version_for_GA_ver } @Test - public void toString_kubernetesVersion_should_return_original_version_for_unstable_version() { + void toString_kubernetesVersion_should_return_original_version_for_unstable_version() { // given String versionString = "v42beta42"; KubernetesVersion version = KubernetesVersion.FACTORY.create(versionString); @@ -194,7 +194,7 @@ public void toString_kubernetesVersion_should_return_original_version_for_unstab } @Test - public void compareTo_kubernetesVersion_should_be_greater_than_nonKubernetesVersion() { + void compareTo_kubernetesVersion_should_be_greater_than_nonKubernetesVersion() { // given Version kVersion = KubernetesVersion.FACTORY.create("v42beta42"); Version nkVersion = NonKubernetesVersion.FACTORY.create("lukeSkywalker"); @@ -204,7 +204,7 @@ public void compareTo_kubernetesVersion_should_be_greater_than_nonKubernetesVers } @Test - public void compareTo_nonKubernetesVersion_should_be_less_than_kubernetesVersion() { + void compareTo_nonKubernetesVersion_should_be_less_than_kubernetesVersion() { // given Version kVersion = KubernetesVersion.FACTORY.create("v42beta42"); Version nkVersion = NonKubernetesVersion.FACTORY.create("lukeSkywalker"); @@ -214,7 +214,7 @@ public void compareTo_nonKubernetesVersion_should_be_less_than_kubernetesVersion } @Test - public void compareTo_same_major_version_should_be_same_as_other_major() { + void compareTo_same_major_version_should_be_same_as_other_major() { // given Version version42_1 = KubernetesVersion.FACTORY.create("v42"); Version version42_2 = KubernetesVersion.FACTORY.create("v42"); @@ -225,7 +225,7 @@ public void compareTo_same_major_version_should_be_same_as_other_major() { } @Test - public void compareTo_kubernetesVersion_with_greater_major_version_should_be_greater_than_smaller_major_version() { + void compareTo_kubernetesVersion_with_greater_major_version_should_be_greater_than_smaller_major_version() { // given Version version42 = KubernetesVersion.FACTORY.create("v42"); Version version84 = KubernetesVersion.FACTORY.create("v84"); @@ -235,7 +235,7 @@ public void compareTo_kubernetesVersion_with_greater_major_version_should_be_gre } @Test - public void compareTo_kubernetesVersion_with_smaller_major_should_be_less_than_greater_major() { + void compareTo_kubernetesVersion_with_smaller_major_should_be_less_than_greater_major() { // given Version version42 = KubernetesVersion.FACTORY.create("v42"); Version version84 = KubernetesVersion.FACTORY.create("v84"); @@ -245,7 +245,7 @@ public void compareTo_kubernetesVersion_with_smaller_major_should_be_less_than_g } @Test - public void compareTo_kubernetesVersion_with_alpha_qualifier_should_be_less_than_beta_qualifier() { + void compareTo_kubernetesVersion_with_alpha_qualifier_should_be_less_than_beta_qualifier() { // given Version alpha = KubernetesVersion.FACTORY.create("v42alpha"); Version beta = KubernetesVersion.FACTORY.create("v42beta"); @@ -255,7 +255,7 @@ public void compareTo_kubernetesVersion_with_alpha_qualifier_should_be_less_than } @Test - public void compareTo_kubernetesVersion_with_beta_qualifier_should_be_greater_than_alpha_qualifier() { + void compareTo_kubernetesVersion_with_beta_qualifier_should_be_greater_than_alpha_qualifier() { // given Version alpha = KubernetesVersion.FACTORY.create("v42alpha"); Version beta = KubernetesVersion.FACTORY.create("v42beta"); @@ -265,7 +265,7 @@ public void compareTo_kubernetesVersion_with_beta_qualifier_should_be_greater_th } @Test - public void compareTo_GA_kubernetesVersion_should_be_greater_than_beta_qualifier() { + void compareTo_GA_kubernetesVersion_should_be_greater_than_beta_qualifier() { // given Version ga = KubernetesVersion.FACTORY.create("v42"); Version beta = KubernetesVersion.FACTORY.create("v42beta"); @@ -275,7 +275,7 @@ public void compareTo_GA_kubernetesVersion_should_be_greater_than_beta_qualifier } @Test - public void compareTo_kubernetesVersion_same_qualifier_should_be_same_as_other_qualifier() { + void compareTo_kubernetesVersion_same_qualifier_should_be_same_as_other_qualifier() { // given Version beta1 = KubernetesVersion.FACTORY.create("v42beta"); Version beta2 = KubernetesVersion.FACTORY.create("v42beta"); @@ -286,7 +286,7 @@ public void compareTo_kubernetesVersion_same_qualifier_should_be_same_as_other_q } @Test - public void compareTo_beta_kubernetesVersion_should_be_less_than_GA() { + void compareTo_beta_kubernetesVersion_should_be_less_than_GA() { // given Version ga = KubernetesVersion.FACTORY.create("v42"); Version beta = KubernetesVersion.FACTORY.create("v42beta"); @@ -296,7 +296,7 @@ public void compareTo_beta_kubernetesVersion_should_be_less_than_GA() { } @Test - public void compareTo_kubernetesVersion_greater_minor_should_be_greater_than_smaller_minor() { + void compareTo_kubernetesVersion_greater_minor_should_be_greater_than_smaller_minor() { // given Version minor42 = KubernetesVersion.FACTORY.create("v42alpha42"); Version minor84 = KubernetesVersion.FACTORY.create("v42alpha84"); @@ -306,7 +306,7 @@ public void compareTo_kubernetesVersion_greater_minor_should_be_greater_than_sma } @Test - public void compareTo_kubernetesVersion_smaller_minor_should_be_smaller_than_greater_minor() { + void compareTo_kubernetesVersion_smaller_minor_should_be_smaller_than_greater_minor() { // given Version minor42 = KubernetesVersion.FACTORY.create("v42beta42"); Version minor84 = KubernetesVersion.FACTORY.create("v42beta84"); @@ -316,7 +316,7 @@ public void compareTo_kubernetesVersion_smaller_minor_should_be_smaller_than_gre } @Test - public void compareTo_kubernetesVersion_minor_should_be_same_as_other_minor() { + void compareTo_kubernetesVersion_minor_should_be_same_as_other_minor() { // given Version minor42_1 = KubernetesVersion.FACTORY.create("v42alpha42"); Version minor42_2 = KubernetesVersion.FACTORY.create("v42alpha42"); @@ -327,7 +327,7 @@ public void compareTo_kubernetesVersion_minor_should_be_same_as_other_minor() { } @Test - public void compareTo_kubernetesVersion_without_minor_should_be_less_than_version_with_minor() { + void compareTo_kubernetesVersion_without_minor_should_be_less_than_version_with_minor() { // given Version noMinor = KubernetesVersion.FACTORY.create("v42alpha"); Version minor42 = KubernetesVersion.FACTORY.create("v42alpha42"); @@ -337,7 +337,7 @@ public void compareTo_kubernetesVersion_without_minor_should_be_less_than_versio } @Test - public void compareTo_kubernetesVersion_with_minor_should_be_greater_than_version_without_minor() { + void compareTo_kubernetesVersion_with_minor_should_be_greater_than_version_without_minor() { // given Version noMinor = KubernetesVersion.FACTORY.create("v42alpha"); Version minor42 = KubernetesVersion.FACTORY.create("v42alpha42"); @@ -347,7 +347,7 @@ public void compareTo_kubernetesVersion_with_minor_should_be_greater_than_versio } @Test - public void compareTo_nonKubernetesVersion_should_be_same_as_other_with_same_version() { + void compareTo_nonKubernetesVersion_should_be_same_as_other_with_same_version() { // given Version skywalker1_1 = NonKubernetesVersion.FACTORY.create("skywalker1"); Version skywalker1_2 = NonKubernetesVersion.FACTORY.create("skywalker1"); @@ -358,7 +358,7 @@ public void compareTo_nonKubernetesVersion_should_be_same_as_other_with_same_ver } @Test - public void compareTo_nonKubernetesVersion_with_minor_should_be_less_than_version_without_minor() { + void compareTo_nonKubernetesVersion_with_minor_should_be_less_than_version_without_minor() { // given Version skywalker = NonKubernetesVersion.FACTORY.create("skywalker"); Version skywalker1 = NonKubernetesVersion.FACTORY.create("skywalker1"); @@ -368,7 +368,7 @@ public void compareTo_nonKubernetesVersion_with_minor_should_be_less_than_versio } @Test - public void compareTo_nonKubernetesVersion_with_greater_minor_should_be_less_than_version_with_smaller_minor() { + void compareTo_nonKubernetesVersion_with_greater_minor_should_be_less_than_version_with_smaller_minor() { // given Version skywalker1 = NonKubernetesVersion.FACTORY.create("skywalker1"); Version skywalker10 = NonKubernetesVersion.FACTORY.create("skywalker10"); @@ -378,7 +378,7 @@ public void compareTo_nonKubernetesVersion_with_greater_minor_should_be_less_tha } @Test - public void compareTo_nonKubernetesVersion_with_smaller_minor_should_be_less_than_version_with_greater_minor() { + void compareTo_nonKubernetesVersion_with_smaller_minor_should_be_less_than_version_with_greater_minor() { // given Version skywalker1 = NonKubernetesVersion.FACTORY.create("skywalker1"); Version skywalker10 = NonKubernetesVersion.FACTORY.create("skywalker10"); @@ -388,7 +388,7 @@ public void compareTo_nonKubernetesVersion_with_smaller_minor_should_be_less_tha } @Test - public void compareTo_nonKubernetesVersion_alphabetically_lower_char_should_be_greater() { + void compareTo_nonKubernetesVersion_alphabetically_lower_char_should_be_greater() { // given Version a = NonKubernetesVersion.FACTORY.create("a"); Version b = NonKubernetesVersion.FACTORY.create("b"); @@ -398,7 +398,7 @@ public void compareTo_nonKubernetesVersion_alphabetically_lower_char_should_be_g } @Test - public void should_sort_spec_example_correctly() { + void should_sort_spec_example_correctly() { // given Version v10 = KubernetesVersionFactory.create("v10"); Version v2 = KubernetesVersionFactory.create("v2"); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriorityTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriorityTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriorityTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriorityTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtilsTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtilsTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodMockUtils.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/PodMockUtils.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodMockUtils.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/PodMockUtils.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodStatusUtilTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/PodStatusUtilTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodStatusUtilTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/PodStatusUtilTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java similarity index 91% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java index 0640b006517..1725570454f 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ReflectUtilsTest.java @@ -24,7 +24,7 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.ObjectMeta; -public class ReflectUtilsTest { +class ReflectUtilsTest { static class Foo { private ObjectMeta metadata; @@ -39,7 +39,6 @@ public ObjectMeta getMetadata() { static class Bar extends Foo { } - @SuppressWarnings("serial") static abstract class AbstractBaz implements HasMetadata { private ObjectMeta metadata; private String apiVersion; @@ -60,10 +59,9 @@ public void setApiVersion(String version) { public String getApiVersion() { return this.apiVersion; } - + } - @SuppressWarnings("serial") static class Baz extends AbstractBaz { @Override public String getKind() { @@ -72,7 +70,7 @@ public String getKind() { } @Test - public void testDirectReflection () throws ReflectiveOperationException { + void testDirectReflection () throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Foo foo = new Foo(); foo.setMetadata(meta); @@ -80,7 +78,7 @@ public void testDirectReflection () throws ReflectiveOperationException { } @Test - public void testDerivedReflection () throws ReflectiveOperationException { + void testDerivedReflection () throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Foo bar = new Bar(); bar.setMetadata(meta); @@ -88,7 +86,7 @@ public void testDerivedReflection () throws ReflectiveOperationException { } @Test - public void testInstanceOf() throws ReflectiveOperationException { + void testInstanceOf() throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Baz baz = new Baz(); baz.setMetadata(meta); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java similarity index 97% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java index 3c0ac03dbd5..4457c0aa3e1 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/ResourceCompareTest.java @@ -25,8 +25,6 @@ import io.fabric8.kubernetes.api.model.KubernetesListBuilder; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; -import io.fabric8.kubernetes.api.model.PodList; -import io.fabric8.kubernetes.api.model.PodListBuilder; import io.fabric8.kubernetes.api.model.ReplicationController; import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; import io.fabric8.kubernetes.api.model.Service; @@ -37,7 +35,7 @@ import java.util.Collections; import java.util.List; -public class ResourceCompareTest { +class ResourceCompareTest { private Pod pod; private Service service; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationAdditionalPropertiesTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationAdditionalPropertiesTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationAdditionalPropertiesTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationAdditionalPropertiesTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationSingleDocumentUnmarshalTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationSingleDocumentUnmarshalTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationSingleDocumentUnmarshalTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationSingleDocumentUnmarshalTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java similarity index 97% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java index 5bf5f9ac84a..46a7a629b54 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationTest.java @@ -55,7 +55,7 @@ class SerializationTest { @Test void unmarshalCRDWithSchema() throws Exception { // Given - final String input = readYamlToString("/test-crd-schema.yml"); + final String input = readYamlToString("/serialization/test-crd-schema.yml"); final CustomResourceDefinition crd = Serialization.unmarshal(input, CustomResourceDefinition.class); // When JSONSchemaProps spec = crd.getSpec() @@ -75,7 +75,7 @@ void unmarshalCRDWithSchema() throws Exception { @Test void asYamlWithDeserializedCRD() throws Exception { // Given - final String input = readYamlToString("/test-crd-schema.yml"); + final String input = readYamlToString("/serialization/test-crd-schema.yml"); final CustomResourceDefinition crd = Serialization.unmarshal(input, CustomResourceDefinition.class); // When final String result = Serialization.asYaml(crd); @@ -87,7 +87,7 @@ void asYamlWithDeserializedCRD() throws Exception { @DisplayName("unmarshal, String containing List with windows like line-ends (CRLF), all list items should be available") void unmarshalListWithWindowsLineSeparatorsString() throws Exception { // Given - final String crlfFile = readYamlToString("/test-list.yml"); + final String crlfFile = readYamlToString("/serialization/test-list.yml"); // When final KubernetesResource result = Serialization.unmarshal(crlfFile, KubernetesResource.class); // Then @@ -154,7 +154,7 @@ void containsMultipleDocumentsWithSingleDocumentAndLinuxLineEnds() { @Test void testSerializeYamlWithAlias() { // Given - InputStream fileInputStream = getClass().getResourceAsStream("/test-pod-manifest-with-aliases.yml"); + InputStream fileInputStream = getClass().getResourceAsStream("/serialization/test-pod-manifest-with-aliases.yml"); // When Pod pod = Serialization.unmarshal(fileInputStream); // Then @@ -311,11 +311,11 @@ void nullValueShouldNotBeOutput() { .doesNotContain("status") .contains("spec: \"foo\""); } - + @Test void quantityQuoting() { Quantity quantity = Serialization.unmarshal("amount: \"2\"\nformat: \"Gi\"", Quantity.class); assertThat(Serialization.asYaml(quantity)).isEqualTo("--- \"2Gi\"\n"); } - + } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationYamlTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationYamlTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/SerializationYamlTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/SerializationYamlTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java similarity index 94% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java index ce6a059d7d5..d591d23f9fd 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptorTest.java @@ -38,14 +38,14 @@ /** * Ignoring for now - the token refresh should be based upon the java 11 client or the provided client library and not okhttp */ -public class TokenRefreshInterceptorTest { +class TokenRefreshInterceptorTest { @Test - public void shouldAutoconfigureAfter401() throws IOException { + void shouldAutoconfigureAfter401() throws IOException { try { // Prepare kubeconfig for autoconfiguration File tempFile = Files.createTempFile("test", "kubeconfig").toFile(); - Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/test-kubeconfig-tokeninterceptor")), Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING); + Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/token-refresh-interceptor/kubeconfig")), Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING); System.setProperty(KUBERNETES_KUBECONFIG_FILE, tempFile.getAbsolutePath()); HttpRequest.Builder builder = Mockito.mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); @@ -94,7 +94,7 @@ void shouldRefreshOIDCToken() throws IOException { try { // Prepare kubeconfig for autoconfiguration File tempFile = Files.createTempFile("test", "kubeconfig").toFile(); - Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/test-kubeconfig-oidc")), + Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/token-refresh-interceptor/kubeconfig-oidc")), Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING); System.setProperty(KUBERNETES_KUBECONFIG_FILE, tempFile.getAbsolutePath()); @@ -110,7 +110,7 @@ void shouldRefreshOIDCToken() throws IOException { // - id-token to set to "renewed". Since the original id-token at autoconfigure // had different value, we can be used the new value to assert/observe that // 401 Unauthorized triggers renewal when OIDC auth provider is used. - Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/test-kubeconfig-tokeninterceptor-oidc")), + Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/token-refresh-interceptor/kubeconfig-oidc")), Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING); TokenRefreshInterceptor interceptor = new TokenRefreshInterceptor(config, Mockito.mock(HttpClient.Factory.class)); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java similarity index 88% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java index b25186e52c7..15844e7f3c9 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/URLUtilsTest.java @@ -20,11 +20,11 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -public class URLUtilsTest { +class URLUtilsTest { @Test - public void shouldJoinUrlWithoutQueryParams() { + void shouldJoinUrlWithoutQueryParams() { // Given String masterUrl = "https://oso-master-url:8888/kubernetes"; @@ -38,7 +38,7 @@ public void shouldJoinUrlWithoutQueryParams() { } @Test - public void shouldAppendUrlWithQueryParams() { + void shouldAppendUrlWithQueryParams() { // Given String masterUrl = "https://oso-master-url:8888/kubernetes?param1=value"; @@ -51,7 +51,7 @@ public void shouldAppendUrlWithQueryParams() { } @Test - public void shouldAppendUrlWithMultipleQueryParams() { + void shouldAppendUrlWithMultipleQueryParams() { // Given String masterUrl = "https://oso-master-url:8888/kubernetes?param1=value"; @@ -64,7 +64,7 @@ public void shouldAppendUrlWithMultipleQueryParams() { } @Test - public void shouldJoinUrlWithQueryParams() { + void shouldJoinUrlWithQueryParams() { // Given String masterUrl = "https://oso-master-url:8888/kubernetes?key=value"; @@ -78,7 +78,7 @@ public void shouldJoinUrlWithQueryParams() { } @Test - public void shouldJoinNoneUrl() { + void shouldJoinNoneUrl() { // Given String masterUrl = "images.openshift.io"; diff --git a/kubernetes-client-api/src/test/resources/serialization/custom-resource.yml b/kubernetes-client-api/src/test/resources/serialization/custom-resource.yml new file mode 100644 index 00000000000..e2c6ae6117b --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/custom-resource.yml @@ -0,0 +1,24 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +apiVersion: the-cr.example.com/v1 +kind: SomeCustomResource +metadata: + name: custom-resource-example +spec: + field: value +status: + reconciled: true diff --git a/kubernetes-client-api/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml b/kubernetes-client-api/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml new file mode 100644 index 00000000000..92a8d2c0231 --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml @@ -0,0 +1,34 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +--- +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + tier: backend + role: master +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis + tier: backend + role: master +--- diff --git a/kubernetes-client-api/src/test/resources/serialization/document-with-leading-document-delimiter.yml b/kubernetes-client-api/src/test/resources/serialization/document-with-leading-document-delimiter.yml new file mode 100644 index 00000000000..917387afacd --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/document-with-leading-document-delimiter.yml @@ -0,0 +1,33 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +--- +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + tier: backend + role: master +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis + tier: backend + role: master diff --git a/kubernetes-client-api/src/test/resources/serialization/document-with-no-document-delimiter.yml b/kubernetes-client-api/src/test/resources/serialization/document-with-no-document-delimiter.yml new file mode 100644 index 00000000000..bd212a4ac71 --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/document-with-no-document-delimiter.yml @@ -0,0 +1,32 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + tier: backend + role: master +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis + tier: backend + role: master diff --git a/kubernetes-client-api/src/test/resources/serialization/document-with-trailing-document-delimiter.yml b/kubernetes-client-api/src/test/resources/serialization/document-with-trailing-document-delimiter.yml new file mode 100644 index 00000000000..df39819de7c --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/document-with-trailing-document-delimiter.yml @@ -0,0 +1,33 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + tier: backend + role: master +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis + tier: backend + role: master +--- diff --git a/kubernetes-client-api/src/test/resources/serialization/invalid-resource.yml b/kubernetes-client-api/src/test/resources/serialization/invalid-resource.yml new file mode 100644 index 00000000000..d0e490e0d85 --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/invalid-resource.yml @@ -0,0 +1,17 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +not-a: resource diff --git a/kubernetes-client-api/src/test/resources/serialization/invalid-yaml.yml b/kubernetes-client-api/src/test/resources/serialization/invalid-yaml.yml new file mode 100644 index 00000000000..ed3119d90fc --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/invalid-yaml.yml @@ -0,0 +1,21 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +This + +is not + +YAML diff --git a/kubernetes-client-api/src/test/resources/serialization/kubernetes-list.yml b/kubernetes-client-api/src/test/resources/serialization/kubernetes-list.yml new file mode 100644 index 00000000000..9d9c39b766a --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/kubernetes-list.yml @@ -0,0 +1,37 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +--- +apiVersion: v1 +kind: List +items: + - apiVersion: custom.resource.example.com/v1 + kind: Example + metadata: + name: a-custom-resource + spec: + field: value + - apiVersion: v1 + kind: Namespace + metadata: + name: a-namespace + - apiVersion: v1 + kind: Pod + metadata: + name: a-pod + spec: + containers: + - name: a-pod-container diff --git a/kubernetes-client/src/test/resources/test-crd-schema.yml b/kubernetes-client-api/src/test/resources/serialization/test-crd-schema.yml similarity index 100% rename from kubernetes-client/src/test/resources/test-crd-schema.yml rename to kubernetes-client-api/src/test/resources/serialization/test-crd-schema.yml diff --git a/kubernetes-client-api/src/test/resources/serialization/test-list.yml b/kubernetes-client-api/src/test/resources/serialization/test-list.yml new file mode 100644 index 00000000000..ece75c084ce --- /dev/null +++ b/kubernetes-client-api/src/test/resources/serialization/test-list.yml @@ -0,0 +1,83 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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. +# + +--- +apiVersion: v1 +kind: List +items: + - apiVersion: v1 + kind: Service + metadata: + labels: + app: test-list-app + name: test-list-app + spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: test-list-app + type: NodePort + - apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app: test-list-app + name: test-list-app + spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: test-list-app + template: + metadata: + labels: + app: test-list-app + spec: + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: hello-world:latest + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /health + port: 8080 + scheme: HTTP + initialDelaySeconds: 180 + successThreshold: 1 + name: hello-world + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /health + port: 8080 + scheme: HTTP + initialDelaySeconds: 10 + successThreshold: 1 + securityContext: + privileged: false diff --git a/kubernetes-client/src/test/resources/test-pod-manifest-with-aliases.yml b/kubernetes-client-api/src/test/resources/serialization/test-pod-manifest-with-aliases.yml similarity index 100% rename from kubernetes-client/src/test/resources/test-pod-manifest-with-aliases.yml rename to kubernetes-client-api/src/test/resources/serialization/test-pod-manifest-with-aliases.yml diff --git a/kubernetes-client/src/test/resources/ssl/fabric8 b/kubernetes-client-api/src/test/resources/ssl/fabric8 similarity index 100% rename from kubernetes-client/src/test/resources/ssl/fabric8 rename to kubernetes-client-api/src/test/resources/ssl/fabric8 diff --git a/kubernetes-client/src/test/resources/ssl/fabric8-store b/kubernetes-client-api/src/test/resources/ssl/fabric8-store similarity index 100% rename from kubernetes-client/src/test/resources/ssl/fabric8-store rename to kubernetes-client-api/src/test/resources/ssl/fabric8-store diff --git a/kubernetes-client/src/test/resources/ssl/fabric8.crt b/kubernetes-client-api/src/test/resources/ssl/fabric8.crt similarity index 100% rename from kubernetes-client/src/test/resources/ssl/fabric8.crt rename to kubernetes-client-api/src/test/resources/ssl/fabric8.crt diff --git a/kubernetes-client/src/test/resources/ssl/fabric8.csr b/kubernetes-client-api/src/test/resources/ssl/fabric8.csr similarity index 100% rename from kubernetes-client/src/test/resources/ssl/fabric8.csr rename to kubernetes-client-api/src/test/resources/ssl/fabric8.csr diff --git a/kubernetes-client/src/test/resources/ssl/fabric8.pub b/kubernetes-client-api/src/test/resources/ssl/fabric8.pub similarity index 100% rename from kubernetes-client/src/test/resources/ssl/fabric8.pub rename to kubernetes-client-api/src/test/resources/ssl/fabric8.pub diff --git a/kubernetes-client/src/test/resources/ssl/multiple-certs.pem b/kubernetes-client-api/src/test/resources/ssl/multiple-certs.pem similarity index 100% rename from kubernetes-client/src/test/resources/ssl/multiple-certs.pem rename to kubernetes-client-api/src/test/resources/ssl/multiple-certs.pem diff --git a/kubernetes-client/src/test/resources/ssl/nonunique-subject.pem b/kubernetes-client-api/src/test/resources/ssl/nonunique-subject.pem similarity index 100% rename from kubernetes-client/src/test/resources/ssl/nonunique-subject.pem rename to kubernetes-client-api/src/test/resources/ssl/nonunique-subject.pem diff --git a/kubernetes-client/src/test/resources/ssl/valid-non-base64-encoded-cert.pem b/kubernetes-client-api/src/test/resources/ssl/valid-non-base64-encoded-cert.pem similarity index 100% rename from kubernetes-client/src/test/resources/ssl/valid-non-base64-encoded-cert.pem rename to kubernetes-client-api/src/test/resources/ssl/valid-non-base64-encoded-cert.pem diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-oidc b/kubernetes-client-api/src/test/resources/test-kubeconfig-oidc similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-oidc rename to kubernetes-client-api/src/test/resources/test-kubeconfig-oidc diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-tokeninterceptor b/kubernetes-client-api/src/test/resources/token-refresh-interceptor/kubeconfig similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-tokeninterceptor rename to kubernetes-client-api/src/test/resources/token-refresh-interceptor/kubeconfig diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-tokeninterceptor-oidc b/kubernetes-client-api/src/test/resources/token-refresh-interceptor/kubeconfig-oidc similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-tokeninterceptor-oidc rename to kubernetes-client-api/src/test/resources/token-refresh-interceptor/kubeconfig-oidc diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImplTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImplTest.java new file mode 100644 index 00000000000..c8bebe6b9b5 --- /dev/null +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImplTest.java @@ -0,0 +1,132 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * 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 io.fabric8.kubernetes.client.dsl.internal; + +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.KubernetesResource; +import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.client.CustomResourceList; +import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.dsl.MixedOperation; +import io.fabric8.kubernetes.client.dsl.Resource; +import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; +import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; +import io.fabric8.kubernetes.client.utils.Serialization; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class HasMetadataOperationsImplTest { + + @Test + void shouldBeAbleToReturnOperationsWithoutSpecificList() { + final MixedOperation> operation = + new DefaultKubernetesClient().customResources(Bar.class, BarList.class); + assertNotNull(operation); + } + + @Test + void shouldReturnGenericKubernetesResourceWhenNotRegistered() { + // When + final KubernetesResource resource = Serialization.unmarshal("{\n" + + " \"apiVersion\": \"sample.fabric8.io/v1\",\n" + + " \"kind\": \"Bar\"\n" + + "}"); + // Then + assertThat(resource) + .isInstanceOf(GenericKubernetesResource.class) + .hasFieldOrPropertyWithValue("apiVersion", "sample.fabric8.io/v1"); + } + + @DisplayName("HasMetadataOperationsImpl registers custom kind") + @ParameterizedTest(name = "{index}: {1}") + @MethodSource("registerCustomKindInput") + void hasMetadataOperationsImplRegistersCustomKind( + String description, + ResourceDefinitionContext resourceDefinitionContext, + Class> resourceClazz, + Class> resourceListClazz + ) { + // Given + new HasMetadataOperationsImpl( + new OperationContext(), + resourceDefinitionContext, + resourceClazz, + resourceListClazz + ); + // When + final KubernetesResource resource = Serialization.unmarshal("{\n" + + " \"apiVersion\": \"custom.group/v1alpha1\",\n" + + " \"kind\": \"MyCustomResource\"\n" + + "}"); + // Then + assertThat(resource) + .isInstanceOf(MyCustomResource.class) + .hasFieldOrPropertyWithValue("apiVersion", "custom.group/v1alpha1"); + } + + static Stream registerCustomKindInput() { + final CustomResourceDefinition myCustomResourceCrd = CustomResourceDefinitionContext + .v1beta1CRDFromCustomResourceType(MyCustomResource.class).build(); + return Stream.of( + Arguments.arguments( + "with typed custom resource and list", + CustomResourceDefinitionContext.fromCrd(myCustomResourceCrd), + MyCustomResource.class, + MyCustomResourceList.class), + Arguments.arguments( + "with typed custom resource and generic list", + CustomResourceDefinitionContext.fromCrd(myCustomResourceCrd), + MyCustomResource.class, + CustomResourceList.class), + Arguments.arguments( + "with manual ResourceDefinitionContext", + new ResourceDefinitionContext.Builder() + .withGroup("custom.group") + .withVersion("v1alpha1") + .withPlural("mycustomresources") + .build(), + MyCustomResource.class, + MyCustomResourceList.class) + ); + } + + @Group(MyCustomResource.GROUP) + @Version(MyCustomResource.VERSION) + public static class MyCustomResource extends CustomResource { + public static final String GROUP = "custom.group"; + public static final String VERSION = "v1alpha1"; + } + + public static class MyCustomResourceList extends CustomResourceList { + } + + @Group("sample.fabric8.io") + @Version("v1") + public static class Bar extends CustomResource {} + + public static class BarList extends CustomResourceList {} +} diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/ResourceOperationsImplTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/ResourceOperationsImplTest.java deleted file mode 100644 index e2a9ad27743..00000000000 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/ResourceOperationsImplTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * 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 io.fabric8.kubernetes.client.dsl.internal; - -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.Assert.assertThat; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.MappingJsonFactory; -import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.api.model.KubernetesResource; -import io.fabric8.kubernetes.api.model.KubernetesResourceList; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.client.CustomResource; -import io.fabric8.kubernetes.client.CustomResourceList; -import io.fabric8.kubernetes.client.DefaultKubernetesClient; -import io.fabric8.kubernetes.client.dsl.MixedOperation; -import io.fabric8.kubernetes.client.dsl.Resource; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; -import io.fabric8.kubernetes.internal.KubernetesDeserializer; -import io.fabric8.kubernetes.model.annotation.Group; -import io.fabric8.kubernetes.model.annotation.Version; -import java.io.IOException; -import org.junit.jupiter.api.Test; - -class ResourceOperationsImplTest { - - @Group(MyCustomResource.GROUP) - @Version(MyCustomResource.VERSION) - public static class MyCustomResource extends CustomResource { - public static final String GROUP = "custom.group"; - public static final String VERSION = "v1alpha1"; - } - - public static class MyCustomResourceList extends CustomResourceList { - } - - @Group("sample.fabric8.io") - @Version("v1") - public static class Bar extends CustomResource {} - - private final CustomResourceDefinition crd = CustomResourceDefinitionContext.v1beta1CRDFromCustomResourceType(MyCustomResource.class).build(); - - @Test - void shouldBeAbleToReturnOperationsWithoutSpecificList() { - final MixedOperation> operation = new DefaultKubernetesClient().customResources(Bar.class, CustomResourceList.class); - assertNotNull(operation); - } - - @Test - void shouldRegisterWithKubernetesDeserializer() throws IOException { - assertForContext(new OperationContext(), CustomResourceDefinitionContext.fromCrd(crd), MyCustomResource.class, MyCustomResourceList.class); - } - - @Test - void shouldWorkWithPlainCustomResourceList() throws IOException { - assertForContext(new OperationContext(), CustomResourceDefinitionContext.fromCrd(crd), MyCustomResource.class, CustomResourceList.class); - } - - @Test - void itFallsBackOnTypeKindIfNoKindSpecifiedInContext() throws IOException { - ResourceDefinitionContext rdc = new ResourceDefinitionContext.Builder() - .withGroup(crd.getSpec().getGroup()) - .withVersion(crd.getSpec().getVersion()) - .withPlural(crd.getSpec().getNames().getPlural()) - .build(); - - assertForContext(new OperationContext(), rdc, MyCustomResource.class, MyCustomResourceList.class); - } - - private > void assertForContext(OperationContext context, ResourceDefinitionContext rdc, Class type, Class listType) throws IOException { - // ResourceOperationsImpl constructor invokes KubernetesDeserializer::registerCustomKind - new HasMetadataOperationsImpl<>(context, rdc, type, listType); - - JsonFactory factory = new MappingJsonFactory(); - JsonParser parser = factory.createParser("{\n" + - " \"apiVersion\": \"custom.group/v1alpha1\",\n" + - " \"kind\": \"MyCustomResource\"\n" + - "}"); - - KubernetesDeserializer deserializer = new KubernetesDeserializer(); - KubernetesResource resource = deserializer.deserialize(parser, null); - - assertThat(resource, instanceOf(MyCustomResource.class)); - assertEquals("custom.group/v1alpha1", ((MyCustomResource) resource).getApiVersion()); - } -} diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImplTest.java similarity index 99% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java rename to kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImplTest.java index 78672ac1a53..f072fb5fd24 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImplTest.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class SharedInformerFactoryTest { +class SharedInformerFactoryImplTest { public static final long RESYNC_PERIOD = 10 * 1000L; private ExecutorService executorService; private BaseKubernetesClient mockBaseClient; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/CacheTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/CacheTest.java index 6c7dbb7ad07..6b06ef28692 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/CacheTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/CacheTest.java @@ -18,9 +18,9 @@ import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.client.informers.cache.Cache; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -30,19 +30,25 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class CacheTest { - private static CacheImpl cache = new CacheImpl("mock", CacheTest::mockIndexFunction, CacheTest::mockKeyFunction); + + private CacheImpl cache; + + @BeforeEach + void setUp() { + cache = new CacheImpl<>("mock", CacheTest::mockIndexFunction, CacheTest::mockKeyFunction); + } @Test void testCacheIndex() { Pod testPodObj = new PodBuilder().withNewMetadata().withName("test-pod").endMetadata().build(); cache.put(testPodObj); - cache.replace(Arrays.asList(testPodObj)); + cache.replace(Collections.singletonList(testPodObj)); String index = mockIndexFunction(testPodObj).get(0); String key = mockKeyFunction(testPodObj); - List indexedObjectList = cache.byIndex("mock", index); + List indexedObjectList = cache.byIndex("mock", index); assertEquals(testPodObj, indexedObjectList.get(0)); indexedObjectList = cache.index("mock", testPodObj); @@ -51,7 +57,7 @@ void testCacheIndex() { List allExistingKeys = cache.listKeys(); assertEquals(1, allExistingKeys.size()); assertEquals(key, allExistingKeys.get(0)); - + cache.replace(Collections.emptyList()); assertEquals(0, cache.byIndex("mock", "y").size()); } @@ -61,10 +67,10 @@ void testCacheStore() { Pod testPodObj = new PodBuilder().withNewMetadata().withName("test-pod2").endMetadata().build(); String index = mockIndexFunction(testPodObj).get(0); - cache.replace(Arrays.asList(testPodObj)); + cache.replace(Collections.singletonList(testPodObj)); cache.remove(testPodObj); - List indexedObjectList = cache.byIndex("mock", index); + List indexedObjectList = cache.byIndex("mock", index); assertEquals(0, indexedObjectList.size()); cache.put(testPodObj); @@ -110,8 +116,8 @@ void testAddIndexers() { String clusterIndex = "cluster-index"; Map>> indexers = new HashMap<>(); - indexers.put(nodeIndex, (Pod pod) -> Arrays.asList(pod.getSpec().getNodeName())); - indexers.put(clusterIndex, (Pod pod) -> Arrays.asList(pod.getMetadata().getClusterName())); + indexers.put(nodeIndex, pod -> Collections.singletonList(pod.getSpec().getNodeName())); + indexers.put(clusterIndex, pod -> Collections.singletonList(pod.getMetadata().getClusterName())); podCache.addIndexers(indexers); @@ -133,9 +139,9 @@ void testAddIndexers() { private static List mockIndexFunction(Object obj) { if (obj == null) { - return Arrays.asList("null"); + return Collections.singletonList("null"); } - return Arrays.asList(obj.getClass().getName()); + return Collections.singletonList(obj.getClass().getName()); } private static String mockKeyFunction(Object obj) { diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ListerTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ListerTest.java deleted file mode 100644 index bd8f6945178..00000000000 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ListerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * 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 io.fabric8.kubernetes.client.informers.impl.cache; - -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.PodBuilder; -import io.fabric8.kubernetes.client.informers.cache.Lister; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class ListerTest { - @Test - void testListerBasic() { - CacheImpl podCache = new CacheImpl<>(); - - Lister namespacedPodLister = new Lister<>(podCache, "default"); - List emptyPodList = namespacedPodLister.list(); - assertEquals(0, emptyPodList.size()); - - podCache.replace( - Arrays.asList( - new PodBuilder().withNewMetadata().withName("foo1").withNamespace("default").endMetadata().build(), - new PodBuilder().withNewMetadata().withName("foo2").withNamespace("default").endMetadata().build(), - new PodBuilder().withNewMetadata().withName("foo3").withNamespace("default").endMetadata().build() - )); - - List namespacedPodList = namespacedPodLister.list(); - assertEquals(3, namespacedPodList.size()); - - Lister allNamespacedPodLister = new Lister<>(podCache); - List allPodList = allNamespacedPodLister.list(); - assertEquals(3, allPodList.size()); - - namespacedPodList = allNamespacedPodLister.namespace("default").list(); - assertEquals(3, namespacedPodList.size()); - } -} diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java index 135706f9dbf..7c9df65b238 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorListenerTest.java @@ -18,15 +18,18 @@ import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.client.informers.ResourceEventHandler; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static junit.framework.TestCase.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; class ProcessorListenerTest { - private static boolean addNotificationReceived, updateNotificationReceived, deleteNotificationReceived; + + private boolean addNotificationReceived, updateNotificationReceived, deleteNotificationReceived; + @Test - void testNotificationHandling() throws InterruptedException { + void testNotificationHandling() { Pod pod = new PodBuilder().withNewMetadata().withName("foo").withNamespace("default").endMetadata().build(); ProcessorListener listener = new ProcessorListener<>( diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorStoreTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorStoreTest.java index 3efce0ce746..cdff206e4f7 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorStoreTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ProcessorStoreTest.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; -public class ProcessorStoreTest { +class ProcessorStoreTest { @Test - public void testEvents() { + void testEvents() { ArgumentCaptor> notificationCaptor = ArgumentCaptor.forClass(Notification.class); ArgumentCaptor syncCaptor = ArgumentCaptor.forClass(Boolean.class); CacheImpl podCache = Mockito.mock(CacheImpl.class); @@ -42,77 +42,77 @@ public void testEvents() { ProcessorStore processorStore = new ProcessorStore<>(podCache, processor); Pod pod = new PodBuilder().withNewMetadata().withName("pod").endMetadata().build(); - + // add notification processorStore.add(pod); // add notification, because the pod doesn't exist in the store processorStore.update(pod); - + // ignored processorStore.delete(pod); - + // update notification Mockito.when(podCache.put(pod)).thenReturn(pod); processorStore.update(pod); - + // delete notification Mockito.when(podCache.remove(pod)).thenReturn(pod); processorStore.delete(pod); Mockito.verify(processor, Mockito.times(4)).distribute(notificationCaptor.capture(), syncCaptor.capture()); - + List> notifications = notificationCaptor.getAllValues(); - + assertThat(notifications.get(0)).isInstanceOf(AddNotification.class); assertThat(notifications.get(1)).isInstanceOf(AddNotification.class); assertThat(notifications.get(2)).isInstanceOf(UpdateNotification.class); assertThat(notifications.get(3)).isInstanceOf(DeleteNotification.class); - + List syncValues = syncCaptor.getAllValues(); - + assertThat(syncValues.get(0)).isFalse(); assertThat(syncValues.get(1)).isFalse(); assertThat(syncValues.get(2)).isTrue(); // same object/revision, so it's sync assertThat(syncValues.get(3)).isFalse(); } - + @Test - public void testSyncEvents() { + void testSyncEvents() { ArgumentCaptor> notificationCaptor = ArgumentCaptor.forClass(Notification.class); ArgumentCaptor syncCaptor = ArgumentCaptor.forClass(Boolean.class); CacheImpl podCache = new CacheImpl<>(); SharedProcessor processor = Mockito.mock(SharedProcessor.class); ProcessorStore processorStore = new ProcessorStore<>(podCache, processor); - + Pod pod = new PodBuilder().withNewMetadata().endMetadata().build(); Pod pod2 = new PodBuilder().withNewMetadata().withName("pod2").endMetadata().build(); - + // replace empty store with two values processorStore.add(pod); processorStore.add(pod2); // resync two values processorStore.resync(); - + // relist with deletes processorStore.retainAll(Collections.emptySet()); - + Mockito.verify(processor, Mockito.times(6)).distribute(notificationCaptor.capture(), syncCaptor.capture()); - + List> notifications = notificationCaptor.getAllValues(); - + assertThat(notifications.get(0)).isInstanceOf(AddNotification.class); assertThat(notifications.get(1)).isInstanceOf(AddNotification.class); assertThat(notifications.get(2)).isInstanceOf(UpdateNotification.class); assertThat(notifications.get(3)).isInstanceOf(UpdateNotification.class); assertTrue(syncCaptor.getAllValues().subList(0, 2).stream().allMatch(s->!s.booleanValue())); assertTrue(syncCaptor.getAllValues().subList(2, 4).stream().allMatch(s->s.booleanValue())); - + assertThat(notifications.get(4)).isInstanceOf(DeleteNotification.class); assertThat(notifications.get(5)).isInstanceOf(DeleteNotification.class); - assertTrue(syncCaptor.getAllValues().subList(4, 6).stream().allMatch(s->!s.booleanValue())); + assertTrue(syncCaptor.getAllValues().subList(4, 6).stream().allMatch(s->!s.booleanValue())); } - + } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ReflectorTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ReflectorTest.java index fcf07d21cfb..876dd824983 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ReflectorTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/ReflectorTest.java @@ -49,7 +49,7 @@ void testStateFlags() { .thenThrow(new KubernetesClientException("error")) .thenReturn(Mockito.mock(Watch.class)); - assertThrows(KubernetesClientException.class, () -> reflector.listSyncAndWatch()); + assertThrows(KubernetesClientException.class, reflector::listSyncAndWatch); // running but watch failed assertFalse(reflector.isWatching()); @@ -65,7 +65,7 @@ void testStateFlags() { assertFalse(reflector.isWatching()); assertFalse(reflector.isRunning()); } - + @Test void testNonHttpGone() { ListerWatcher mock = Mockito.mock(ListerWatcher.class); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java index e95793057c9..f6daa182bd1 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/impl/cache/SharedProcessorTest.java @@ -24,7 +24,7 @@ class SharedProcessorTest { @Test - void testListenerAddition() throws InterruptedException { + void testListenerAddition() { SharedProcessor sharedProcessor = new SharedProcessor<>(); Pod foo1 = new PodBuilder().withNewMetadata().withName("foo1").withNamespace("default").endMetadata().build(); @@ -48,11 +48,11 @@ void testListenerAddition() throws InterruptedException { assertTrue(expectUpdateHandler.isSatisfied()); assertTrue(expectDeleteHandler.isSatisfied()); } - + @Test - void testDistributeAfterStop() throws InterruptedException { + void testDistributeAfterStop() { SharedProcessor sharedProcessor = new SharedProcessor<>(); - + sharedProcessor.stop(); Pod foo1 = new PodBuilder().withNewMetadata().withName("foo1").withNamespace("default").endMetadata().build(); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/CreateOrReplaceHelperTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/CreateOrReplaceHelperTest.java similarity index 98% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/CreateOrReplaceHelperTest.java rename to kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/CreateOrReplaceHelperTest.java index 692892754b5..0c0cbbc3235 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/CreateOrReplaceHelperTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/CreateOrReplaceHelperTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.fabric8.kubernetes.client.utils; +package io.fabric8.kubernetes.client.utils.internal; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; @@ -50,7 +50,7 @@ void testCreateOrReplaceShouldCreate() { p -> getPod(), p -> getPod() ); - + Pod p = getPod(); p.getMetadata().setResourceVersion("1"); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/DeleteAndCreateHelperTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/DeleteAndCreateHelperTest.java similarity index 99% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/DeleteAndCreateHelperTest.java rename to kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/DeleteAndCreateHelperTest.java index 35902d110dd..0dea5e142da 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/DeleteAndCreateHelperTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/DeleteAndCreateHelperTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.fabric8.kubernetes.client.utils; +package io.fabric8.kubernetes.client.utils.internal; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapperTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/OptionalDependencyWrapperTest.java similarity index 97% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapperTest.java rename to kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/OptionalDependencyWrapperTest.java index b0fef28879b..cf776a61e24 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapperTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/OptionalDependencyWrapperTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.fabric8.kubernetes.client.utils; +package io.fabric8.kubernetes.client.utils.internal; import io.fabric8.kubernetes.client.KubernetesClientException; import org.junit.jupiter.api.Test; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/PodOperationUtilTest.java similarity index 99% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java rename to kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/PodOperationUtilTest.java index 330a94842e2..0b2da671c04 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/internal/PodOperationUtilTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.fabric8.kubernetes.client.utils; +package io.fabric8.kubernetes.client.utils.internal; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; diff --git a/kubernetes-client/src/test/resources/serialization/custom-resource.yml b/kubernetes-client/src/test/resources/serialization/custom-resource.yml deleted file mode 100644 index e5094b28377..00000000000 --- a/kubernetes-client/src/test/resources/serialization/custom-resource.yml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: the-cr.example.com/v1 -kind: SomeCustomResource -metadata: - name: custom-resource-example -spec: - field: value -status: - reconciled: true diff --git a/kubernetes-client/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml b/kubernetes-client/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml deleted file mode 100644 index 3ee48663480..00000000000 --- a/kubernetes-client/src/test/resources/serialization/document-with-leading-and-trailing-document-delimiter.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - name: redis-master - labels: - app: redis - tier: backend - role: master -spec: - ports: - - port: 6379 - targetPort: 6379 - selector: - app: redis - tier: backend - role: master ---- diff --git a/kubernetes-client/src/test/resources/serialization/document-with-leading-document-delimiter.yml b/kubernetes-client/src/test/resources/serialization/document-with-leading-document-delimiter.yml deleted file mode 100644 index b051d47df64..00000000000 --- a/kubernetes-client/src/test/resources/serialization/document-with-leading-document-delimiter.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - name: redis-master - labels: - app: redis - tier: backend - role: master -spec: - ports: - - port: 6379 - targetPort: 6379 - selector: - app: redis - tier: backend - role: master diff --git a/kubernetes-client/src/test/resources/serialization/document-with-no-document-delimiter.yml b/kubernetes-client/src/test/resources/serialization/document-with-no-document-delimiter.yml deleted file mode 100644 index 3613bc0e870..00000000000 --- a/kubernetes-client/src/test/resources/serialization/document-with-no-document-delimiter.yml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: redis-master - labels: - app: redis - tier: backend - role: master -spec: - ports: - - port: 6379 - targetPort: 6379 - selector: - app: redis - tier: backend - role: master diff --git a/kubernetes-client/src/test/resources/serialization/document-with-trailing-document-delimiter.yml b/kubernetes-client/src/test/resources/serialization/document-with-trailing-document-delimiter.yml deleted file mode 100644 index 5b2b6dac862..00000000000 --- a/kubernetes-client/src/test/resources/serialization/document-with-trailing-document-delimiter.yml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: redis-master - labels: - app: redis - tier: backend - role: master -spec: - ports: - - port: 6379 - targetPort: 6379 - selector: - app: redis - tier: backend - role: master ---- diff --git a/kubernetes-client/src/test/resources/serialization/invalid-resource.yml b/kubernetes-client/src/test/resources/serialization/invalid-resource.yml deleted file mode 100644 index efced3bcc14..00000000000 --- a/kubernetes-client/src/test/resources/serialization/invalid-resource.yml +++ /dev/null @@ -1 +0,0 @@ -not-a: resource diff --git a/kubernetes-client/src/test/resources/serialization/invalid-yaml.yml b/kubernetes-client/src/test/resources/serialization/invalid-yaml.yml deleted file mode 100644 index 5670a5bb0e0..00000000000 --- a/kubernetes-client/src/test/resources/serialization/invalid-yaml.yml +++ /dev/null @@ -1,5 +0,0 @@ -This - -is not - -YAML diff --git a/kubernetes-client/src/test/resources/serialization/kubernetes-list.yml b/kubernetes-client/src/test/resources/serialization/kubernetes-list.yml deleted file mode 100644 index 660210aa120..00000000000 --- a/kubernetes-client/src/test/resources/serialization/kubernetes-list.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -apiVersion: v1 -kind: List -items: - - apiVersion: custom.resource.example.com/v1 - kind: Example - metadata: - name: a-custom-resource - spec: - field: value - - apiVersion: v1 - kind: Namespace - metadata: - name: a-namespace - - apiVersion: v1 - kind: Pod - metadata: - name: a-pod - spec: - containers: - - name: a-pod-container