mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fail test in case of exception
This commit is contained in:
+8
-4
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -138,8 +139,8 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
|
||||
assertTrue(indicator.isCanceled());
|
||||
}
|
||||
|
||||
public void testThereIsNoDelayBetweenIndicatorCancelAndProgressManagerCheckCanceled() {
|
||||
for (int i=0; i<1000;i++) {
|
||||
public void testThereIsNoDelayBetweenIndicatorCancelAndProgressManagerCheckCanceled() throws Throwable {
|
||||
for (int i=0; i<100;i++) {
|
||||
final ProgressIndicatorBase indicator = new ProgressIndicatorBase();
|
||||
List<Thread> threads = ContainerUtil.map(Collections.nCopies(10, ""), new Function<String, Thread>() {
|
||||
@Override
|
||||
@@ -151,13 +152,16 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean canceled = indicator.isCanceled();
|
||||
Thread.sleep(new Random().nextInt(100));
|
||||
indicator.cancel();
|
||||
ProgressManager.checkCanceled();
|
||||
fail("checkCanceled() must know about canceled indicator even from different thread");
|
||||
}
|
||||
catch (ProcessCanceledException ignored) {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
}, indicator);
|
||||
}
|
||||
@@ -177,7 +181,7 @@ public class ProgressIndicatorTest extends LightPlatformTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (exception != null) throw exception;
|
||||
}
|
||||
|
||||
private volatile boolean checkCanceledCalled;
|
||||
|
||||
Reference in New Issue
Block a user