-
-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
commafeed-server/src/test/java/com/commafeed/CommaFeedDropwizardAppExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.commafeed; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import com.codahale.metrics.MetricRegistry; | ||
|
||
import io.dropwizard.testing.ResourceHelpers; | ||
import io.dropwizard.testing.junit5.DropwizardAppExtension; | ||
|
||
public class CommaFeedDropwizardAppExtension extends DropwizardAppExtension<CommaFeedConfiguration> { | ||
|
||
public CommaFeedDropwizardAppExtension() { | ||
super(CommaFeedApplication.class, ResourceHelpers.resourceFilePath("config.test.yml")); | ||
} | ||
|
||
@Override | ||
public void after() { | ||
super.after(); | ||
|
||
DataSource dataSource = getConfiguration().getDataSourceFactory().build(new MetricRegistry(), "cleanup"); | ||
try (Connection connection = dataSource.getConnection(); | ||
PreparedStatement statement = connection.prepareStatement("DROP ALL OBJECTS")) { | ||
statement.executeUpdate(); | ||
} catch (SQLException e) { | ||
throw new RuntimeException("could not cleanup database", e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters