fail test in case of exception

This commit is contained in:
Alexey Kudravtsev
2014-09-16 15:27:15 +04:00
parent 759f26454a
commit 7bc909a0d0
@@ -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;