geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [01/14] geode git commit: GEODE-3413: overhaul launcher and process classes and tests
Date Fri, 11 Aug 2017 17:11:59 GMT
Repository: geode
Updated Branches:
  refs/heads/develop beebb65a3 -> 894f3ee71


http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
new file mode 100644
index 0000000..d26f73e
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePid.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.internal.process.lang;
+
+import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.geode.internal.util.StopWatch;
+
+/**
+ * Finds unused pids for use in tests.
+ */
+public class AvailablePid {
+
+  static final int LOWER_BOUND = 1;
+  static final int UPPER_BOUND = 64000;
+  static final int DEFAULT_TIMEOUT_MILLIS = 60 * 1000;
+
+  private final Random random;
+  private final int timeoutMillis;
+
+  /**
+   * Construct with no seed and default timeout of 1 minute.
+   */
+  public AvailablePid() {
+    this(new Random(), DEFAULT_TIMEOUT_MILLIS);
+  }
+
+  /**
+   * Construct with specified seed and timeout.
+   */
+  public AvailablePid(final long seed, final int timeoutMillis) {
+    this(new Random(seed), timeoutMillis);
+  }
+
+  /**
+   * Construct with specified Random implementation.
+   */
+  public AvailablePid(final Random random, final int timeoutMillis) {
+    this.random = random;
+    this.timeoutMillis = timeoutMillis;
+  }
+
+  /**
+   * Returns specified pid if it's unused. Else returns randomly unused pid.
+   */
+  public int findAvailablePid(final int pid) throws TimeoutException {
+    if (isProcessAlive(pid)) {
+      return pid;
+    }
+    return findAvailablePid();
+  }
+
+  /**
+   * Returns randomly unused pid.
+   */
+  public int findAvailablePid() throws TimeoutException {
+    StopWatch stopWatch = new StopWatch(true);
+    int pid = random();
+    while (isProcessAlive(pid)) {
+      if (stopWatch.elapsedTimeMillis() > timeoutMillis) {
+        throw new TimeoutException(
+            "Failed to find available pid within " + timeoutMillis + " millis.");
+      }
+      pid = random();
+    }
+    return pid;
+  }
+
+  /**
+   * Returns specified number of randomly unused pids.
+   */
+  public int[] findAvailablePids(final int number) throws TimeoutException {
+    Set<Integer> pids = new HashSet<>();
+    while (pids.size() < number) {
+      int pid = new AvailablePid().findAvailablePid();
+      if (!pids.contains(pid)) {
+        pids.add(pid);
+      }
+    }
+    return Arrays.stream(pids.toArray(new Integer[0])).mapToInt(Integer::intValue).toArray();
+  }
+
+  private int random() {
+    return random.nextInt(UPPER_BOUND - LOWER_BOUND);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
new file mode 100644
index 0000000..00beb67
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.internal.process.lang;
+
+import static org.apache.geode.internal.process.ProcessUtils.identifyPid;
+import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+import static org.apache.geode.internal.process.lang.AvailablePid.DEFAULT_TIMEOUT_MILLIS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for {@link AvailablePid}.
+ */
+@Category(UnitTest.class)
+public class AvailablePidTest {
+
+  private AvailablePid availablePid;
+
+  @Before
+  public void before() throws Exception {
+    availablePid = new AvailablePid();
+  }
+
+  @Test
+  public void lowerBoundShouldBeLegalPid() throws Exception {
+    assertThat(isProcessAlive(AvailablePid.LOWER_BOUND)).isIn(true, false);
+  }
+
+  @Test
+  public void upperBoundShouldBeLegalPid() throws Exception {
+    assertThat(isProcessAlive(AvailablePid.UPPER_BOUND)).isIn(true, false);
+  }
+
+  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  public void findAvailablePidShouldNotReturnLocalPid() throws Exception {
+    int pid = availablePid.findAvailablePid();
+
+    assertThat(pid).isNotEqualTo(identifyPid());
+  }
+
+  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  public void findAvailablePidShouldNotReturnLivePid() throws Exception {
+    int pid = availablePid.findAvailablePid();
+
+    assertThat(isProcessAlive(pid)).isFalse();
+  }
+
+  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  public void findAvailablePidShouldReturnRandomPid() throws Exception {
+    Random random = spy(new Random());
+    availablePid = new AvailablePid(random, DEFAULT_TIMEOUT_MILLIS);
+
+    availablePid.findAvailablePid();
+
+    verify(random, atLeastOnce()).nextInt(anyInt());
+  }
+
+  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  public void findAvailablePidsShouldReturnSpecifiedNumberOfPids() throws Exception {
+    assertThat(availablePid.findAvailablePids(1)).hasSize(1);
+    assertThat(availablePid.findAvailablePids(2)).hasSize(2);
+    assertThat(availablePid.findAvailablePids(3)).hasSize(3);
+    assertThat(availablePid.findAvailablePids(5)).hasSize(5);
+    assertThat(availablePid.findAvailablePids(8)).hasSize(8);
+  }
+
+  @Test(timeout = DEFAULT_TIMEOUT_MILLIS)
+  public void findAvailablePidsShouldReturnNoDuplicatedPids() throws Exception {
+    assertThatNoPidIsDuplicated(availablePid.findAvailablePids(1));
+    assertThatNoPidIsDuplicated(availablePid.findAvailablePids(2));
+    assertThatNoPidIsDuplicated(availablePid.findAvailablePids(3));
+    assertThatNoPidIsDuplicated(availablePid.findAvailablePids(5));
+    assertThatNoPidIsDuplicated(availablePid.findAvailablePids(8));
+  }
+
+  private void assertThatNoPidIsDuplicated(int[] pids) {
+    Set<Integer> pidSet = Arrays.stream(pids).boxed().collect(Collectors.toSet());
+    assertThat(pidSet).hasSize(pids.length);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/mbean/Process.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/mbean/Process.java b/geode-core/src/test/java/org/apache/geode/internal/process/mbean/Process.java
deleted file mode 100644
index 597da94..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/process/mbean/Process.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.process.mbean;
-
-/**
- * Extracted from LocalProcessControllerDUnitTest.
- * 
- */
-public class Process implements ProcessMBean {
-
-  private final Object object = new Object();
-  private final int pid;
-  private final boolean process;
-  private volatile boolean stop;
-
-  public Process(int pid, boolean process) {
-    this.pid = pid;
-    this.process = process;
-  }
-
-  @Override
-  public int getPid() {
-    return this.pid;
-  }
-
-  public boolean isProcess() {
-    return this.process;
-  }
-
-  @Override
-  public void stop() {
-    synchronized (this.object) {
-      this.stop = true;
-      this.object.notifyAll();
-    }
-  }
-
-  public void waitUntilStopped() throws InterruptedException {
-    synchronized (this.object) {
-      while (!this.stop) {
-        this.object.wait();
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/mbean/ProcessMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/mbean/ProcessMBean.java b/geode-core/src/test/java/org/apache/geode/internal/process/mbean/ProcessMBean.java
deleted file mode 100644
index 6cebaf3..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/process/mbean/ProcessMBean.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.process.mbean;
-
-/**
- * Extracted from LocalProcessControllerDUnitTest.
- * 
- */
-public interface ProcessMBean {
-  public int getPid();
-
-  public boolean isProcess();
-
-  public void stop();
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerJUnitTest.java
deleted file mode 100644
index 1dc6c0d..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerJUnitTest.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.process.signal;
-
-import static org.junit.Assert.*;
-
-import java.util.Set;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.concurrent.Synchroniser;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.util.CollectionUtils;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-/**
- * The AbstractSignalNotificationHandlerJUnitTest class is a test suite of test cases testing the
- * contract and functionality of the AbstractSignalNotificationHandler.
- * </p>
- * 
- * @see org.apache.geode.internal.process.signal.AbstractSignalNotificationHandler
- * @see org.apache.geode.internal.process.signal.Signal
- * @see org.apache.geode.internal.process.signal.SignalEvent
- * @see org.apache.geode.internal.process.signal.SignalListener
- * @see org.jmock.Expectations
- * @see org.jmock.Mockery
- * @see org.junit.Assert
- * @see org.junit.Test
- * @since GemFire 7.0
- */
-@Category(UnitTest.class)
-public class AbstractSignalNotificationHandlerJUnitTest {
-
-  private Mockery mockContext;
-
-  @Before
-  public void setup() {
-    mockContext = new Mockery() {
-      {
-        setImposteriser(ClassImposteriser.INSTANCE);
-        setThreadingPolicy(new Synchroniser());
-      }
-    };
-  }
-
-  @After
-  public void tearDown() {
-    mockContext.assertIsSatisfied();
-    mockContext = null;
-  }
-
-  private AbstractSignalNotificationHandler createSignalNotificationHandler() {
-    return new TestSignalNotificationHandler();
-  }
-
-  @Test
-  public void testAssertNotNullWithNonNullValue() {
-    AbstractSignalNotificationHandler.assertNotNull(new Object(), "TEST");
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testAssertNotNullWithNullValue() {
-    try {
-      AbstractSignalNotificationHandler.assertNotNull(null, "Expected %1$s message!", "test");
-    } catch (NullPointerException expected) {
-      assertEquals("Expected test message!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testAssertStateWithValidState() {
-    AbstractSignalNotificationHandler.assertState(true, "TEST");
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void testAssertStateWithInvalidState() {
-    try {
-      AbstractSignalNotificationHandler.assertState(false, "Expected %1$s message!", "test");
-    } catch (IllegalStateException expected) {
-      assertEquals("Expected test message!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testAssertValidArgumentWithLegalArgument() {
-    AbstractSignalNotificationHandler.assertValidArgument(true, "TEST");
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testAssertValidArgmentWithIllegalArgument() {
-    try {
-      AbstractSignalNotificationHandler.assertValidArgument(false, "Expected %1$s message!",
-          "test");
-    } catch (IllegalArgumentException expected) {
-      assertEquals("Expected test message!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testRegisterListener() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-
-    final SignalListener mockListenerOne = mockContext.mock(SignalListener.class, "SIGALL1");
-    final SignalListener mockListenerTwo = mockContext.mock(SignalListener.class, "SIGALL2");
-
-    assertFalse(signalHandler.isListening(mockListenerOne));
-    assertFalse(signalHandler.isListening(mockListenerTwo));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-      assertFalse(signalHandler.isListening(mockListenerOne, signal));
-      assertFalse(signalHandler.isListening(mockListenerTwo, signal));
-    }
-
-    assertTrue(signalHandler.registerListener(mockListenerOne));
-    assertTrue(signalHandler.registerListener(mockListenerTwo));
-    assertFalse(signalHandler.registerListener(mockListenerTwo));
-    assertTrue(signalHandler.isListening(mockListenerOne));
-    assertTrue(signalHandler.isListening(mockListenerTwo));
-
-    for (final Signal signal : Signal.values()) {
-      assertTrue(signalHandler.hasListeners(signal));
-      assertTrue(signalHandler.isListening(mockListenerOne, signal));
-      assertTrue(signalHandler.isListening(mockListenerTwo, signal));
-    }
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testRegisterListenerWithNullSignalListener() {
-    try {
-      createSignalNotificationHandler().registerListener(null);
-    } catch (NullPointerException expected) {
-      assertEquals("The SignalListener to register, listening for all signals cannot be null!",
-          expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testRegisterListenerWithSignal() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-
-    final SignalListener mockSigIntListener = mockContext.mock(SignalListener.class, "SIGINT");
-    final SignalListener mockSigIntTermListener =
-        mockContext.mock(SignalListener.class, "SIGINT + SIGTERM");
-
-    assertFalse(signalHandler.isListening(mockSigIntListener));
-    assertFalse(signalHandler.isListening(mockSigIntTermListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-      assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-      assertFalse(signalHandler.isListening(mockSigIntTermListener, signal));
-    }
-
-    assertTrue(signalHandler.registerListener(mockSigIntListener, Signal.SIGINT));
-    assertTrue(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGINT));
-    assertTrue(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGTERM));
-    assertFalse(signalHandler.registerListener(mockSigIntTermListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSigIntListener));
-    assertTrue(signalHandler.isListening(mockSigIntTermListener));
-
-    final Set<Signal> expectedSignals = CollectionUtils.asSet(Signal.SIGINT, Signal.SIGTERM);
-
-    for (final Signal signal : Signal.values()) {
-      assertEquals(expectedSignals.contains(signal), signalHandler.hasListeners(signal));
-      switch (signal) {
-        case SIGINT:
-          assertTrue(signalHandler.isListening(mockSigIntListener, signal));
-          assertTrue(signalHandler.isListening(mockSigIntTermListener, signal));
-          break;
-        case SIGTERM:
-          assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-          assertTrue(signalHandler.isListening(mockSigIntTermListener, signal));
-          break;
-        default:
-          assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-          assertFalse(signalHandler.isListening(mockSigIntTermListener, signal));
-      }
-    }
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testRegisterListenerWithNullSignal() {
-    try {
-      createSignalNotificationHandler()
-          .registerListener(mockContext.mock(SignalListener.class, "SIGALL"), null);
-    } catch (NullPointerException expected) {
-      assertEquals("The signal to register the listener for cannot be null!",
-          expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testRegisterListenerWithSignalAndNullSignalListener() {
-    try {
-      createSignalNotificationHandler().registerListener(null, Signal.SIGQUIT);
-    } catch (NullPointerException expected) {
-      assertEquals(String.format(
-          "The SignalListener being registered to listen for '%1$s' signals cannot be null!",
-          Signal.SIGQUIT.getName()), expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testUnregisterListener() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-    final SignalListener mockSignalListener = mockContext.mock(SignalListener.class, "SIGALL");
-
-    assertFalse(signalHandler.isListening(mockSignalListener));
-    assertTrue(signalHandler.registerListener(mockSignalListener));
-    assertTrue(signalHandler.isListening(mockSignalListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertTrue(signalHandler.hasListeners(signal));
-    }
-
-    assertTrue(signalHandler.unregisterListener(mockSignalListener));
-    assertFalse(signalHandler.isListening(mockSignalListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-    }
-
-    assertFalse(signalHandler.unregisterListener(mockSignalListener));
-  }
-
-  @Test
-  public void testUnregisterListenerWithSignalListenerAndAllSignals() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-    final SignalListener mockSignalListener = mockContext.mock(SignalListener.class, "SIGALL");
-
-    assertFalse(signalHandler.isListening(mockSignalListener));
-    assertTrue(signalHandler.registerListener(mockSignalListener));
-    assertTrue(signalHandler.isListening(mockSignalListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertTrue(signalHandler.hasListeners(signal));
-      assertTrue(signalHandler.isListening(mockSignalListener, signal));
-      assertTrue(signalHandler.unregisterListener(mockSignalListener, signal));
-      assertFalse(signalHandler.isListening(mockSignalListener, signal));
-      assertFalse(signalHandler.hasListeners(signal));
-    }
-
-    assertFalse(signalHandler.unregisterListener(mockSignalListener));
-  }
-
-  @Test
-  public void testUnregisterListenerWithSignalListenerAndSigint() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-    final SignalListener mockSignalListener = mockContext.mock(SignalListener.class, "SIGALL");
-
-    assertFalse(signalHandler.isListening(mockSignalListener));
-    assertTrue(signalHandler.registerListener(mockSignalListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSignalListener));
-    assertTrue(signalHandler.isListening(mockSignalListener, Signal.SIGINT));
-
-    for (final Signal signal : Signal.values()) {
-      if (!Signal.SIGINT.equals(signal)) {
-        assertFalse(signalHandler.hasListeners(signal));
-        assertFalse(signalHandler.isListening(mockSignalListener, signal));
-      }
-    }
-
-    assertTrue(signalHandler.isListening(mockSignalListener));
-    assertTrue(signalHandler.isListening(mockSignalListener, Signal.SIGINT));
-    assertTrue(signalHandler.unregisterListener(mockSignalListener, Signal.SIGINT));
-    assertFalse(signalHandler.isListening(mockSignalListener, Signal.SIGINT));
-    assertFalse(signalHandler.isListening(mockSignalListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-    }
-
-    assertFalse(signalHandler.unregisterListener(mockSignalListener));
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testUnregisterListenerWithSignalListenerAndNullSignal() {
-    try {
-      createSignalNotificationHandler()
-          .unregisterListener(mockContext.mock(SignalListener.class, "SIGALL"), null);
-    } catch (NullPointerException expected) {
-      assertEquals("The signal from which to unregister the listener cannot be null!",
-          expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testUnregisterListeners() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-
-    final SignalListener mockSigQuitListener = mockContext.mock(SignalListener.class, "SIGQUIT");
-    final SignalListener mockSigTermListener = mockContext.mock(SignalListener.class, "SIGTERM");
-    final SignalListener mockSigTermQuitListener =
-        mockContext.mock(SignalListener.class, "SIGTERM + SIGQUIT");
-
-    assertFalse(signalHandler.isListening(mockSigQuitListener));
-    assertFalse(signalHandler.isListening(mockSigTermListener));
-    assertFalse(signalHandler.isListening(mockSigTermQuitListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-    }
-
-    // register sigquit and sigterm listeners...
-    assertTrue(signalHandler.registerListener(mockSigQuitListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.registerListener(mockSigTermListener, Signal.SIGTERM));
-    assertTrue(signalHandler.registerListener(mockSigTermQuitListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.registerListener(mockSigTermQuitListener, Signal.SIGTERM));
-
-    assertTrue(signalHandler.isListening(mockSigQuitListener));
-    assertFalse(signalHandler.isListening(mockSigQuitListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSigQuitListener, Signal.SIGQUIT));
-    assertFalse(signalHandler.isListening(mockSigQuitListener, Signal.SIGTERM));
-    assertTrue(signalHandler.isListening(mockSigTermListener));
-    assertFalse(signalHandler.isListening(mockSigTermListener, Signal.SIGINT));
-    assertFalse(signalHandler.isListening(mockSigTermListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.isListening(mockSigTermListener, Signal.SIGTERM));
-    assertTrue(signalHandler.isListening(mockSigTermQuitListener));
-    assertFalse(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGTERM));
-    assertFalse(signalHandler.hasListeners(Signal.SIGINT));
-    assertTrue(signalHandler.hasListeners(Signal.SIGQUIT));
-    assertTrue(signalHandler.hasListeners(Signal.SIGTERM));
-
-    // unregister all sigterm listeners...
-    assertTrue(signalHandler.unregisterListeners(Signal.SIGTERM));
-
-    assertTrue(signalHandler.isListening(mockSigQuitListener));
-    assertFalse(signalHandler.isListening(mockSigQuitListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSigQuitListener, Signal.SIGQUIT));
-    assertFalse(signalHandler.isListening(mockSigQuitListener, Signal.SIGTERM));
-    assertFalse(signalHandler.isListening(mockSigTermListener));
-    assertFalse(signalHandler.isListening(mockSigTermListener, Signal.SIGINT));
-    assertFalse(signalHandler.isListening(mockSigTermListener, Signal.SIGQUIT));
-    assertFalse(signalHandler.isListening(mockSigTermListener, Signal.SIGTERM));
-    assertTrue(signalHandler.isListening(mockSigTermQuitListener));
-    assertFalse(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGINT));
-    assertTrue(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGQUIT));
-    assertFalse(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGTERM));
-    assertFalse(signalHandler.hasListeners(Signal.SIGINT));
-    assertTrue(signalHandler.hasListeners(Signal.SIGQUIT));
-    assertFalse(signalHandler.hasListeners(Signal.SIGTERM));
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testUnregisterListenersWithNullSignal() {
-    try {
-      createSignalNotificationHandler().unregisterListeners(null);
-    } catch (NullPointerException expected) {
-      assertEquals("The signal from which to unregister all listeners cannot be null!",
-          expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testNotifyListeners() {
-    final AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
-
-    final SignalListener mockSigAllListener = mockContext.mock(SignalListener.class, "SIGALL");
-    final SignalListener mockSigIntListener = mockContext.mock(SignalListener.class, "SIGINT");
-    final SignalListener mockSigQuitListener = mockContext.mock(SignalListener.class, "SIGQUIT");
-    final SignalListener mockSigQuitTermListener =
-        mockContext.mock(SignalListener.class, "SIGQUIT + SIGTERM");
-
-    final SignalEvent sigintEvent = new SignalEvent(this, Signal.SIGINT);
-    final SignalEvent sigioEvent = new SignalEvent(this, Signal.SIGIO);
-    final SignalEvent sigquitEvent = new SignalEvent(this, Signal.SIGQUIT);
-    final SignalEvent sigtermEvent = new SignalEvent(this, Signal.SIGTERM);
-
-    mockContext.checking(new Expectations() {
-      {
-        oneOf(mockSigAllListener).handle(with(equal(sigintEvent)));
-        oneOf(mockSigAllListener).handle(with(equal(sigioEvent)));
-        oneOf(mockSigAllListener).handle(with(equal(sigquitEvent)));
-        oneOf(mockSigAllListener).handle(with(equal(sigtermEvent)));
-        oneOf(mockSigIntListener).handle(with(equal(sigintEvent)));
-        oneOf(mockSigQuitListener).handle(with(equal(sigquitEvent)));
-        oneOf(mockSigQuitTermListener).handle(with(equal(sigquitEvent)));
-        oneOf(mockSigQuitTermListener).handle(with(equal(sigtermEvent)));
-      }
-    });
-
-    assertFalse(signalHandler.isListening(mockSigAllListener));
-    assertFalse(signalHandler.isListening(mockSigIntListener));
-    assertFalse(signalHandler.isListening(mockSigQuitListener));
-    assertFalse(signalHandler.isListening(mockSigQuitTermListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertFalse(signalHandler.hasListeners(signal));
-    }
-
-    assertTrue(signalHandler.registerListener(mockSigAllListener));
-    assertTrue(signalHandler.registerListener(mockSigIntListener, Signal.SIGINT));
-    assertTrue(signalHandler.registerListener(mockSigQuitListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.registerListener(mockSigQuitTermListener, Signal.SIGQUIT));
-    assertTrue(signalHandler.registerListener(mockSigQuitTermListener, Signal.SIGTERM));
-    assertTrue(signalHandler.isListening(mockSigAllListener));
-    assertTrue(signalHandler.isListening(mockSigIntListener));
-    assertTrue(signalHandler.isListening(mockSigQuitListener));
-    assertTrue(signalHandler.isListening(mockSigQuitTermListener));
-
-    for (final Signal signal : Signal.values()) {
-      assertTrue(signalHandler.hasListeners(signal));
-      assertTrue(signalHandler.isListening(mockSigAllListener, signal));
-
-      switch (signal) {
-        case SIGINT:
-          assertTrue(signalHandler.isListening(mockSigIntListener, signal));
-          assertFalse(signalHandler.isListening(mockSigQuitListener, signal));
-          assertFalse(signalHandler.isListening(mockSigQuitTermListener, signal));
-          break;
-        case SIGQUIT:
-          assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-          assertTrue(signalHandler.isListening(mockSigQuitListener, signal));
-          assertTrue(signalHandler.isListening(mockSigQuitTermListener, signal));
-          break;
-        case SIGTERM:
-          assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-          assertFalse(signalHandler.isListening(mockSigQuitListener, signal));
-          assertTrue(signalHandler.isListening(mockSigQuitTermListener, signal));
-          break;
-        default:
-          assertFalse(signalHandler.isListening(mockSigIntListener, signal));
-          assertFalse(signalHandler.isListening(mockSigQuitListener, signal));
-          assertFalse(signalHandler.isListening(mockSigQuitTermListener, signal));
-      }
-    }
-
-    signalHandler.notifyListeners(sigintEvent);
-    signalHandler.notifyListeners(sigioEvent);
-    signalHandler.notifyListeners(sigquitEvent);
-    signalHandler.notifyListeners(sigtermEvent);
-
-    // notification verification handled by mockContext.assertIsSatisfied in tearDown()
-  }
-
-  private static class TestSignalNotificationHandler extends AbstractSignalNotificationHandler {
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerTest.java
new file mode 100644
index 0000000..d1f422d
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/signal/AbstractSignalNotificationHandlerTest.java
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.process.signal;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.internal.util.CollectionUtils;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for {@link AbstractSignalNotificationHandler}.
+ *
+ * @since GemFire 7.0
+ */
+@Category(UnitTest.class)
+public class AbstractSignalNotificationHandlerTest {
+
+  @Test
+  public void assertNotNullWithNonNullValueDoesNotThrow() {
+    AbstractSignalNotificationHandler.assertNotNull(new Object(), "TEST");
+  }
+
+  @Test
+  public void assertNotNullWithNullValueThrowsNullPointerException() {
+    assertThatThrownBy(() -> AbstractSignalNotificationHandler.assertNotNull(null,
+        "Expected %1$s message!", "test")).isInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void assertStateWithValidStateDoesNotThrow() {
+    AbstractSignalNotificationHandler.assertState(true, "TEST");
+  }
+
+  @Test
+  public void assertStateWithInvalidStateThrowsIllegalStateException() {
+    assertThatThrownBy(() -> AbstractSignalNotificationHandler.assertState(false,
+        "Expected %1$s message!", "test")).isInstanceOf(IllegalStateException.class);
+  }
+
+  @Test
+  public void assertValidArgumentWithLegalArgumentDoesNotThrow() {
+    AbstractSignalNotificationHandler.assertValidArgument(true, "TEST");
+  }
+
+  @Test
+  public void assertValidArgumentWithIllegalArgumentThrowsIllegalArgumentException() {
+    assertThatThrownBy(() -> AbstractSignalNotificationHandler.assertValidArgument(false,
+        "Expected %1$s message!", "test")).isInstanceOf(IllegalArgumentException.class);
+  }
+
+  @Test
+  public void registerListener() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+
+    SignalListener mockListenerOne = mock(SignalListener.class, "SIGALL1");
+    SignalListener mockListenerTwo = mock(SignalListener.class, "SIGALL2");
+
+    assertThat(signalHandler.isListening(mockListenerOne)).isFalse();
+    assertThat(signalHandler.isListening(mockListenerTwo)).isFalse();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+      assertThat(signalHandler.isListening(mockListenerOne, signal)).isFalse();
+      assertThat(signalHandler.isListening(mockListenerTwo, signal)).isFalse();
+    }
+
+    assertThat(signalHandler.registerListener(mockListenerOne)).isTrue();
+    assertThat(signalHandler.registerListener(mockListenerTwo)).isTrue();
+    assertThat(signalHandler.registerListener(mockListenerTwo)).isFalse();
+    assertThat(signalHandler.isListening(mockListenerOne)).isTrue();
+    assertThat(signalHandler.isListening(mockListenerTwo)).isTrue();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isTrue();
+      assertThat(signalHandler.isListening(mockListenerOne, signal)).isTrue();
+      assertThat(signalHandler.isListening(mockListenerTwo, signal)).isTrue();
+    }
+  }
+
+  @Test
+  public void registerListenerWithNullSignalListenerThrowsNullPointerException() {
+    assertThatThrownBy(() -> createSignalNotificationHandler().registerListener(null))
+        .isInstanceOf(NullPointerException.class)
+        .hasMessage("The SignalListener to register, listening for all signals cannot be null!");
+  }
+
+  @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();
+      }
+    }
+  }
+
+  @Test
+  public void registerListenerWithNullSignalThrowsNullPointerException() {
+    assertThatThrownBy(() -> createSignalNotificationHandler()
+        .registerListener(mock(SignalListener.class, "SIGALL"), null))
+            .isInstanceOf(NullPointerException.class)
+            .hasMessage("The signal to register the listener for cannot be null!");
+  }
+
+  @Test
+  public void registerListenerWithSignalAndNullSignalListenerThrowsNullPointerException() {
+    assertThatThrownBy(
+        () -> createSignalNotificationHandler().registerListener(null, Signal.SIGQUIT))
+            .isInstanceOf(NullPointerException.class)
+            .hasMessage(signalListenerForSignalCannotBeNullErrorMessage(Signal.SIGQUIT));
+  }
+
+  @Test
+  public void unregisterListener() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+    SignalListener mockSignalListener = mock(SignalListener.class, "SIGALL");
+
+    assertThat(signalHandler.isListening(mockSignalListener)).isFalse();
+    assertThat(signalHandler.registerListener(mockSignalListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener)).isTrue();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isTrue();
+    }
+
+    assertThat(signalHandler.unregisterListener(mockSignalListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener)).isFalse();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+    }
+
+    assertThat(signalHandler.unregisterListener(mockSignalListener)).isFalse();
+  }
+
+  @Test
+  public void unregisterListenerWithSignalListenerAndAllSignals() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+    SignalListener mockSignalListener = mock(SignalListener.class, "SIGALL");
+
+    assertThat(signalHandler.isListening(mockSignalListener)).isFalse();
+    assertThat(signalHandler.registerListener(mockSignalListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener)).isTrue();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isTrue();
+      assertThat(signalHandler.isListening(mockSignalListener, signal)).isTrue();
+      assertThat(signalHandler.unregisterListener(mockSignalListener, signal)).isTrue();
+      assertThat(signalHandler.isListening(mockSignalListener, signal)).isFalse();
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+    }
+
+    assertThat(signalHandler.unregisterListener(mockSignalListener)).isFalse();
+  }
+
+  @Test
+  public void unregisterListenerWithSignalListenerAndSigint() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+    SignalListener mockSignalListener = mock(SignalListener.class, "SIGALL");
+
+    assertThat(signalHandler.isListening(mockSignalListener)).isFalse();
+    assertThat(signalHandler.registerListener(mockSignalListener, Signal.SIGINT)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener, Signal.SIGINT)).isTrue();
+
+    for (Signal signal : Signal.values()) {
+      if (!Signal.SIGINT.equals(signal)) {
+        assertThat(signalHandler.hasListeners(signal)).isFalse();
+        assertThat(signalHandler.isListening(mockSignalListener, signal)).isFalse();
+      }
+    }
+
+    assertThat(signalHandler.isListening(mockSignalListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener, Signal.SIGINT)).isTrue();
+    assertThat(signalHandler.unregisterListener(mockSignalListener, Signal.SIGINT)).isTrue();
+    assertThat(signalHandler.isListening(mockSignalListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSignalListener)).isFalse();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+    }
+
+    assertThat(signalHandler.unregisterListener(mockSignalListener)).isFalse();
+  }
+
+  @Test
+  public void unregisterListenerWithSignalListenerAndNullSignalThrowsNullPointerException() {
+    assertThatThrownBy(() -> createSignalNotificationHandler()
+        .unregisterListener(mock(SignalListener.class, "SIGALL"), null))
+            .isInstanceOf(NullPointerException.class)
+            .hasMessage("The signal from which to unregister the listener cannot be null!");
+  }
+
+  @Test
+  public void unregisterListeners() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+
+    SignalListener mockSigQuitListener = mock(SignalListener.class, "SIGQUIT");
+    SignalListener mockSigTermListener = mock(SignalListener.class, "SIGTERM");
+    SignalListener mockSigTermQuitListener = mock(SignalListener.class, "SIGTERM + SIGQUIT");
+
+    assertThat(signalHandler.isListening(mockSigQuitListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener)).isFalse();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+    }
+
+    // register sigquit and sigterm listeners...
+    assertThat(signalHandler.registerListener(mockSigQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigTermListener, Signal.SIGTERM)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigTermQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigTermQuitListener, Signal.SIGTERM)).isTrue();
+
+    assertThat(signalHandler.isListening(mockSigQuitListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGTERM)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGQUIT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGTERM)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGTERM)).isTrue();
+    assertThat(signalHandler.hasListeners(Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.hasListeners(Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.hasListeners(Signal.SIGTERM)).isTrue();
+
+    // unregister all sigterm listeners...
+    assertThat(signalHandler.unregisterListeners(Signal.SIGTERM)).isTrue();
+
+    assertThat(signalHandler.isListening(mockSigQuitListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitListener, Signal.SIGTERM)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGQUIT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermListener, Signal.SIGTERM)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.isListening(mockSigTermQuitListener, Signal.SIGTERM)).isFalse();
+    assertThat(signalHandler.hasListeners(Signal.SIGINT)).isFalse();
+    assertThat(signalHandler.hasListeners(Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.hasListeners(Signal.SIGTERM)).isFalse();
+  }
+
+  @Test
+  public void unregisterListenersWithNullSignalThrowsNullPointerException() {
+    assertThatThrownBy(() -> createSignalNotificationHandler().unregisterListeners(null))
+        .isInstanceOf(NullPointerException.class)
+        .hasMessage("The signal from which to unregister all listeners cannot be null!");
+  }
+
+  @Test
+  public void notifyListeners() {
+    AbstractSignalNotificationHandler signalHandler = createSignalNotificationHandler();
+
+    SignalListener mockSigAllListener = mock(SignalListener.class, "SIGALL");
+    SignalListener mockSigIntListener = mock(SignalListener.class, "SIGINT");
+    SignalListener mockSigQuitListener = mock(SignalListener.class, "SIGQUIT");
+    SignalListener mockSigQuitTermListener = mock(SignalListener.class, "SIGQUIT + SIGTERM");
+
+    SignalEvent sigintEvent = new SignalEvent(this, Signal.SIGINT);
+    SignalEvent sigioEvent = new SignalEvent(this, Signal.SIGIO);
+    SignalEvent sigquitEvent = new SignalEvent(this, Signal.SIGQUIT);
+    SignalEvent sigtermEvent = new SignalEvent(this, Signal.SIGTERM);
+
+    assertThat(signalHandler.isListening(mockSigAllListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigIntListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigQuitListener)).isFalse();
+    assertThat(signalHandler.isListening(mockSigQuitTermListener)).isFalse();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isFalse();
+    }
+
+    assertThat(signalHandler.registerListener(mockSigAllListener)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigIntListener, Signal.SIGINT)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigQuitListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigQuitTermListener, Signal.SIGQUIT)).isTrue();
+    assertThat(signalHandler.registerListener(mockSigQuitTermListener, Signal.SIGTERM)).isTrue();
+    assertThat(signalHandler.isListening(mockSigAllListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigIntListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitListener)).isTrue();
+    assertThat(signalHandler.isListening(mockSigQuitTermListener)).isTrue();
+
+    for (Signal signal : Signal.values()) {
+      assertThat(signalHandler.hasListeners(signal)).isTrue();
+      assertThat(signalHandler.isListening(mockSigAllListener, signal)).isTrue();
+
+      switch (signal) {
+        case SIGINT:
+          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isTrue();
+          assertThat(signalHandler.isListening(mockSigQuitListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitTermListener, signal)).isFalse();
+          break;
+        case SIGQUIT:
+          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitListener, signal)).isTrue();
+          assertThat(signalHandler.isListening(mockSigQuitTermListener, signal)).isTrue();
+          break;
+        case SIGTERM:
+          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitTermListener, signal)).isTrue();
+          break;
+        default:
+          assertThat(signalHandler.isListening(mockSigIntListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitListener, signal)).isFalse();
+          assertThat(signalHandler.isListening(mockSigQuitTermListener, signal)).isFalse();
+      }
+    }
+
+    signalHandler.notifyListeners(sigintEvent);
+    signalHandler.notifyListeners(sigioEvent);
+    signalHandler.notifyListeners(sigquitEvent);
+    signalHandler.notifyListeners(sigtermEvent);
+
+    verify(mockSigAllListener, times(1)).handle(eq(sigintEvent));
+    verify(mockSigAllListener, times(1)).handle(eq(sigioEvent));
+    verify(mockSigAllListener, times(1)).handle(eq(sigquitEvent));
+    verify(mockSigAllListener, times(1)).handle(eq(sigtermEvent));
+
+    verify(mockSigIntListener, times(1)).handle(eq(sigintEvent));
+
+    verify(mockSigQuitListener, times(1)).handle(eq(sigquitEvent));
+
+    verify(mockSigQuitTermListener, times(1)).handle(eq(sigquitEvent));
+    verify(mockSigQuitTermListener, times(1)).handle(eq(sigtermEvent));
+  }
+
+  private String signalListenerForSignalCannotBeNullErrorMessage(Signal signal) {
+    return String.format(
+        "The SignalListener being registered to listen for '%1$s' signals cannot be null!",
+        signal.getName());
+  }
+
+  private AbstractSignalNotificationHandler createSignalNotificationHandler() {
+    return new TestSignalNotificationHandler();
+  }
+
+  private static class TestSignalNotificationHandler extends AbstractSignalNotificationHandler {
+    // nothing here
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/resources/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider b/geode-core/src/test/resources/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider
index 5dc9077..b87b276 100644
--- a/geode-core/src/test/resources/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider
+++ b/geode-core/src/test/resources/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider
@@ -1 +1 @@
-org.apache.geode.distributed.MockServerLauncherCacheProvider
\ No newline at end of file
+org.apache.geode.distributed.TestServerLauncherCacheProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/894f3ee7/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index 743a8c2..9044109 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -201,6 +201,7 @@ org/apache/geode/cache/util/Gateway$OrderPolicy,false
 org/apache/geode/cache/wan/GatewaySender$OrderPolicy,false
 org/apache/geode/compression/CompressionException,true,4118639654597191235
 org/apache/geode/compression/SnappyCompressor,true,496609875302446099
+org/apache/geode/config/internal/ClusterConfigurationNotAvailableException,true,771319836094239284
 org/apache/geode/distributed/AbstractLauncher$Status,false,description:java/lang/String
 org/apache/geode/distributed/DistributedSystemDisconnectedException,true,-2484849299224086250
 org/apache/geode/distributed/FutureCancelledException,true,-4599338440381989844
@@ -249,7 +250,6 @@ org/apache/geode/internal/SystemAdmin$CombinedResources,false
 org/apache/geode/internal/admin/CompoundEntrySnapshot,true,5776382582897895718,allUserAttributes:java/util/Set,allValues:java/util/Set,hitRatio:float,hitRatioSum:double,hitResponders:long,lastAccessTime:long,lastModifiedTime:long,name:java/lang/Object,numHits:long,numMisses:long
 org/apache/geode/internal/admin/CompoundRegionSnapshot,true,6295026394298398004,allCacheLoaders:java/util/Set,allCacheWriters:java/util/Set,allCapControllers:java/util/Set,allConcLevels:java/util/Set,allCustomIdle:java/util/HashSet,allCustomTtl:java/util/HashSet,allDataPolicies:java/util/Set,allEntryIdleTimeout:java/util/Set,allEntryTtl:java/util/Set,allInitialCaps:java/util/Set,allKeyConstraints:java/util/Set,allListeners:java/util/Set,allLoadFactors:java/util/Set,allRegionIdleTimeout:java/util/Set,allRegionTtl:java/util/Set,allScopes:java/util/Set,allStatsEnabled:java/util/Set,allUserAttributes:java/util/Set,allValueConstraints:java/util/Set,hitRatio:float,hitRatioSum:double,hitResponders:long,lastAccessTime:long,lastModifiedTime:long,name:java/lang/String,numHits:long,numMisses:long
 org/apache/geode/internal/admin/StatAlert,true,5725457607122449170,definitionId:int,time:java/util/Date,values:java/lang/Number[]
-org/apache/geode/internal/admin/remote/DistributionLocatorId,true,6587390186971937865,bindAddress:java/lang/String,host:java/net/InetAddress,hostnameForClients:java/lang/String,peerLocator:boolean,port:int,serverLocator:boolean
 org/apache/geode/internal/admin/remote/EntryValueNodeImpl,false,fields:org/apache/geode/internal/admin/remote/EntryValueNodeImpl[],name:java/lang/String,primitive:boolean,primitiveVal:java/lang/Object,type:java/lang/String
 org/apache/geode/internal/cache/BucketAdvisor$SetFromMap,true,2454657854757543876,m:java/util/Map
 org/apache/geode/internal/cache/BucketNotFoundException,true,2898657229184289911
@@ -358,6 +358,7 @@ org/apache/geode/internal/concurrent/CompactConcurrentHashSet2,true,724906924676
 org/apache/geode/internal/concurrent/CompactConcurrentHashSet2$Segment,true,2249069246763182397,loadFactor:float
 org/apache/geode/internal/concurrent/ConcurrentHashSet,true,-3338819662572203596,map:java/util/concurrent/ConcurrentHashMap
 org/apache/geode/internal/concurrent/LI,true,-6014738350371493969,className:java/lang/String,identityHashCode:int,lockedStackFrame:java/lang/StackTraceElement
+org/apache/geode/internal/config/ClusterConfigurationNotAvailableException,true,771319836094239284
 org/apache/geode/internal/datasource/AbstractDataSource,false,configProps:org/apache/geode/internal/datasource/ConfiguredDataSourceProperties,isActive:boolean,jdbcDriver:java/lang/String,loginTimeOut:int,password:java/lang/String,serverName:java/lang/String,url:java/lang/String,user:java/lang/String
 org/apache/geode/internal/datasource/AbstractPoolCache,false,INIT_LIMIT:int,MAX_LIMIT:int,activeConnections:int,configProps:org/apache/geode/internal/datasource/ConfiguredDataSourceProperties,connEventListner:java/util/EventListener,expirationTime:int,expiredConns:java/util/List,loginTimeOut:int,sleepTime:long,th:java/lang/Thread,timeOut:int,totalConnections:int
 org/apache/geode/internal/datasource/ConfiguredDataSourceProperties,true,1241739895646314739,connPoolDSClass:java/lang/String,expirationTime:int,initialPoolSize:int,jdbcDriver:java/lang/String,loginTimeOut:int,maxPoolSize:int,mcfClass:java/lang/String,password:java/lang/String,timeOut:int,txnType:java/lang/String,url:java/lang/String,user:java/lang/String,xadsClass:java/lang/String
@@ -540,9 +541,6 @@ org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction,
 org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction,true,1
 org/apache/geode/management/internal/cli/functions/CreateIndexFunction,true,1
 org/apache/geode/management/internal/cli/functions/DataCommandFunction,true,1,optimizeForWrite:boolean
-org/apache/geode/management/internal/cli/functions/DataCommandFunction$SelectExecStep,true,1
-org/apache/geode/management/internal/cli/functions/DataCommandFunction$SelectMoveStep,true,1
-org/apache/geode/management/internal/cli/functions/DataCommandFunction$SelectQuitStep,true,1
 org/apache/geode/management/internal/cli/functions/DeployFunction,true,1
 org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction,false
 org/apache/geode/management/internal/cli/functions/DestroyDiskStoreFunction,true,1
@@ -594,9 +592,6 @@ org/apache/geode/management/internal/cli/functions/UndeployFunction,true,1
 org/apache/geode/management/internal/cli/functions/UnregisterFunction,true,1
 org/apache/geode/management/internal/cli/functions/UserFunctionExecution,true,1
 org/apache/geode/management/internal/cli/json/GfJsonException,true,36449998984143318
-org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper$RemoteStep,false,commandArguments:java/lang/Object[],name:java/lang/String
-org/apache/geode/management/internal/cli/multistep/CLIMultiStepHelper$StepExecutionException,true,1,message:java/lang/String
-org/apache/geode/management/internal/cli/multistep/CLIStepExecption,false,result:org/apache/geode/management/cli/Result
 org/apache/geode/management/internal/cli/result/CommandResultException,true,1,result:org/apache/geode/management/cli/Result
 org/apache/geode/management/internal/cli/result/ResultDataException,true,3851919811942980944
 org/apache/geode/management/internal/cli/result/TableBuilder$Align,false


Mime
View raw message