Skip to content

Commit 0dd8398

Browse files
committed
Remove usage of SocketUtils in test code.
See #1228
1 parent 3a93a83 commit 0dd8398

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/util/CassandraDelegate.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424

2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
27-
import org.testcontainers.containers.CassandraContainer;
2827

2928
import org.springframework.data.cassandra.core.cql.SessionCallback;
3029
import org.springframework.data.cassandra.support.CassandraConnectionProperties;
3130
import org.springframework.data.cassandra.support.CqlDataSet;
3231
import org.springframework.lang.NonNull;
3332
import org.springframework.util.Assert;
34-
import org.springframework.util.SocketUtils;
3533
import org.springframework.util.StringUtils;
3634

35+
import org.testcontainers.containers.CassandraContainer;
36+
3737
import com.datastax.oss.driver.api.core.CqlIdentifier;
3838
import com.datastax.oss.driver.api.core.CqlSession;
3939
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
@@ -85,8 +85,8 @@ class CassandraDelegate {
8585
/**
8686
* Create a new {@link CassandraDelegate} allowing the use of a config file.
8787
*
88-
* @param yamlConfigurationResource {@link String name} of the configuration resource;
89-
* must not be {@literal null} or {@literal empty}.
88+
* @param yamlConfigurationResource {@link String name} of the configuration resource; must not be {@literal null} or
89+
* {@literal empty}.
9090
* @see #CassandraDelegate(String, long)
9191
*/
9292
public CassandraDelegate(@NonNull String yamlConfigurationResource) {
@@ -258,7 +258,7 @@ private boolean isStartNeeded() {
258258
private void configureRemoteJmxPort() {
259259

260260
if (!System.getProperties().containsKey("com.sun.management.jmxremote.port")) {
261-
System.setProperty("com.sun.management.jmxremote.port", String.valueOf(SocketUtils.findAvailableTcpPort(1024)));
261+
System.setProperty("com.sun.management.jmxremote.port", "1024");
262262
}
263263
}
264264

@@ -273,9 +273,7 @@ private void runTestcontainerCassandra() {
273273

274274
if (container == null) {
275275

276-
container = getCassandraDockerImageName()
277-
.map(CassandraContainer::new)
278-
.orElseGet(CassandraContainer::new);
276+
container = getCassandraDockerImageName().map(CassandraContainer::new).orElseGet(CassandraContainer::new);
279277

280278
container.start();
281279

@@ -289,14 +287,13 @@ private void runTestcontainerCassandra() {
289287

290288
private Optional<String> getCassandraDockerImageName() {
291289

292-
return resolveCassandraVersion()
293-
.map(cassandraVersion -> String.format("cassandra:%s", cassandraVersion));
290+
return resolveCassandraVersion().map(cassandraVersion -> String.format("cassandra:%s", cassandraVersion));
294291
}
295292

296293
private Optional<String> resolveCassandraVersion() {
297294

298295
return Optional.ofNullable(System.getProperty("cassandra.version", System.getenv("CASSANDRA_VERSION")))
299-
.filter(StringUtils::hasText);
296+
.filter(StringUtils::hasText);
300297
}
301298

302299
private synchronized void initializeConnection() {

0 commit comments

Comments
 (0)