Skip to content

Commit 72aebe1

Browse files
committed
Rework after review
1 parent 992da3d commit 72aebe1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/test/java/org/java_websocket/issues/Issue900Test.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
import org.junit.Test;
3838

3939
import java.io.IOException;
40-
import java.io.InputStream;
41-
import java.lang.reflect.Method;
4240
import java.net.InetSocketAddress;
4341
import java.net.URI;
4442
import java.nio.ByteBuffer;
@@ -47,8 +45,8 @@
4745

4846
public class Issue900Test {
4947

50-
CountDownLatch countServerDownLatch = new CountDownLatch(1);
51-
CountDownLatch countCloseCallsDownLatch = new CountDownLatch(1);
48+
CountDownLatch serverStartLatch = new CountDownLatch(1);
49+
CountDownLatch closeCalledLatch = new CountDownLatch(1);
5250

5351
@Test(timeout = 2000)
5452
public void testIssue() throws Exception {
@@ -79,7 +77,7 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {
7977

8078
@Override
8179
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
82-
countCloseCallsDownLatch.countDown();
80+
closeCalledLatch.countDown();
8381
}
8482

8583
@Override
@@ -94,22 +92,22 @@ public void onError(WebSocket conn, Exception ex) {
9492

9593
@Override
9694
public void onStart() {
97-
countServerDownLatch.countDown();
95+
serverStartLatch.countDown();
9896
}
9997
};
10098
new Thread(server).start();
101-
countServerDownLatch.await();
99+
serverStartLatch.await();
102100
client.connectBlocking();
103101
WebSocketImpl websocketImpl = (WebSocketImpl)new ArrayList<WebSocket>(server.getConnections()).get(0);
104102
websocketImpl.setChannel(new ExceptionThrowingByteChannel());
105103
server.broadcast("test");
106-
countCloseCallsDownLatch.await();
104+
closeCalledLatch.await();
107105
}
108106
class ExceptionThrowingByteChannel implements WrappedByteChannel {
109107

110108
@Override
111109
public boolean isNeedWrite() {
112-
return false;
110+
return true;
113111
}
114112

115113
@Override
@@ -119,7 +117,7 @@ public void writeMore() throws IOException {
119117

120118
@Override
121119
public boolean isNeedRead() {
122-
return false;
120+
return true;
123121
}
124122

125123
@Override

0 commit comments

Comments
 (0)