Skip to content

Commit 7024347

Browse files
author
Andrei Nadyktov
committed
IGNITE-22530 Add new test
1 parent f44d84d commit 7024347

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

modules/cdc-ext/src/main/java/org/apache/ignite/cdc/CdcRegexManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void compileRegexp(String includeTemplate, String excludeTemplate) {
5757
excludeFilter = Pattern.compile(excludeTemplate);
5858
}
5959
catch (PatternSyntaxException e) {
60-
throw new IgniteException("Invalid cache regexp template.", e);
60+
throw new IgniteException("Invalid cache regexp template", e);
6161
}
6262
}
6363
}

modules/cdc-ext/src/test/java/org/apache/ignite/cdc/RegexFiltersSelfTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.stream.IntStream;
66

77
import org.apache.ignite.IgniteCache;
8+
import org.apache.ignite.IgniteException;
89
import org.apache.ignite.cdc.thin.IgniteToIgniteClientCdcStreamer;
910
import org.apache.ignite.cluster.ClusterState;
1011
import org.apache.ignite.configuration.CacheConfiguration;
@@ -76,6 +77,8 @@ private enum WaitDataMode {
7677
/** */
7778
private static final String REGEX_EXCLUDE_PATTERN = "forbidden.*";
7879

80+
private static final String INVALID_PATTERN = "[aaaaaaaaaaaaa";
81+
7982
/** */
8083
private static final int KEYS_CNT = 1000;
8184

@@ -325,6 +328,26 @@ public void testRegexExcludeFilters() throws Exception {
325328
cdc.cancel();
326329
}
327330

331+
/**
332+
* Test checks that CDC won't start if invalid cache regexp is set.
333+
*/
334+
@Test
335+
public void testInvalidRegex() throws Exception {
336+
src.cluster().state(ClusterState.ACTIVE);
337+
338+
dest.cluster().state(ClusterState.ACTIVE);
339+
340+
IgniteInternalFuture<?> cdc = startCdc(src.configuration(), TEST_CACHE, INVALID_PATTERN, "");
341+
342+
waitForCondition(() -> cdc.error() != null, getTestTimeout());
343+
344+
assertEquals(IgniteException.class, cdc.error().getClass());
345+
346+
assertEquals("Invalid cache regexp template", cdc.error().getMessage());
347+
348+
cdc.cancel();
349+
}
350+
328351
/** */
329352
private static class TestI2IClientCdcStreamer extends IgniteToIgniteClientCdcStreamer {
330353
/** */

0 commit comments

Comments
 (0)