Skip to content

Commit 81306a3

Browse files
committed
deprecate providers
1 parent a40fb09 commit 81306a3

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,28 @@ enum DatabaseProvider {
193193
/**
194194
* Use Zonky's fork of OpenTable Embedded PostgreSQL Component to create the embedded database
195195
* (<a href="https://github.com/zonkyio/embedded-postgres">https://github.com/zonkyio/embedded-postgres</a>).
196+
*
197+
* @deprecated Use the {@link #EMBEDDED} value instead. Zonky provider has been renamed to the Embedded Postgres provider and this enum value is scheduled to be removed in the next major version.
196198
*/
199+
@Deprecated
197200
ZONKY,
198201

199202
/**
200203
* Use OpenTable Embedded PostgreSQL Component to create the embedded database
201204
* (<a href="https://github.com/opentable/otj-pg-embedded">https://github.com/opentable/otj-pg-embedded</a>).
205+
*
206+
* @deprecated Use the {@link #EMBEDDED} value instead. OpenTable provider has been deprecated in favor of Zonky provider and is scheduled to be removed in the next major version.
202207
*/
208+
@Deprecated
203209
OPENTABLE,
204210

205211
/**
206212
* Use Yandex's Embedded PostgreSQL Server to create the embedded database
207213
* (<a href="https://github.com/yandex-qatools/postgresql-embedded">https://github.com/yandex-qatools/postgresql-embedded</a>).
214+
*
215+
* @deprecated Use the {@link #EMBEDDED} value instead. Yandex provider has been deprecated in favor of Zonky provider and is scheduled to be removed in the next major version.
208216
*/
217+
@Deprecated
209218
YANDEX
210219

211220
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private void captureTestClassPreparers(TestContext testContext, RefreshMode... r
8787
private void forEachDatabase(TestContext testContext, RefreshMode[] refreshModes, BiConsumer<DatabaseContext, AutoConfigureEmbeddedDatabase> action) {
8888
Set<AutoConfigureEmbeddedDatabase> annotations = AnnotationUtils.getDatabaseAnnotations(testContext.getTestClass());
8989

90+
// prevent invocation of testContext.getApplicationContext() if not necessary
9091
if (annotations.isEmpty()) {
9192
return;
9293
}

embedded-database-spring-test/src/main/java/io/zonky/test/db/config/EmbeddedDatabaseAutoConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ public DatabaseProvider dockerPostgresDatabaseProvider(DatabaseProviderFactory p
6363
return postgresDatabaseProviderFactory.createProvider(DockerPostgresDatabaseProvider.class);
6464
}
6565

66+
@Bean
67+
@Provider(type = "embedded", database = "postgres")
68+
@ConditionalOnMissingBean(name = "embeddedPostgresDatabaseProvider")
69+
public DatabaseProvider embeddedPostgresDatabaseProvider(DatabaseProviderFactory postgresDatabaseProviderFactory) {
70+
checkDependency("io.zonky.test", "embedded-postgres", "io.zonky.test.db.postgres.embedded.EmbeddedPostgres");
71+
checkDependency("org.postgresql", "postgresql", "org.postgresql.ds.PGSimpleDataSource");
72+
return postgresDatabaseProviderFactory.createProvider(ZonkyPostgresDatabaseProvider.class);
73+
}
74+
6675
@Bean
6776
@Provider(type = "zonky", database = "postgres")
6877
@ConditionalOnMissingBean(name = "zonkyPostgresDatabaseProvider")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
import java.util.Map;
4242

4343
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.DOCKER;
44-
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.ZONKY;
44+
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.EMBEDDED;
4545
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseType.POSTGRES;
4646
import static org.assertj.core.api.Assertions.assertThat;
4747
import static org.assertj.core.api.Assertions.entry;
4848
import static org.assertj.core.api.Assertions.tuple;
4949

5050
@RunWith(SpringRunner.class)
5151
@Category(FlywayTestSuite.class)
52-
@AutoConfigureEmbeddedDatabase(beanName = "dataSource1", type = POSTGRES, provider = ZONKY)
52+
@AutoConfigureEmbeddedDatabase(beanName = "dataSource1", type = POSTGRES, provider = EMBEDDED)
5353
@AutoConfigureEmbeddedDatabase(beanName = "dataSource2", type = POSTGRES, provider = DOCKER)
54-
@AutoConfigureEmbeddedDatabase(beanName = "dataSource3", type = POSTGRES, provider = ZONKY)
54+
@AutoConfigureEmbeddedDatabase(beanName = "dataSource3", type = POSTGRES, provider = EMBEDDED)
5555
@ContextConfiguration
5656
public class MultipleDatabasesIntegrationTest {
5757

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
import javax.sql.DataSource;
3030
import java.sql.SQLException;
3131

32-
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.ZONKY;
32+
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.EMBEDDED;
3333
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseType.POSTGRES;
3434
import static org.assertj.core.api.Assertions.assertThat;
3535

3636
@RunWith(SpringRunner.class)
3737
@Category(PostgresTestSuite.class)
38-
@AutoConfigureEmbeddedDatabase(type = POSTGRES, provider = ZONKY)
38+
@AutoConfigureEmbeddedDatabase(type = POSTGRES, provider = EMBEDDED)
3939
@ContextConfiguration
4040
public class ZonkyProviderIntegrationTest {
4141

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
import java.sql.SQLException;
3535
import java.util.function.Consumer;
3636

37-
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.ZONKY;
37+
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseProvider.EMBEDDED;
3838
import static io.zonky.test.db.AutoConfigureEmbeddedDatabase.DatabaseType.POSTGRES;
3939
import static org.assertj.core.api.Assertions.assertThat;
4040

4141
@RunWith(SpringRunner.class)
4242
@Category(PostgresTestSuite.class)
43-
@AutoConfigureEmbeddedDatabase(type = POSTGRES, provider = ZONKY)
43+
@AutoConfigureEmbeddedDatabase(type = POSTGRES, provider = EMBEDDED)
4444
@ContextConfiguration
4545
public class ZonkyProviderWithConfigurationIntegrationTest {
4646

0 commit comments

Comments
 (0)