Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.socketio4j.socketio.integration;

import java.net.ServerSocket;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand All @@ -35,7 +36,11 @@ final class DistributedClusterIntegrationSupport {

private DistributedClusterIntegrationSupport() {
}

static int findAvailablePort() throws Exception {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
}
}
static void applyReuseListenAddress(Configuration configuration) {
configuration.getSocketConfig().setReuseAddress(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package com.socketio4j.socketio.integration;

import java.net.ServerSocket;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
Expand All @@ -34,6 +32,8 @@
import com.socketio4j.socketio.store.redis_reliable.RedisPubSubReliableEventStore;
import com.socketio4j.socketio.store.redis_stream.RedisStreamEventStore;

import static com.socketio4j.socketio.integration.DistributedClusterIntegrationSupport.findAvailablePort;

/**
* Runs {@link DistributedCommonTest} against all Redisson-backed cluster variants while sharing
* one Redis Testcontainer.
Expand All @@ -43,12 +43,6 @@ public class DistributedRedissonClusterSuite {
@SuppressWarnings("resource")
static final CustomizedRedisContainer REDIS = new CustomizedRedisContainer().withReuse(false);

private static int findAvailablePort() throws Exception {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
}
}

@BeforeAll
static void startRedis() {
REDIS.start();
Expand Down
Loading