|
74 | 74 | import java.util.function.Function;
|
75 | 75 |
|
76 | 76 | import static org.assertj.core.api.Assertions.assertThat;
|
| 77 | +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
77 | 78 | import static org.awaitility.Awaitility.await;
|
78 | 79 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
79 | 80 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
@@ -103,7 +104,7 @@ class DefaultSharedIndexInformerTest {
|
103 | 104 | .withKind("Animal")
|
104 | 105 | .withScope("Namespaced")
|
105 | 106 | .build();
|
106 |
| - private KubernetesClient client; |
| 107 | + KubernetesClient client; |
107 | 108 | private SharedInformerFactory factory;
|
108 | 109 |
|
109 | 110 | @BeforeEach
|
@@ -212,7 +213,7 @@ void testInformerWithNamespaceAndNameConfigured() throws InterruptedException {
|
212 | 213 | RESYNC_PERIOD);
|
213 | 214 | CountDownLatch foundExistingPod = new CountDownLatch(1);
|
214 | 215 | podInformer.addEventHandler(
|
215 |
| - new ResourceEventHandler<Pod>() { |
| 216 | + new ResourceEventHandler<>() { |
216 | 217 | @Override
|
217 | 218 | public void onAdd(Pod obj) {
|
218 | 219 | if (obj.getMetadata().getName().equalsIgnoreCase("pod1")) {
|
@@ -541,7 +542,7 @@ void testEventListeners() throws InterruptedException {
|
541 | 542 | SharedIndexInformer<Pod> podInformer = factory.sharedIndexInformerFor(Pod.class, 1000L);
|
542 | 543 | CountDownLatch failureCallbackReceived = new CountDownLatch(1);
|
543 | 544 | podInformer.addEventHandler(
|
544 |
| - new ResourceEventHandler<Pod>() { |
| 545 | + new ResourceEventHandler<>() { |
545 | 546 | @Override
|
546 | 547 | public void onAdd(Pod obj) {
|
547 | 548 | }
|
@@ -1224,22 +1225,19 @@ void testClientStopClosesInformer() throws InterruptedException {
|
1224 | 1225 | }
|
1225 | 1226 |
|
1226 | 1227 | @Test
|
1227 |
| - void testClientStopClosesInformerBeforeStarting() throws InterruptedException { |
| 1228 | + void clientStopPreventsInformerFromStarting() { |
1228 | 1229 | // Given
|
1229 | 1230 | setupMockServerExpectations(Animal.class, "ns1", this::getList,
|
1230 | 1231 | r -> new WatchEvent(getAnimal("red-panda", "Carnivora", r), "ADDED"), null, null);
|
1231 |
| - |
1232 |
| - // When |
1233 | 1232 | SharedIndexInformer<GenericKubernetesResource> animalSharedIndexInformer = client
|
1234 | 1233 | .genericKubernetesResources(animalContext)
|
1235 | 1234 | .inNamespace("ns1")
|
1236 | 1235 | .runnableInformer(60 * WATCH_EVENT_EMIT_TIME);
|
1237 |
| - |
1238 | 1236 | client.close();
|
1239 |
| - |
1240 |
| - animalSharedIndexInformer.start(); |
1241 |
| - |
1242 |
| - assertTrue(animalSharedIndexInformer.stopped().toCompletableFuture().isDone()); |
| 1237 | + // When |
| 1238 | + assertThatIllegalStateException() |
| 1239 | + .isThrownBy(animalSharedIndexInformer::start) |
| 1240 | + .withMessage("Client is closed"); |
1243 | 1241 | }
|
1244 | 1242 |
|
1245 | 1243 | private KubernetesResource getAnimal(String name, String order, String resourceVersion) {
|
|
0 commit comments