/
developer.bami
/
DFM
Обзор
Документация
Войти
/
developer.bami
/
DFM
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
v1/src/test/java/com/bami/dfm/config/PostgreSqlTestContainer.java
42 строки
1 KB
Michael
Initial version of dfm generated by generator-jhipster@8.0.0-beta.1
28 янв 2024, 15:02
28 янв 2024, 15:02
a03b62a
Код
Авторство
О чём код?
package com.bami.dfm.config; import java.util.Collections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.containers.JdbcDatabaseContainer; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; public class PostgreSqlTestContainer implements SqlTestContainer { private static final Logger log = LoggerFactory.getLogger(PostgreSqlTestContainer.class); private PostgreSQLContainer<?> postgreSQLContainer; @Override public void destroy() { if (null != postgreSQLContainer && postgreSQLContainer.isRunning()) { postgreSQLContainer.stop(); } } @Override public void afterPropertiesSet() { if (null == postgreSQLContainer) { postgreSQLContainer = new PostgreSQLContainer<>("postgres:15.3") .withDatabaseName("dfm") .withTmpFs(Collections.singletonMap("/testtmpfs", "rw")) .withLogConsumer(new Slf4jLogConsumer(log)) .withReuse(true); } if (!postgreSQLContainer.isRunning()) { postgreSQLContainer.start(); } } @Override public JdbcDatabaseContainer<?> getTestContainer() { return postgreSQLContainer; } }