@Test
  public void registerListenerWithSignal() {
    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();

    SignalListener mockSigIntListener = mock(SignalListener.class, "SIGINT");
    SignalListener mockSigIntTermListener = mock(SignalListener.class, "SIGINT + SIGTERM");

    assertThat(signalHandler.isListening(mockSigIntListener)).isFalse();
    assertThat(signalHandler.isListening(mockSigIntTermListener)).isFalse();

    for (Signal signal : Signal.values()) {
      assertThat(signalHandler.hasListeners(signal)).isFalse();
      assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
      assertThat(signalHandler.isListening(mockSigIntTermListener, signal)).isFalse();
    }

    assertThat(signalHandler.registerListener(mockSigIntListener, Signal.SIGINT)).isTrue();
    assertThat(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGINT)).isTrue();
    assertThat(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGTERM)).isTrue();
    assertThat(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGINT)).isFalse();
    assertThat(signalHandler.isListening(mockSigIntListener)).isTrue();
    assertThat(signalHandler.isListening(mockSigIntTermListener)).isTrue();

    Set<Signal> expectedSignals = CollectionUtils.asSet(Signal.SIGINT, Signal.SIGTERM);

    for (Signal signal : Signal.values()) {
      assertThat(signalHandler.hasListeners(signal)).isEqualTo(expectedSignals.contains(signal));
      switch (signal) {
        case SIGINT:
          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isTrue();
          assertThat(signalHandler.isListening(mockSigIntTermListener, signal)).isTrue();
          break;
        case SIGTERM:
          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
          assertThat(signalHandler.isListening(mockSigIntTermListener, signal)).isTrue();
          break;
        default:
          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
          assertThat(signalHandler.isListening(mockSigIntTermListener, signal)).isFalse();
      }
    }
  }
Unit tests for {@link AbstractSignalNotificationHandler}.

@since GemFire 7.0
geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerTest.java