Skip to content

Commit

Permalink
Rework after review
Browse files Browse the repository at this point in the history
  • Loading branch information
marci4 committed Jan 20, 2020
1 parent 992da3d commit 72aebe1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/test/java/org/java_websocket/issues/Issue900Test.java
Expand Up @@ -37,8 +37,6 @@
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.ByteBuffer;
Expand All @@ -47,8 +45,8 @@

public class Issue900Test {

CountDownLatch countServerDownLatch = new CountDownLatch(1);
CountDownLatch countCloseCallsDownLatch = new CountDownLatch(1);
CountDownLatch serverStartLatch = new CountDownLatch(1);
CountDownLatch closeCalledLatch = new CountDownLatch(1);

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

@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
countCloseCallsDownLatch.countDown();
closeCalledLatch.countDown();
}

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

@Override
public void onStart() {
countServerDownLatch.countDown();
serverStartLatch.countDown();
}
};
new Thread(server).start();
countServerDownLatch.await();
serverStartLatch.await();
client.connectBlocking();
WebSocketImpl websocketImpl = (WebSocketImpl)new ArrayList<WebSocket>(server.getConnections()).get(0);
websocketImpl.setChannel(new ExceptionThrowingByteChannel());
server.broadcast("test");
countCloseCallsDownLatch.await();
closeCalledLatch.await();
}
class ExceptionThrowingByteChannel implements WrappedByteChannel {

@Override
public boolean isNeedWrite() {
return false;
return true;
}

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

@Override
public boolean isNeedRead() {
return false;
return true;
}

@Override
Expand Down

0 comments on commit 72aebe1

Please sign in to comment.