Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NOD flaky test #1444

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions src/test/java/org/java_websocket/issues/Issue256Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
Expand All @@ -46,25 +43,18 @@
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class Issue256Test {

private static final int NUMBER_OF_TESTS = 10;
private static WebSocketServer ws;

private static int port;
static CountDownLatch countServerDownLatch = new CountDownLatch(1);
private WebSocketServer ws;
private int port;
CountDownLatch countServerDownLatch = new CountDownLatch(1);
@Rule
public ThreadCheck zombies = new ThreadCheck();

@Parameterized.Parameter
public int count;

@BeforeClass
public static void startServer() throws Exception {
public void startServer() throws Exception {
port = SocketUtil.getAvailablePort();
ws = new WebSocketServer(new InetSocketAddress(port), 16) {
@Override
Expand Down Expand Up @@ -138,27 +128,22 @@ public void onError(Exception ex) {
}

@AfterClass
public static void successTests() throws InterruptedException, IOException {
public void successTests() throws InterruptedException, IOException {
ws.stop();
}

@Parameterized.Parameters
public static Collection<Integer[]> data() {
List<Integer[]> ret = new ArrayList<Integer[]>(NUMBER_OF_TESTS);
@Test(timeout = 5000 * NUMBER_OF_TESTS)
public void runReconnectSocketClose() throws Exception {
for (int i = 0; i < NUMBER_OF_TESTS; i++) {
ret.add(new Integer[]{i});
runTestScenarioReconnect(false);
}
return ret;
}

@Test(timeout = 5000)
public void runReconnectSocketClose() throws Exception {
runTestScenarioReconnect(false);
}

@Test(timeout = 5000)
@Test(timeout = 5000 * NUMBER_OF_TESTS)
public void runReconnectCloseBlocking() throws Exception {
runTestScenarioReconnect(true);
for (int i = 0; i < NUMBER_OF_TESTS; i++) {
runTestScenarioReconnect(true);
}
}

}
Expand Down