diff options
Diffstat (limited to 'server/sonar-process')
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java index cc3e712f63d..86418d5f637 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java @@ -21,6 +21,8 @@ package org.sonar.process.cluster.hz; import com.hazelcast.cluster.Member; import com.hazelcast.cluster.memberselector.MemberSelectors; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.topic.ITopic; import java.net.InetAddress; import java.util.Arrays; import java.util.List; @@ -34,10 +36,17 @@ import org.junit.Test; import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; +import org.mockito.verification.VerificationMode; +import org.sonar.core.util.RuleActivationListener; import org.sonar.process.NetworkUtilsImpl; import org.sonar.process.ProcessId; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class HazelcastMemberImplTest { @@ -106,6 +115,19 @@ public class HazelcastMemberImplTest { assertThat(failures.get(0)).hasMessageContaining("BOOM"); } + @Test + public void subscribeRuleActivationTopic_listenerAdded() { + RuleActivationListener listener = mock(RuleActivationListener.class); + HazelcastInstance hzInstance = mock(HazelcastInstance.class); + ITopic<Object> topic = mock(ITopic.class); + when(hzInstance.getTopic(any())).thenReturn(topic); + HazelcastMemberImpl underTest = new HazelcastMemberImpl(hzInstance); + + underTest.subscribeRuleActivationTopic(listener); + + verify(topic, times(1)).addMessageListener(any()); + } + private static HazelcastMember newHzMember(int port, int... otherPorts) { return new HazelcastMemberBuilder(JoinConfigurationType.TCP_IP) .setProcessId(ProcessId.COMPUTE_ENGINE) |