Skip to content

Commit 0ffb8f2

Browse files
committed
some minor fixes and improvements
1 parent 1bb58c5 commit 0ffb8f2

File tree

7 files changed

+27
-24
lines changed

7 files changed

+27
-24
lines changed

build.gradle

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ project(':embedded-database-spring-test') {
142142
runtime "io.zonky.test.postgres:embedded-postgres-binaries-linux-amd64-alpine:$postgresVersion"
143143

144144
compile project(':embedded-database-spring-test-autoconfigure')
145-
compile 'org.springframework:spring-context:4.3.10.RELEASE'
146-
compile 'org.springframework:spring-test:4.3.10.RELEASE'
145+
compile 'org.springframework:spring-context:4.3.18.RELEASE'
146+
compile 'org.springframework:spring-test:4.3.18.RELEASE'
147147
compile "org.flywaydb:flyway-core:$flywayCoreVersion"
148148
compile "org.flywaydb.flyway-test-extensions:flyway-spring-test:$flywayTestVersion"
149149
compile 'com.google.guava:guava:23.0'
@@ -194,7 +194,8 @@ project(':embedded-database-spring-test') {
194194

195195
configurations {
196196
flywayCoreVersions.init().each { version ->
197-
"testRuntimeWithFlywayCore$version" {
197+
def versionName = version.replaceAll('\\.', '_')
198+
"testRuntimeWithFlywayCore_$versionName" {
198199
extendsFrom testRuntime
199200
resolutionStrategy {
200201
eachDependency { details ->
@@ -207,7 +208,8 @@ project(':embedded-database-spring-test') {
207208
}
208209

209210
flywayTestExtensionsVersions.init().each { version ->
210-
"testRuntimeWithFlywayTestExtensions$version" {
211+
def versionName = version.replaceAll('\\.', '_')
212+
"testRuntimeWithFlywayTestExtensions_$versionName" {
211213
extendsFrom testRuntime
212214
resolutionStrategy {
213215
eachDependency { details ->
@@ -220,7 +222,8 @@ project(':embedded-database-spring-test') {
220222
}
221223

222224
embeddedPostgresVersions.init().each { version ->
223-
"testRuntimeWithEmbeddedPostgres$version" {
225+
def versionName = version.replaceAll('\\.', '_')
226+
"testRuntimeWithEmbeddedPostgres_$versionName" {
224227
extendsFrom testRuntime
225228
resolutionStrategy {
226229
eachDependency { details ->
@@ -234,26 +237,28 @@ project(':embedded-database-spring-test') {
234237
}
235238

236239
flywayCoreVersions.init().each { version ->
237-
task "testWithFlywayCore$version"(type: Test) {
240+
def versionName = version.replaceAll('\\.', '_')
241+
task "testWithFlywayCore_$versionName"(type: Test) {
238242
dependsOn jar
239243

240244
classpath -= configurations.testRuntime
241-
classpath += configurations."testRuntimeWithFlywayCore$version"
245+
classpath += configurations."testRuntimeWithFlywayCore_$versionName"
242246

243247
useJUnit {
244248
includeCategories 'io.zonky.test.category.FlywayIntegrationTests'
245249
includeCategories 'io.zonky.test.category.MultiFlywayIntegrationTests'
246250
}
247251
}
248-
check.dependsOn("testWithFlywayCore$version")
252+
check.dependsOn("testWithFlywayCore_$versionName")
249253
}
250254

251255
flywayTestExtensionsVersions.init().each { version ->
252-
task "testWithFlywayTestExtensions$version"(type: Test) {
256+
def versionName = version.replaceAll('\\.', '_')
257+
task "testWithFlywayTestExtensions_$versionName"(type: Test) {
253258
dependsOn jar
254259

255260
classpath -= configurations.testRuntime
256-
classpath += configurations."testRuntimeWithFlywayTestExtensions$version"
261+
classpath += configurations."testRuntimeWithFlywayTestExtensions_$versionName"
257262

258263
useJUnit {
259264
includeCategories 'io.zonky.test.category.FlywayIntegrationTests'
@@ -263,17 +268,18 @@ project(':embedded-database-spring-test') {
263268
}
264269
}
265270
}
266-
check.dependsOn("testWithFlywayTestExtensions$version")
271+
check.dependsOn("testWithFlywayTestExtensions_$versionName")
267272
}
268273

269274
embeddedPostgresVersions.init().each { version ->
270-
task "testWithEmbeddedPostgres$version"(type: Test) {
275+
def versionName = version.replaceAll('\\.', '_')
276+
task "testWithEmbeddedPostgres_$versionName"(type: Test) {
271277
dependsOn jar
272278

273279
classpath -= configurations.testRuntime
274-
classpath += configurations."testRuntimeWithEmbeddedPostgres$version"
280+
classpath += configurations."testRuntimeWithEmbeddedPostgres_$versionName"
275281
}
276-
check.dependsOn("testWithEmbeddedPostgres$version")
282+
check.dependsOn("testWithEmbeddedPostgres_$versionName")
277283
}
278284

279285
tasks.withType(Test) {

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/DefaultFlywayDataSourceContext.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
public class DefaultFlywayDataSourceContext implements FlywayDataSourceContext {
6262

6363
protected static final int MAX_DATABASE_CONNECTIONS = 300;
64-
protected static final int DEFAULT_MAX_RETRY_ATTEMPTS = 1;
64+
protected static final int DEFAULT_MAX_RETRY_ATTEMPTS = 2;
6565

6666
protected static final Consumer<Builder> DEFAULT_DATABASE_CONFIGURATION = builder -> {
6767
builder.setPgBinaryResolver(DefaultPostgresBinaryResolver.INSTANCE);
68-
builder.setPGStartupWait(Duration.ofSeconds(30L));
68+
builder.setPGStartupWait(Duration.ofSeconds(20L));
6969
};
7070

7171
protected static final Consumer<Builder> FORCED_DATABASE_CONFIGURATION =
@@ -159,11 +159,8 @@ public synchronized ListenableFuture<DataSource> reload(Flyway flyway) {
159159
* Includes the initial attempt before the retries begin so, generally, will be {@code >= 1}.
160160
* For example setting this property to 3 means 3 attempts total (initial + 2 retries).
161161
*
162-
* @deprecated This method is scheduled to be removed in version 2.0.0,
163-
* use {@link Builder Consumer&lt;EmbeddedPostgres.Builder&gt;} customizer and increase startup waiting time instead.
164162
* @param maxAttempts the maximum number of attempts including the initial attempt.
165163
*/
166-
@Deprecated
167164
public void setMaxAttempts(int maxAttempts) {
168165
this.maxAttempts = maxAttempts;
169166
}

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/FlywayClassUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class FlywayClassUtils {
3232
version = "30";
3333
}
3434
} catch (Exception e) {
35-
LoggerFactory.getLogger(FlywayConfigSnapshot.class).error("Error resolving flyway version", e);
35+
LoggerFactory.getLogger(FlywayConfigSnapshot.class).error("Unexpected error occurred while resolving flyway version", e);
3636
version = "0";
3737
}
3838
flywayVersion = Integer.valueOf(version);

embedded-database-spring-test/src/main/java/io/zonky/test/db/postgres/EmptyEmbeddedPostgresDataSourceFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class EmptyEmbeddedPostgresDataSourceFactoryBean implements FactoryBean<D
4949

5050
protected static final Consumer<Builder> DEFAULT_DATABASE_CONFIGURATION = builder -> {
5151
builder.setPgBinaryResolver(DefaultPostgresBinaryResolver.INSTANCE);
52-
builder.setPGStartupWait(Duration.ofSeconds(30L));
52+
builder.setPGStartupWait(Duration.ofSeconds(20L));
5353
};
5454

5555
protected static final Consumer<Builder> FORCED_DATABASE_CONFIGURATION =

embedded-database-spring-test/src/test/java/io/zonky/test/db/AsyncFlywayInitializationIntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
@RunWith(SpringRunner.class)
4646
@Category(FlywayIntegrationTests.class)
47-
@FlywayTest
4847
@AutoConfigureEmbeddedDatabase(beanName = "dataSource")
4948
@ContextConfiguration
5049
public class AsyncFlywayInitializationIntegrationTest {
@@ -59,6 +58,7 @@ public Flyway flyway(DataSource dataSource) {
5958
Flyway flyway = new Flyway();
6059
flyway.setDataSource(dataSource);
6160
flyway.setSchemas("test");
61+
flyway.setLocations("db/migration", "db/test_migration/slow");
6262
return flyway;
6363
}
6464

@@ -91,7 +91,6 @@ public TaskExecutor bootstrapExecutor() {
9191
@Autowired
9292
private JdbcTemplate jdbcTemplate;
9393

94-
@FlywayTest
9594
@Test(timeout = 10000)
9695
public void loadDefaultMigrations() throws Exception {
9796
Duration duration = longTimeInitializingBean.getInitializationDuration();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select pg_sleep(1);

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
rootProject.name = 'embedded-database-spring-test-root'
1+
rootProject.name = 'embedded-database-spring-test-parent'
22

33
include 'embedded-database-spring-test'
44
include 'embedded-database-spring-test-autoconfigure'

0 commit comments

Comments
 (0)