lbownik commented on code in PR #4112:
URL: https://github.com/apache/netbeans/pull/4112#discussion_r1043325497


##########
platform/openide.util/test/unit/src/org/openide/util/TaskTest.java:
##########
@@ -21,25 +21,184 @@
 
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.junit.Test;
 import org.netbeans.junit.Log;
-import org.netbeans.junit.NbTestCase;
-import org.openide.util.Exceptions;
-import org.openide.util.Task;
+import static java.lang.System.currentTimeMillis;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import org.junit.Ignore;
 
-public class TaskTest extends NbTestCase {
-    private Logger LOG;
 
-    public TaskTest(String testName) {
-        super(testName);
+public class TaskTest {
+    private static final Logger LOG = 
Logger.getLogger("org.openide.util.TaskTest");
+
+    private volatile boolean runHasBeenExecuted = false;
+    private volatile Task executedListenerTask = null;
+
+    
//--------------------------------------------------------------------------
+    private static void assertFinished(final Task task) {
+
+        assertTrue(task.isFinished());
+    }
+
+    
//--------------------------------------------------------------------------
+    private static void assertWaitFinishedReturnsImmediately(final Task task) {
+
+        final long begin = currentTimeMillis();
+        task.waitFinished();
+        final long duration = currentTimeMillis() - begin;
+        // shorter than 1 milisecond
+        assertEquals("The Task.waitFinished() took longer than milisecond. "
+                + "This is not neseserily a bug.", 0, duration);

Review Comment:
   I changed currentTimeMillis() to nanoTime()  in 
https://github.com/apache/netbeans/pull/4112/commits/31c8e4c8119ede109d0b37499d39684ebda61458
 and expanded wait time to 10 miliseconds in both tests.
   10 miliseconds steel feel "immediately" from users perspective and the false 
negative rate should be really low.
   now these two tests, though imperfect guard us from "catastrophic" failures 
(like infinite wait); alternatively we can skip testing these use cases 
entirely;
   
   if You accept, I'll squash it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to