fix blocking tests (#3378)
* make sure modules using java8 * move url matching code * upgrade boot parent * minor cleanup * fix blocking tests
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
cbd1a9dfbf
commit
ee86e6b6ad
@@ -1,20 +1,21 @@
|
||||
package com.baeldung.concurrent.stopping;
|
||||
|
||||
import com.jayway.awaitility.Awaitility;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.jayway.awaitility.Awaitility.await;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.jayway.awaitility.Awaitility;
|
||||
|
||||
public class StopThreadTest {
|
||||
|
||||
@Test
|
||||
public void whenStoppedThreadIsStopped() throws InterruptedException {
|
||||
|
||||
int interval = 100;
|
||||
int interval = 5;
|
||||
|
||||
ControlSubThread controlSubThread = new ControlSubThread(interval);
|
||||
controlSubThread.start();
|
||||
@@ -33,13 +34,13 @@ public class StopThreadTest {
|
||||
@Test
|
||||
public void whenInterruptedThreadIsStopped() throws InterruptedException {
|
||||
|
||||
int interval = 5000;
|
||||
int interval = 50;
|
||||
|
||||
ControlSubThread controlSubThread = new ControlSubThread(interval);
|
||||
controlSubThread.start();
|
||||
|
||||
// Give things a chance to get set up
|
||||
Thread.sleep(100);
|
||||
Thread.sleep(interval);
|
||||
assertTrue(controlSubThread.isRunning());
|
||||
assertFalse(controlSubThread.isStopped());
|
||||
|
||||
@@ -48,6 +49,7 @@ public class StopThreadTest {
|
||||
|
||||
// Wait less than the time we would normally sleep, and make sure we exited.
|
||||
Awaitility.await()
|
||||
.pollDelay(2, TimeUnit.MILLISECONDS)
|
||||
.atMost(interval/ 10, TimeUnit.MILLISECONDS)
|
||||
.until(controlSubThread::isStopped);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user