make test run in seconds instead of minutes

This commit is contained in:
Alexey Kudravtsev
2016-05-26 12:26:15 +03:00
parent 135c418cad
commit 3d8ac80912
@@ -54,7 +54,7 @@ public class AlarmTest extends PlatformTestCase {
}
private static void assertRequestsExecuteSequentially(@NotNull Alarm alarm) throws InterruptedException, ExecutionException, TimeoutException {
int N = 100000;
int N = 10000;
StringBuffer log = new StringBuffer(N*4);
StringBuilder expected = new StringBuilder(N * 4);
@@ -87,14 +87,13 @@ public class AlarmTest extends PlatformTestCase {
AtomicInteger executed = new AtomicInteger();
int N = 100000;
for (int i = 0; i < N; i++) {
alarm.addRequest(executed::incrementAndGet, 100);
alarm.addRequest(executed::incrementAndGet, 10);
}
while (executed.get() != N) {
UIUtil.dispatchAllInvocationEvents();
}
Map<Thread, StackTraceElement[]> after = Thread.getAllStackTraces();
System.out.println("before: "+before.size()+"; after: "+after.size());
assertTrue(after.size() - before.size() < 10);
assertTrue("before: "+before.size()+"; after: "+after.size(), after.size() - before.size() < 10);
}
public void testManyAlarmsDoNotStartTooManyThreads() throws InterruptedException, ExecutionException, TimeoutException {
@@ -102,7 +101,7 @@ public class AlarmTest extends PlatformTestCase {
AtomicInteger executed = new AtomicInteger();
int N = 100000;
List<Alarm> alarms = Collections.nCopies(N, "").stream().map(__ -> new Alarm(getTestRootDisposable())).collect(Collectors.toList());
alarms.forEach(alarm -> alarm.addRequest(executed::incrementAndGet, 100));
alarms.forEach(alarm -> alarm.addRequest(executed::incrementAndGet, 10));
while (executed.get() != N) {
UIUtil.dispatchAllInvocationEvents();