]> juplo.de Git - demos/kafka/training/commitdiff
ROT: Verhalten beim Abrufen von einer nicht existierenden Partition definiert
authorKai Moritz <kai@juplo.de>
Mon, 7 Apr 2025 17:42:59 +0000 (19:42 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 20 Mar 2026 17:55:29 +0000 (18:55 +0100)
src/test/java/de/juplo/kafka/ApplicationTests.java

index bb48a5784057f50caa16d3c966cba59bf37ac11a..660f90dc2f20f83fedacd2d6bf88b83e94f72ca2 100644 (file)
@@ -10,6 +10,8 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.resttestclient.TestRestTemplate;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -74,6 +76,15 @@ public class ApplicationTests
     assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value()));
   }
 
+  @DisplayName("Non-existent partition")
+  @ParameterizedTest(name = "partition: {0}")
+  @ValueSource(ints = { -1, NUM_PARTITIONS, 66 })
+  void testNonExistentPartition(int partition)
+  {
+    ResponseEntity<String> response = restTemplate.getForEntity("/{partition}/0", String.class, partition);
+    assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value()));
+  }
+
 
   static final String TOPIC = "ExampleConsumerTest_TEST";
   static final int NUM_PARTITIONS = 7;