Skip to content

Commit 0dfc972

Browse files
eddumelendezmarcusdacoregio
authored andcommitted
Polish related to testcontainers
* Use getHost instead of getContainerIpAddress * Rely on OracleContainer and it's improvements which involve the log wait strategy
1 parent 7c927c7 commit 0dfc972

File tree

21 files changed

+45
-78
lines changed

21 files changed

+45
-78
lines changed

spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/AbstractMongoRepositoryITest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -399,8 +399,8 @@ public MongoDBContainer mongoContainer() {
399399
@Bean
400400
public MongoOperations mongoOperations(MongoDBContainer mongoContainer) {
401401

402-
MongoClient mongo = MongoClients.create(
403-
"mongodb://" + mongoContainer.getContainerIpAddress() + ":" + mongoContainer.getFirstMappedPort());
402+
MongoClient mongo = MongoClients
403+
.create("mongodb://" + mongoContainer.getHost() + ":" + mongoContainer.getFirstMappedPort());
404404
return new MongoTemplate(mongo, "test");
405405
}
406406

spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbDeleteJacksonSessionVerificationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -185,8 +185,8 @@ MongoDBContainer mongoContainer() {
185185
@Bean
186186
ReactiveMongoOperations mongoOperations(MongoDBContainer mongoContainer) {
187187

188-
MongoClient mongo = MongoClients.create(
189-
"mongodb://" + mongoContainer.getContainerIpAddress() + ":" + mongoContainer.getFirstMappedPort());
188+
MongoClient mongo = MongoClients
189+
.create("mongodb://" + mongoContainer.getHost() + ":" + mongoContainer.getFirstMappedPort());
190190
return new ReactiveMongoTemplate(mongo, "DB_Name_DeleteJacksonSessionVerificationTest");
191191
}
192192

spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbLogoutVerificationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,8 +180,8 @@ MongoDBContainer mongoContainer() {
180180
@Bean
181181
ReactiveMongoOperations mongoOperations(MongoDBContainer mongoContainer) {
182182

183-
MongoClient mongo = MongoClients.create(
184-
"mongodb://" + mongoContainer.getContainerIpAddress() + ":" + mongoContainer.getFirstMappedPort());
183+
MongoClient mongo = MongoClients
184+
.create("mongodb://" + mongoContainer.getHost() + ":" + mongoContainer.getFirstMappedPort());
185185
return new ReactiveMongoTemplate(mongo, "test");
186186
}
187187

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/AbstractRedisITests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@ public GenericContainer redisContainer() {
4242

4343
@Bean
4444
public LettuceConnectionFactory redisConnectionFactory() {
45-
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(
46-
redisContainer().getContainerIpAddress(), redisContainer().getFirstMappedPort());
45+
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(redisContainer().getHost(),
46+
redisContainer().getFirstMappedPort());
4747
return new LettuceConnectionFactory(configuration);
4848
}
4949

spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/ClientServerHazelcast4IndexedSessionRepositoryITests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static class HazelcastSessionConfig {
6666
@Bean
6767
HazelcastInstance hazelcastInstance() {
6868
ClientConfig clientConfig = new ClientConfig();
69-
clientConfig.getNetworkConfig()
70-
.addAddress(container.getContainerIpAddress() + ":" + container.getFirstMappedPort());
69+
clientConfig.getNetworkConfig().addAddress(container.getHost() + ":" + container.getFirstMappedPort());
7170
clientConfig.getUserCodeDeploymentConfig().setEnabled(true).addClass(Session.class)
7271
.addClass(MapSession.class).addClass(Hazelcast4SessionUpdateEntryProcessor.class);
7372
return HazelcastClient.newHazelcastClient(clientConfig);

spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/ClientServerHazelcastIndexedSessionRepositoryITests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,8 +67,7 @@ static class HazelcastSessionConfig {
6767
@Bean
6868
HazelcastInstance hazelcastInstance() {
6969
ClientConfig clientConfig = new ClientConfig();
70-
clientConfig.getNetworkConfig()
71-
.addAddress(container.getContainerIpAddress() + ":" + container.getFirstMappedPort());
70+
clientConfig.getNetworkConfig().addAddress(container.getHost() + ":" + container.getFirstMappedPort());
7271
clientConfig.getUserCodeDeploymentConfig().setEnabled(true).addClass(Session.class)
7372
.addClass(MapSession.class).addClass(SessionUpdateEntryProcessor.class);
7473
return HazelcastClient.newHazelcastClient(clientConfig);

spring-session-jdbc/src/integration-test/java/org/springframework/session/jdbc/DatabaseContainers.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,16 +16,13 @@
1616

1717
package org.springframework.session.jdbc;
1818

19-
import java.time.Duration;
20-
2119
import org.testcontainers.containers.Db2Container;
2220
import org.testcontainers.containers.JdbcDatabaseContainer;
2321
import org.testcontainers.containers.MSSQLServerContainer;
2422
import org.testcontainers.containers.MariaDBContainer;
2523
import org.testcontainers.containers.MySQLContainer;
2624
import org.testcontainers.containers.OracleContainer;
2725
import org.testcontainers.containers.PostgreSQLContainer;
28-
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
2926

3027
/**
3128
* Factories for various {@link JdbcDatabaseContainer}s.
@@ -50,21 +47,7 @@ static MySQLContainer<?> mySql() {
5047
}
5148

5249
static OracleContainer oracle() {
53-
return new OracleContainer() {
54-
55-
@Override
56-
protected void configure() {
57-
this.waitStrategy = new LogMessageWaitStrategy().withRegEx(".*DATABASE IS READY TO USE!.*\\s")
58-
.withStartupTimeout(Duration.ofMinutes(10));
59-
addEnv("ORACLE_PWD", getPassword());
60-
}
61-
62-
@Override
63-
protected void waitUntilContainerStarted() {
64-
getWaitStrategy().waitUntilReady(this);
65-
}
66-
67-
};
50+
return new OracleContainer("gvenzl/oracle-xe:18.4.0-slim");
6851
}
6952

7053
static PostgreSQLContainer<?> postgreSql() {

spring-session-samples/spring-session-sample-boot-findbyusername/src/integration-test/java/sample/FindByUsernameTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -115,8 +115,7 @@ GenericContainer redisContainer() {
115115

116116
@Bean
117117
LettuceConnectionFactory redisConnectionFactory() {
118-
return new LettuceConnectionFactory(redisContainer().getContainerIpAddress(),
119-
redisContainer().getFirstMappedPort());
118+
return new LettuceConnectionFactory(redisContainer().getHost(), redisContainer().getFirstMappedPort());
120119
}
121120

122121
}

spring-session-samples/spring-session-sample-boot-redis-json/src/integration-test/java/sample/HttpRedisJsonTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -115,8 +115,7 @@ GenericContainer redisContainer() {
115115

116116
@Bean
117117
LettuceConnectionFactory redisConnectionFactory() {
118-
return new LettuceConnectionFactory(redisContainer().getContainerIpAddress(),
119-
redisContainer().getFirstMappedPort());
118+
return new LettuceConnectionFactory(redisContainer().getHost(), redisContainer().getFirstMappedPort());
120119
}
121120

122121
}

spring-session-samples/spring-session-sample-boot-redis-json/src/integration-test/java/sample/RedisSerializerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,8 +64,7 @@ GenericContainer redisContainer() {
6464

6565
@Bean
6666
LettuceConnectionFactory redisConnectionFactory() {
67-
return new LettuceConnectionFactory(redisContainer().getContainerIpAddress(),
68-
redisContainer().getFirstMappedPort());
67+
return new LettuceConnectionFactory(redisContainer().getHost(), redisContainer().getFirstMappedPort());
6968
}
7069

7170
}

0 commit comments

Comments
 (0)