mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add more IT tests to ease transition to dropwizard 4
This commit is contained in:
@@ -3,6 +3,8 @@ package com.commafeed;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -13,6 +15,9 @@ import io.dropwizard.testing.junit5.DropwizardAppExtension;
|
||||
|
||||
public class CommaFeedDropwizardAppExtension extends DropwizardAppExtension<CommaFeedConfiguration> {
|
||||
|
||||
private static final List<String> TABLES = Arrays.asList("FEEDENTRYSTATUSES", "FEEDENTRYTAGS", "FEEDENTRIES", "FEEDENTRYCONTENTS",
|
||||
"FEEDSUBSCRIPTIONS", "FEEDS", "FEEDCATEGORIES");
|
||||
|
||||
public CommaFeedDropwizardAppExtension() {
|
||||
super(CommaFeedApplication.class, ResourceHelpers.resourceFilePath("config.test.yml"));
|
||||
}
|
||||
@@ -23,9 +28,11 @@ public class CommaFeedDropwizardAppExtension extends DropwizardAppExtension<Comm
|
||||
|
||||
// clean database after each test
|
||||
DataSource dataSource = getConfiguration().getDataSourceFactory().build(new MetricRegistry(), "cleanup");
|
||||
try (Connection connection = dataSource.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("DROP ALL OBJECTS")) {
|
||||
statement.executeUpdate();
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
for (String table : TABLES) {
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM " + table);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("could not cleanup database", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user