Fix test for getWaitRunnable
This commit is contained in:
parent
ffa54af3be
commit
ff9ace1033
@ -48,6 +48,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -110,17 +111,15 @@ public class ReadingRunnableTest {
|
||||
final ReadingRunnable runnable = new ReadingRunnable(reader);
|
||||
Thread th0 = new Thread(runnable, "read");
|
||||
th0.start();
|
||||
Thread th = runnable.getWaitForDelivery("");
|
||||
Thread th = runnable.getWaitForDelivery("msg");
|
||||
|
||||
final Object start = new Object();
|
||||
out.write(Charset.forName("UTF-8")
|
||||
.encode("msg" + System.lineSeparator()).array());
|
||||
|
||||
Thread th2 = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (start) {
|
||||
start.notify();
|
||||
}
|
||||
try {
|
||||
runnable.getMessage();
|
||||
} catch (IOException e) {
|
||||
@ -129,11 +128,7 @@ public class ReadingRunnableTest {
|
||||
}
|
||||
}
|
||||
}, "get");
|
||||
synchronized (start) {
|
||||
th2.start();
|
||||
start.wait();
|
||||
}
|
||||
runnable.interrupt();
|
||||
th2.start();
|
||||
try {
|
||||
th.join();
|
||||
} catch (InterruptedException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user