[FLINK-24129][connectors-pulsar] Harden TopicRangeTest.rangeCreationHaveALimitedScope.
diff --git a/flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/enumerator/topic/TopicRangeTest.java b/flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/enumerator/topic/TopicRangeTest.java
index 93b3621..f5665e7 100644
--- a/flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/enumerator/topic/TopicRangeTest.java
+++ b/flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/enumerator/topic/TopicRangeTest.java
@@ -20,11 +20,8 @@
 
 import org.apache.flink.util.InstantiationUtil;
 
-import org.junit.jupiter.api.RepeatedTest;
 import org.junit.jupiter.api.Test;
 
-import java.util.Random;
-
 import static org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.MAX_RANGE;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -33,26 +30,30 @@
 /** Unit tests for {@link TopicRange}. */
 class TopicRangeTest {
 
-    private final Random random = new Random(System.currentTimeMillis());
-
-    @RepeatedTest(10)
-    @SuppressWarnings("java:S5778")
-    void rangeCreationHaveALimitedScope() {
-        assertThrows(
-                IllegalArgumentException.class,
-                () -> new TopicRange(-1, random.nextInt(MAX_RANGE)));
-        assertThrows(
-                IllegalArgumentException.class,
-                () -> new TopicRange(1, MAX_RANGE + random.nextInt(10000)));
-
-        assertDoesNotThrow(() -> new TopicRange(1, random.nextInt(MAX_RANGE)));
+    @Test
+    void topicRangeIsSerializable() throws Exception {
+        final TopicRange range = new TopicRange(1, 5);
+        final TopicRange cloneRange = InstantiationUtil.clone(range);
+        assertEquals(range, cloneRange);
     }
 
     @Test
-    void topicRangeIsSerializable() throws Exception {
-        TopicRange range = new TopicRange(10, random.nextInt(MAX_RANGE));
-        TopicRange cloneRange = InstantiationUtil.clone(range);
+    void negativeStart() {
+        assertThrows(IllegalArgumentException.class, () -> new TopicRange(-1, 1));
+    }
 
-        assertEquals(range, cloneRange);
+    @Test
+    void endBelowTheMaximum() {
+        assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE - 1));
+    }
+
+    @Test
+    void endOnTheMaximum() {
+        assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE));
+    }
+
+    @Test
+    void endAboveTheMaximum() {
+        assertThrows(IllegalArgumentException.class, () -> new TopicRange(1, MAX_RANGE + 1));
     }
 }