Skip to content

Commit

Permalink
use a random available port for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Athou committed Apr 14, 2024
1 parent 9d052f2 commit dcc32cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -5,15 +5,19 @@

import javax.sql.DataSource;

import org.mockserver.socket.PortFactory;

import com.codahale.metrics.MetricRegistry;

import io.dropwizard.testing.ConfigOverride;
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"));
super(CommaFeedApplication.class, ResourceHelpers.resourceFilePath("config.test.yml"),
ConfigOverride.config("server.applicationConnectors[0].port", String.valueOf(PortFactory.findFreePort())));
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions commafeed-server/src/test/resources/config.test.yml
Expand Up @@ -119,6 +119,9 @@ database:
validationQuery: "/* CommaFeed Health Check */ SELECT 1"

server:
applicationConnectors:
- type: http
port: 8083
adminConnectors: [ ]

logging:
Expand Down

0 comments on commit dcc32cb

Please sign in to comment.