
io.github.mfvanek.pg.testing.PostgreSqlDataSourceHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pg-index-health-testing Show documentation
Show all versions of pg-index-health-testing Show documentation
pg-index-health-testing is an auxiliary library that allows you to run a PostgreSQL cluster in tests.
/*
* Copyright (c) 2019-2023. Ivan Vakhrushev and others.
* https://github.com/mfvanek/pg-index-health
*
* This file is a part of "pg-index-health" - a Java library for
* analyzing and maintaining indexes health in PostgreSQL databases.
*
* Licensed under the Apache License 2.0
*/
package io.github.mfvanek.pg.testing;
import org.apache.commons.dbcp2.BasicDataSource;
import org.testcontainers.containers.JdbcDatabaseContainer;
import javax.annotation.Nonnull;
/**
* Builder for DataSource.
*
* @author Ivan Vakhrushev
* @since 0.6.2
*/
final class PostgreSqlDataSourceHelper {
private PostgreSqlDataSourceHelper() {
throw new UnsupportedOperationException();
}
@Nonnull
static BasicDataSource buildDataSource(@Nonnull final JdbcDatabaseContainer> container) {
final BasicDataSource basicDataSource = new BasicDataSource();
basicDataSource.setUrl(container.getJdbcUrl());
basicDataSource.setUsername(container.getUsername());
basicDataSource.setPassword(container.getPassword());
basicDataSource.setDriverClassName(container.getDriverClassName());
return basicDataSource;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy