All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.appform.testcontainers.rabbitmq.container.RabbitMQContainer Maven / Gradle / Ivy

There is a newer version: 1.0.14
Show newest version
package io.appform.testcontainers.rabbitmq.container;

import io.appform.testcontainers.commons.ContainerUtils;
import io.appform.testcontainers.rabbitmq.RabbitMQStatusCheck;
import io.appform.testcontainers.rabbitmq.config.RabbitMQContainerConfiguration;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.testcontainers.containers.GenericContainer;

@Slf4j
@EqualsAndHashCode(callSuper = true)
public class RabbitMQContainer extends GenericContainer {

    private final RabbitMQContainerConfiguration rabbitMQContainerConfiguration;

    public RabbitMQContainer() {
        this(new RabbitMQContainerConfiguration());
    }

    public RabbitMQContainer(final RabbitMQContainerConfiguration rabbitMQContainerConfiguration) {

        super(rabbitMQContainerConfiguration.getDockerImage());

        this.withEnv("RABBITMQ_DEFAULT_VHOST", rabbitMQContainerConfiguration.getVhost())
            .withEnv("RABBITMQ_DEFAULT_USER", rabbitMQContainerConfiguration.getUser())
            .withEnv("RABBITMQ_DEFAULT_PASS", rabbitMQContainerConfiguration.getPassword())
            .withExposedPorts(rabbitMQContainerConfiguration.getPort())
            .withLogConsumer(ContainerUtils.containerLogsConsumer(log))
            .waitingFor(new RabbitMQStatusCheck(rabbitMQContainerConfiguration))
            .withStartupTimeout(rabbitMQContainerConfiguration.getTimeoutDuration());

        this.rabbitMQContainerConfiguration = rabbitMQContainerConfiguration;
    }

    public int getConnectionPort() {
        return getMappedPort(rabbitMQContainerConfiguration.getPort());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy