MarginaliaSearch/code/processes/loading-process/test/nu/marginalia/loader/DbTestUtil.java
Viktor Lofgren 1d34224416 (refac) Remove src/main from all source code paths.
Look, this will make the git history look funny, but trimming unnecessary depth from the source tree is a very necessary sanity-preserving measure when dealing with a super-modularized codebase like this one.

While it makes the project configuration a bit less conventional, it will save you several clicks every time you jump between modules.  Which you'll do a lot, because it's *modul*ar.  The src/main/java convention makes a lot of sense for a non-modular project though.  This ain't that.
2024-02-23 16:13:40 +01:00

39 lines
1.2 KiB
Java

package nu.marginalia.loader;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DbTestUtil {
private static final int TEST_PORT_BASE = 6000;
private static final int TEST_PORT_RANGE = 2000;
private final static Logger logger = LoggerFactory.getLogger(DbTestUtil.class);
public static int getPort() {
return TEST_PORT_BASE + (int)(TEST_PORT_RANGE * Math.random());
}
@SneakyThrows
public static HikariDataSource getConnection() {
return getConnection("jdbc:mysql://localhost:3306/WMSA_test");
}
@SneakyThrows
public static HikariDataSource getConnection(String connString) {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(connString);
config.setUsername("wmsa");
config.setPassword("wmsa");
config.setMaximumPoolSize(16);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
}