Skip to content

Commit e8d3032

Browse files
committed
fixes broken pom and re-run formatter
1 parent 81335ce commit e8d3032

File tree

10 files changed

+153
-135
lines changed

10 files changed

+153
-135
lines changed

extended/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</dependency>
6060
<dependency>
6161
<groupId>com.github.stefanbirkner</groupId>
62-
<artifactId>system-rules</artifactId>
62+
<artifactId>system-lambda</artifactId>
6363
<scope>test</scope>
6464
</dependency>
6565
<dependency>

util/src/test/java/io/kubernetes/client/informer/cache/CacheTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.function.Function;
27-
import org.junit.Rule;
2827
import org.junit.Test;
2928
import org.junit.runner.RunWith;
3029
import org.junit.runners.Parameterized;

util/src/test/java/io/kubernetes/client/informer/cache/ControllerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Arrays;
2525
import java.util.concurrent.atomic.AtomicBoolean;
2626
import java.util.concurrent.atomic.AtomicInteger;
27-
import org.junit.Rule;
2827
import org.junit.Test;
2928

3029
public class ControllerTest {

util/src/test/java/io/kubernetes/client/informer/cache/DeltaFIFOTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Deque;
2424
import java.util.LinkedList;
2525
import org.apache.commons.lang3.tuple.MutablePair;
26-
import org.junit.Rule;
2726
import org.junit.Test;
2827

2928
public class DeltaFIFOTest {

util/src/test/java/io/kubernetes/client/informer/cache/ListerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.kubernetes.client.openapi.models.V1Pod;
1919
import java.util.Arrays;
2020
import java.util.List;
21-
import org.junit.Rule;
2221
import org.junit.Test;
2322

2423
public class ListerTest {

util/src/test/java/io/kubernetes/client/informer/cache/ProcessorListenerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import io.kubernetes.client.informer.ResourceEventHandler;
1818
import io.kubernetes.client.openapi.models.V1ObjectMeta;
1919
import io.kubernetes.client.openapi.models.V1Pod;
20-
import org.junit.Rule;
2120
import org.junit.Test;
2221

2322
public class ProcessorListenerTest {

util/src/test/java/io/kubernetes/client/informer/cache/ReflectorRunnableTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.concurrent.atomic.AtomicReference;
3535
import org.awaitility.Awaitility;
3636
import org.hamcrest.core.IsEqual;
37-
import org.junit.Rule;
3837
import org.junit.Test;
3938
import org.junit.runner.RunWith;
4039
import org.mockito.Mock;

util/src/test/java/io/kubernetes/client/informer/cache/SharedProcessorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.kubernetes.client.openapi.models.V1Pod;
2121
import java.time.Duration;
2222
import java.util.concurrent.Executors;
23-
import org.junit.Rule;
2423
import org.junit.Test;
2524

2625
public class SharedProcessorTest {

util/src/test/java/io/kubernetes/client/util/ClientBuilderTest.java

Lines changed: 121 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package io.kubernetes.client.util;
1414

15+
import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable;
1516
import static io.kubernetes.client.util.Config.ENV_SERVICE_HOST;
1617
import static io.kubernetes.client.util.Config.ENV_SERVICE_PORT;
1718
import static org.hamcrest.MatcherAssert.assertThat;
@@ -30,11 +31,7 @@
3031
import java.io.IOException;
3132
import java.nio.file.Files;
3233
import java.nio.file.Paths;
33-
import org.junit.Before;
34-
import org.junit.Rule;
3534
import org.junit.Test;
36-
import org.junit.contrib.java.lang.system.EnvironmentVariables;
37-
import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable;
3835

3936
/** Tests for the ConfigBuilder helper class */
4037
public class ClientBuilderTest {
@@ -60,115 +57,127 @@ public class ClientBuilderTest {
6057
public static final String KUBEDIR = ".kube";
6158
public static final String KUBECONFIG = "config";
6259

63-
@Rule public final EnvironmentVariables environmentVariables = new EnvironmentVariables();
64-
65-
@Before
66-
public void setup() {
67-
environmentVariables.set("HOME", "/non-existent");
68-
environmentVariables.set("KUBECONFIG", null);
69-
}
70-
7160
@Test
7261
public void testDefaultClientWithNoFiles() throws Exception {
73-
String path = withEnvironmentVariable("HOME", "/non-existent")
74-
.execute(() -> {
75-
environmentVariables.set("HOME", "/non-existent");
76-
final ApiClient client = ClientBuilder.defaultClient();
77-
return client.getBasePath();
78-
});
62+
String path =
63+
withEnvironmentVariable("HOME", "/non-existent")
64+
.and("KUBECONFIG", null)
65+
.execute(
66+
() -> {
67+
final ApiClient client = ClientBuilder.defaultClient();
68+
return client.getBasePath();
69+
});
7970
assertEquals("http://localhost:8080", path);
8071
}
8172

8273
@Test
8374
public void testDefaultClientReadsHomeDir() throws Exception {
84-
String path = withEnvironmentVariable("HOME", HOME_PATH)
85-
.execute(() -> {
86-
ApiClient client = ClientBuilder.defaultClient();
87-
return client.getBasePath();
88-
});
75+
String path =
76+
withEnvironmentVariable("HOME", HOME_PATH)
77+
.execute(
78+
() -> {
79+
ApiClient client = ClientBuilder.defaultClient();
80+
return client.getBasePath();
81+
});
8982
assertEquals("http://home.dir.com", path);
9083
}
9184

9285
@Test
9386
public void testDefaultClientReadsKubeConfig() throws Exception {
94-
String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_FILE_PATH)
95-
.execute(() -> {
96-
final ApiClient client = ClientBuilder.defaultClient();
97-
return client.getBasePath();
98-
});
87+
String path =
88+
withEnvironmentVariable("KUBECONFIG", KUBECONFIG_FILE_PATH)
89+
.execute(
90+
() -> {
91+
final ApiClient client = ClientBuilder.defaultClient();
92+
return client.getBasePath();
93+
});
9994
assertEquals("http://kubeconfig.dir.com", path);
10095
}
10196

10297
@Test
10398
public void testDefaultClientUTF8EncodedConfig() throws Exception {
104-
String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_UTF8_FILE_PATH)
105-
.execute(() -> {
106-
final ApiClient client = ClientBuilder.defaultClient();
107-
return client.getBasePath();
108-
});
99+
String path =
100+
withEnvironmentVariable("KUBECONFIG", KUBECONFIG_UTF8_FILE_PATH)
101+
.execute(
102+
() -> {
103+
final ApiClient client = ClientBuilder.defaultClient();
104+
return client.getBasePath();
105+
});
109106
assertEquals("http://kubeconfig.dir.com", path);
110107
}
111108

112109
@Test
113110
public void testDefaultClientReadsKubeConfigMultiple() throws Exception {
114111
final String kubeConfigEnv = KUBECONFIG_FILE_PATH + File.pathSeparator + "/non-existent";
115-
String path = withEnvironmentVariable("KUBECONFIG", kubeConfigEnv)
116-
.execute(() -> {
117-
final ApiClient client = ClientBuilder.defaultClient();
118-
return client.getBasePath();
119-
});
112+
String path =
113+
withEnvironmentVariable("KUBECONFIG", kubeConfigEnv)
114+
.execute(
115+
() -> {
116+
final ApiClient client = ClientBuilder.defaultClient();
117+
return client.getBasePath();
118+
});
120119
assertEquals("http://kubeconfig.dir.com", path);
121120
}
122121

123122
@Test
124123
public void testKubeconfigPreferredOverHomeDir() throws Exception {
125-
String path = withEnvironmentVariable("HOME", HOME_PATH)
126-
.and("KUBECONFIG", KUBECONFIG_FILE_PATH)
127-
.execute(() -> {
128-
final ApiClient client = ClientBuilder.standard().build();
129-
return client.getBasePath();
130-
});
124+
String path =
125+
withEnvironmentVariable("HOME", HOME_PATH)
126+
.and("KUBECONFIG", KUBECONFIG_FILE_PATH)
127+
.execute(
128+
() -> {
129+
final ApiClient client = ClientBuilder.standard().build();
130+
return client.getBasePath();
131+
});
131132
// $KUBECONFIG should take precedence over $HOME/.kube/config
132133
assertEquals("http://kubeconfig.dir.com", path);
133134
}
134135

135136
@Test
136137
public void testInvalidKubeconfig() throws Exception {
137-
String path = withEnvironmentVariable("KUBECONFIG", "/non-existent")
138-
.execute(() -> {
139-
final ApiClient client = ClientBuilder.standard().build();
140-
return client.getBasePath();
141-
});
138+
String path =
139+
withEnvironmentVariable("KUBECONFIG", "/non-existent")
140+
.execute(
141+
() -> {
142+
final ApiClient client = ClientBuilder.standard().build();
143+
return client.getBasePath();
144+
});
142145
assertThat(path, is(Config.DEFAULT_FALLBACK_HOST));
143146
}
144147

145148
@Test
146149
public void testKubeconfigAddsSchemeHttps() throws Exception {
147-
String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTPS_FILE_PATH)
148-
.execute(() -> {
149-
final ApiClient client = ClientBuilder.standard().build();
150-
return client.getBasePath();
151-
});
150+
String path =
151+
withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTPS_FILE_PATH)
152+
.execute(
153+
() -> {
154+
final ApiClient client = ClientBuilder.standard().build();
155+
return client.getBasePath();
156+
});
152157
assertThat(path, is("https://localhost:443"));
153158
}
154159

155160
@Test
156161
public void testKubeconfigAddsSchemeHttp() throws Exception {
157-
String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTP_FILE_PATH)
158-
.execute(() -> {
159-
final ApiClient client = ClientBuilder.standard().build();
160-
return client.getBasePath();
161-
});
162+
String path =
163+
withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTP_FILE_PATH)
164+
.execute(
165+
() -> {
166+
final ApiClient client = ClientBuilder.standard().build();
167+
return client.getBasePath();
168+
});
162169
assertThat(path, is("http://localhost"));
163170
}
164171

165172
@Test
166173
public void testKubeconfigDisablesVerifySsl() throws Exception {
167-
boolean isVerifyingSsl = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTP_FILE_PATH)
168-
.execute(() -> {
169-
final ApiClient client = ClientBuilder.standard().build();
170-
return client.isVerifyingSsl();
171-
});
174+
boolean isVerifyingSsl =
175+
withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTP_FILE_PATH)
176+
.execute(
177+
() -> {
178+
final ApiClient client = ClientBuilder.standard().build();
179+
return client.isVerifyingSsl();
180+
});
172181
assertThat(isVerifyingSsl, is(false));
173182
}
174183

@@ -180,11 +189,13 @@ public void testBasePathTrailingSlash() throws Exception {
180189

181190
@Test
182191
public void testStandardVerifiesSsl() throws Exception {
183-
boolean isVerifyingSsl = withEnvironmentVariable("HOME", "/non-existent")
184-
.execute(() -> {
185-
final ApiClient client = ClientBuilder.standard().build();
186-
return client.isVerifyingSsl();
187-
});
192+
boolean isVerifyingSsl =
193+
withEnvironmentVariable("HOME", "/non-existent")
194+
.execute(
195+
() -> {
196+
final ApiClient client = ClientBuilder.standard().build();
197+
return client.isVerifyingSsl();
198+
});
188199
assertThat(isVerifyingSsl, is(true));
189200
}
190201

@@ -218,51 +229,57 @@ public void testSslCertCaBad() throws Exception {
218229

219230
@Test
220231
public void testHomeDirPreferredOverKubeConfig() throws Exception {
221-
String path = withEnvironmentVariable("HOME", HOME_PATH)
222-
.and("KUBEDIR", KUBEDIR)
223-
.and("KUBECONFIG", KUBECONFIG)
224-
.execute(() -> {
225-
final ApiClient client = ClientBuilder.standard().build();
226-
return client.getBasePath();
227-
});
232+
String path =
233+
withEnvironmentVariable("HOME", HOME_PATH)
234+
.and("KUBEDIR", KUBEDIR)
235+
.and("KUBECONFIG", KUBECONFIG)
236+
.execute(
237+
() -> {
238+
final ApiClient client = ClientBuilder.standard().build();
239+
return client.getBasePath();
240+
});
228241
assertEquals(path, "http://home.dir.com");
229242
}
230243

231244
@Test
232245
public void testIPv4AddressParsingShouldWork() throws Exception {
233-
String path = withEnvironmentVariable(ENV_SERVICE_HOST, "127.0.0.1")
234-
.and(ENV_SERVICE_PORT, "6443")
235-
.execute(() -> {
236-
String ipv4Host = "127.0.0.1";
237-
String port = "6443";
238-
ClientBuilder builder =
239-
new ClientBuilder() {
240-
@Override
241-
public ClientBuilder setBasePath(String host, String port) {
242-
return super.setBasePath(host, port);
243-
}
244-
}.setBasePath(ipv4Host, port);
245-
return builder.getBasePath();
246-
});
246+
String path =
247+
withEnvironmentVariable(ENV_SERVICE_HOST, "127.0.0.1")
248+
.and(ENV_SERVICE_PORT, "6443")
249+
.execute(
250+
() -> {
251+
String ipv4Host = "127.0.0.1";
252+
String port = "6443";
253+
ClientBuilder builder =
254+
new ClientBuilder() {
255+
@Override
256+
public ClientBuilder setBasePath(String host, String port) {
257+
return super.setBasePath(host, port);
258+
}
259+
}.setBasePath(ipv4Host, port);
260+
return builder.getBasePath();
261+
});
247262
assertEquals(path, "https://127.0.0.1:6443");
248263
}
249264

250265
@Test
251266
public void testIPv6AddressParsingShouldWork() throws Exception {
252-
String path = withEnvironmentVariable(ENV_SERVICE_HOST, "127.0.0.1")
253-
.and(ENV_SERVICE_PORT, "6443")
254-
.execute(() -> {
255-
String ipv4Host = "::1";
256-
String port = "6443";
257-
ClientBuilder builder =
258-
new ClientBuilder() {
259-
@Override
260-
public ClientBuilder setBasePath(String host, String port) {
261-
return super.setBasePath(host, port);
262-
}
263-
}.setBasePath(ipv4Host, port);
264-
return builder.getBasePath();
265-
});
267+
String path =
268+
withEnvironmentVariable(ENV_SERVICE_HOST, "127.0.0.1")
269+
.and(ENV_SERVICE_PORT, "6443")
270+
.execute(
271+
() -> {
272+
String ipv4Host = "::1";
273+
String port = "6443";
274+
ClientBuilder builder =
275+
new ClientBuilder() {
276+
@Override
277+
public ClientBuilder setBasePath(String host, String port) {
278+
return super.setBasePath(host, port);
279+
}
280+
}.setBasePath(ipv4Host, port);
281+
return builder.getBasePath();
282+
});
266283
assertEquals(path, "https://[::1]:6443");
267284
}
268285

0 commit comments

Comments
 (0)