@@ -130,13 +130,31 @@ public void testReplicatesHeartbeatsWhenDisabledButFilterAllows() {
130130 public void testNoCycles () {
131131 MirrorSourceConnector connector = new MirrorSourceConnector (new SourceAndTarget ("source" , "target" ),
132132 new DefaultReplicationPolicy (), x -> true , getConfigPropertyFilter ());
133+ assertFalse (connector .shouldReplicateTopic ("source.topic1" ), "should not allow cycles" );
133134 assertFalse (connector .shouldReplicateTopic ("target.topic1" ), "should not allow cycles" );
134135 assertFalse (connector .shouldReplicateTopic ("target.source.topic1" ), "should not allow cycles" );
135136 assertFalse (connector .shouldReplicateTopic ("source.target.topic1" ), "should not allow cycles" );
136137 assertFalse (connector .shouldReplicateTopic ("target.source.target.topic1" ), "should not allow cycles" );
137138 assertFalse (connector .shouldReplicateTopic ("source.target.source.topic1" ), "should not allow cycles" );
138139 assertTrue (connector .shouldReplicateTopic ("topic1" ), "should allow anything else" );
139- assertTrue (connector .shouldReplicateTopic ("source.topic1" ), "should allow anything else" );
140+ assertTrue (connector .shouldReplicateTopic ("othersource.topic1" ), "should allow anything else" );
141+ assertTrue (connector .shouldReplicateTopic ("othertarget.topic1" ), "should allow anything else" );
142+ assertTrue (connector .shouldReplicateTopic ("other.another.topic1" ), "should allow anything else" );
143+
144+ final IdentityReplicationPolicy identityReplicationPolicy = new IdentityReplicationPolicy ();
145+ final HashMap <String , String > props = new HashMap <>();
146+ props .put ("source.cluster.alias" , "source" );
147+ identityReplicationPolicy .configure (props );
148+ connector = new MirrorSourceConnector (new SourceAndTarget ("source" , "target" ),
149+ identityReplicationPolicy , x -> true , x -> true );
150+ assertTrue (connector .shouldReplicateTopic ("source.topic1" ), "should not consider this a cycle" );
151+ assertTrue (connector .shouldReplicateTopic ("target.topic1" ), "should not consider this a cycle" );
152+ assertTrue (connector .shouldReplicateTopic ("target.source.topic1" ), "should not consider this a cycle" );
153+ assertTrue (connector .shouldReplicateTopic ("source.target.topic1" ), "should not consider this a cycle" );
154+ assertTrue (connector .shouldReplicateTopic ("topic1" ), "should not consider this a cycle" );
155+ assertTrue (connector .shouldReplicateTopic ("othersource.topic1" ), "should not consider this a cycle" );
156+ assertTrue (connector .shouldReplicateTopic ("othertarget.topic1" ), "should not consider this a cycle" );
157+ assertTrue (connector .shouldReplicateTopic ("other.another.topic1" ), "should not consider this a cycle" );
140158 }
141159
142160 @ Test
0 commit comments