Files
openide/platform/util-rt/test/com/intellij/execution/rmi/IdeaWatchdogImplTest.java
Dmitry Kichinsky 4c5670a690 IDEA-313450 IdeaWatchdogImpl tests
GitOrigin-RevId: c8e65791d19ffa53f76d3b8ce23d1c1fd3f7bde7
2023-02-17 23:22:17 +00:00

36 lines
1.3 KiB
Java

// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution.rmi;
import junit.framework.TestCase;
public class IdeaWatchdogImplTest extends TestCase {
public void testNewlyCreatedWatchdogIsAlive() {
IdeaWatchdogImpl watchdog = new IdeaWatchdogImpl();
assertTrue(watchdog.isAlive());
assertTrue(watchdog.ping());
assertTrue(watchdog.isAlive());
}
public void testKillingWatchdog() {
IdeaWatchdogImpl watchdog = new IdeaWatchdogImpl();
assertTrue(watchdog.isAlive());
assertTrue(watchdog.ping());
assertTrue(watchdog.isAlive());
assertTrue(watchdog.die());
assertFalse(watchdog.die()); // can only be killed once
assertFalse(watchdog.isAlive()); // is not alive anymore
assertFalse(watchdog.ping()); // cannot be pinged anymore
assertFalse(watchdog.isAlive()); // still is not alive
}
public void testWatchdogWaitTimeout() throws InterruptedException {
long waitTimeout = 5;
IdeaWatchdogImpl watchdog = new IdeaWatchdogImpl(waitTimeout, waitTimeout);
assertTrue(watchdog.isAlive());
Thread.sleep(2 * waitTimeout);
assertFalse(watchdog.isAlive());
assertFalse(watchdog.ping()); // cannot be pinged anymore
assertFalse(watchdog.isAlive()); // still is not alive
}
}