This commit is contained in:
akwizgran
2017-11-16 10:29:18 +00:00
committed by Torsten Grote
parent 27328afe3c
commit 5fa6b0ca1c
109 changed files with 2087 additions and 3450 deletions

View File

@@ -28,12 +28,9 @@ public class PoliteExecutorTest extends BrambleTestCase {
final CountDownLatch latch = new CountDownLatch(TASKS);
for (int i = 0; i < TASKS; i++) {
final int result = i;
polite.execute(new Runnable() {
@Override
public void run() {
list.add(result);
latch.countDown();
}
polite.execute(() -> {
list.add(result);
latch.countDown();
});
}
// Wait for all the tasks to finish
@@ -53,12 +50,9 @@ public class PoliteExecutorTest extends BrambleTestCase {
final CountDownLatch latch = new CountDownLatch(TASKS);
for (int i = 0; i < TASKS; i++) {
final int result = i;
polite.execute(new Runnable() {
@Override
public void run() {
list.add(result);
latch.countDown();
}
polite.execute(() -> {
list.add(result);
latch.countDown();
});
}
// Wait for all the tasks to finish
@@ -78,18 +72,15 @@ public class PoliteExecutorTest extends BrambleTestCase {
for (int i = 0; i < TASKS; i++) latches[i] = new CountDownLatch(1);
for (int i = 0; i < TASKS; i++) {
final int result = i;
polite.execute(new Runnable() {
@Override
public void run() {
try {
// Each task waits for the next task, if any, to finish
if (result < TASKS - 1) latches[result + 1].await();
list.add(result);
} catch (InterruptedException e) {
fail();
}
latches[result].countDown();
polite.execute(() -> {
try {
// Each task waits for the next task, if any, to finish
if (result < TASKS - 1) latches[result + 1].await();
list.add(result);
} catch (InterruptedException e) {
fail();
}
latches[result].countDown();
});
}
// Wait for all the tasks to finish
@@ -108,18 +99,15 @@ public class PoliteExecutorTest extends BrambleTestCase {
final CountDownLatch latch = new CountDownLatch(TASKS);
for (int i = 0; i < TASKS; i++) {
final int result = i;
polite.execute(new Runnable() {
@Override
public void run() {
try {
// Each task runs faster than the previous task
Thread.sleep(TASKS - result);
list.add(result);
} catch (InterruptedException e) {
fail();
}
latch.countDown();
polite.execute(() -> {
try {
// Each task runs faster than the previous task
Thread.sleep(TASKS - result);
list.add(result);
} catch (InterruptedException e) {
fail();
}
latch.countDown();
});
}
// Wait for all the tasks to finish

View File

@@ -17,11 +17,7 @@ public class ShutdownManagerImplTest extends BrambleTestCase {
ShutdownManager s = createShutdownManager();
Set<Integer> handles = new HashSet<>();
for (int i = 0; i < 100; i++) {
int handle = s.addShutdownHook(new Runnable() {
@Override
public void run() {
}
});
int handle = s.addShutdownHook(() -> {});
// The handles should all be distinct
assertTrue(handles.add(handle));
}