This is an automated email from the ASF dual-hosted git repository.
rmetzger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new e18d273 [FLINK-24129][connectors-pulsar] Harden
TopicRangeTest.rangeCreationHaveALimitedScope.
e18d273 is described below
commit e18d2731a637b6f6d7f984221e95f02fb68b4e20
Author: David Moravek <[email protected]>
AuthorDate: Mon Sep 6 11:39:24 2021 +0200
[FLINK-24129][connectors-pulsar] Harden
TopicRangeTest.rangeCreationHaveALimitedScope.
---
.../source/enumerator/topic/TopicRangeTest.java | 37 +++++++++++-----------
1 file changed, 19 insertions(+), 18 deletions(-)
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 @@ package
org.apache.flink.connector.pulsar.source.enumerator.topic;
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 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
/** Unit tests for {@link TopicRange}. */
class TopicRangeTest {
- private final Random random = new Random(System.currentTimeMillis());
+ @Test
+ void topicRangeIsSerializable() throws Exception {
+ final TopicRange range = new TopicRange(1, 5);
+ final TopicRange cloneRange = InstantiationUtil.clone(range);
+ assertEquals(range, cloneRange);
+ }
- @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)));
+ @Test
+ void negativeStart() {
+ assertThrows(IllegalArgumentException.class, () -> new TopicRange(-1,
1));
+ }
- assertDoesNotThrow(() -> new TopicRange(1, random.nextInt(MAX_RANGE)));
+ @Test
+ void endBelowTheMaximum() {
+ assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE - 1));
}
@Test
- void topicRangeIsSerializable() throws Exception {
- TopicRange range = new TopicRange(10, random.nextInt(MAX_RANGE));
- TopicRange cloneRange = InstantiationUtil.clone(range);
+ void endOnTheMaximum() {
+ assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE));
+ }
- assertEquals(range, cloneRange);
+ @Test
+ void endAboveTheMaximum() {
+ assertThrows(IllegalArgumentException.class, () -> new TopicRange(1,
MAX_RANGE + 1));
}
}