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

generator.server.springboot.broker.pulsar.PulsarTestContainerExtension.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package {{packageName}};

import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.testcontainers.containers.PulsarContainer;
import org.testcontainers.utility.DockerImageName;

public class PulsarTestContainerExtension implements BeforeAllCallback {

  private final AtomicBoolean pulsarContainerStarted = new AtomicBoolean(false);

  @Override
  public void beforeAll(final ExtensionContext context) {
    if (!pulsarContainerStarted.get()) {
      final PulsarContainer pulsarContainer = new PulsarContainer(DockerImageName.parse("{{pulsarDockerImage}}"));
      pulsarContainer.start();
      pulsarContainerStarted.set(true);
      System.setProperty("pulsar.client.serviceUrl", pulsarContainer.getPulsarBrokerUrl());
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy