@Test
  public void testHelixNotifier() throws Exception {
    // Subscribe a topic and publish a message for the topic
    helixNotifier.subscribe(refTopics.get(0), listeners.get(0));
    latch0.set(new CountDownLatch(1));
    helixNotifier.publish(refTopics.get(0), refMessages.get(0));
    awaitLatchOrTimeout(latch0.get(), LATCH_TIMEOUT_MS);
    assertEquals("Received topic is different from expected", refTopics.get(0), receivedTopicsByListener0.get(0));
    assertEquals("Received message is different from expected", refMessages.get(0), receivedMessagesByListener0.get(0));

    // publish a different message for the topic
    resetListeners();
    latch0.set(new CountDownLatch(1));
    helixNotifier.publish(refTopics.get(0), refMessages.get(1));
    awaitLatchOrTimeout(latch0.get(), LATCH_TIMEOUT_MS);
    assertEquals("Received topic is different from expected", refTopics.get(0), receivedTopicsByListener0.get(0));
    assertEquals("Received message is different from expected", refMessages.get(1), receivedMessagesByListener0.get(0));

    // Subscribe to a different topic and publish message for that topic
    resetListeners();
    helixNotifier.subscribe(refTopics.get(1), listeners.get(0));
    latch0.set(new CountDownLatch(1));
    helixNotifier.publish(refTopics.get(1), refMessages.get(0));
    awaitLatchOrTimeout(latch0.get(), LATCH_TIMEOUT_MS);
    assertEquals("Received topic is different from expected", refTopics.get(1), receivedTopicsByListener0.get(0));
    assertEquals("Received message is different from expected", refMessages.get(0), receivedMessagesByListener0.get(0));
  }
Tests normal operations using a single {@link HelixNotifier} and two {@link TopicListener}s.
@throws Exception Any unexpected exceptions.
ambry-commons/src/test/java/com/github/ambry/commons/HelixNotifierTest.java