mbien commented on code in PR #4112:
URL: https://github.com/apache/netbeans/pull/4112#discussion_r1043198002
##########
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:
at the very least:
* use `nanoTime`
* allow a delta of 1-2 ms
Most tests should have enough heap to hopefully not trigger GC in situations
like this (which would cause failure too).
--
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