/*
 * Copyright (C) 2016-2020 the original author or authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package space.npstr.wolfia;

import org.testcontainers.containers.GenericContainer;

/**
 * Set up our testcontainers & pass their urls into the application config.
 * Yes, this is the recommended way to go about setting up containers that are shared by all tests.
 */
public abstract class PostgresAndRedisContainers {

    private static final GenericContainer<?> DB = new GenericContainer<>("napstr/wolfia-postgres:12")
            .withEnv("ROLE", "wolfia_test")
            .withEnv("DB", "wolfia_test")
            .withExposedPorts(5432);

    static {
        DB.start();
        String host = DB.getContainerIpAddress();
        int port = DB.getMappedPort(5432);
        String jdbcUrl = "jdbc:postgresql://" + host + ":" + port + "/wolfia_test?user=wolfia_test";
        System.setProperty("database.jdbcUrl", jdbcUrl);
    }


    private static final GenericContainer<?> REDIS = new GenericContainer<>("redis:5-alpine")
            .withExposedPorts(6379);

    static {
        REDIS.start();
        String host = REDIS.getContainerIpAddress();
        int port = REDIS.getMappedPort(6379);
        String redisUrl = "redis://" + host + ":" + port + "/1";
        System.setProperty("spring.redis.url", redisUrl);
    }
}

@@ -773,48 +773,167 @@
 org.
-testcontainers.containers.GenericContain
+slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.testcontainers.containers.GenericContainer;%0Aimport org.testcontainers.containers.output.Slf4jLogConsum
 er;%0A
@@ -1169,16 +1169,114 @@
 ners %7B%0A%0A
+    private static final Logger log = LoggerFactory.getLogger(PostgresAndRedisContainers.class);%0A%0A
     priv
@@ -1369,16 +1369,72 @@
 es:12%22)%0A
+            .withLogConsumer(new Slf4jLogConsumer(log))%0A
         
@@ -1841,16 +1841,16 @@
     %7D%0A%0A%0A
-
     priv
@@ -1935,16 +1935,72 @@
 lpine%22)%0A
+            .withLogConsumer(new Slf4jLogConsumer(log))%0A
         

Attach loggers to postgres and redis containers during tests