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.InputStreamReader;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -110,17 +111,15 @@ public class ReadingRunnableTest {
|
|||||||
final ReadingRunnable runnable = new ReadingRunnable(reader);
|
final ReadingRunnable runnable = new ReadingRunnable(reader);
|
||||||
Thread th0 = new Thread(runnable, "read");
|
Thread th0 = new Thread(runnable, "read");
|
||||||
th0.start();
|
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() {
|
Thread th2 = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (start) {
|
|
||||||
start.notify();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
runnable.getMessage();
|
runnable.getMessage();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -129,11 +128,7 @@ public class ReadingRunnableTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "get");
|
}, "get");
|
||||||
synchronized (start) {
|
th2.start();
|
||||||
th2.start();
|
|
||||||
start.wait();
|
|
||||||
}
|
|
||||||
runnable.interrupt();
|
|
||||||
try {
|
try {
|
||||||
th.join();
|
th.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user