package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.TestcontainersConfiguration;

/**
 * This container wraps Apache pulsar running in stanalone mode
 */
public class PulsarContainer extends GenericContainer<PulsarContainer> {

    public static final int PULSAR_PORT = 6850;

    public PulsarContainer() {
        this("2.1.0-incubating");
    }

    public PulsarContainer(String pulsarVersion) {
        super(TestcontainersConfiguration.getInstance().getPulsarImage() + ":" + pulsarVersion);
        withExposedPorts(PULSAR_PORT);
        withCommand("/bin/bash", "-c", "" +
            "servicePort=6850 webServicePort=8280 webServicePortTls=8643 bin/apply-config-from-env.py conf/proxy.conf && " +
            "bin/pulsar standalone & " +
            "bin/pulsar proxy --zookeeper-servers localhost:2181 --global-zookeeper-servers localhost:2181"
        );

        waitingFor(Wait.forLogMessage(".*messaging service is ready.*\\s", 1));
    }

    public String getPulsarBrokerUrl() {
        return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getFirstMappedPort());
    }

}

@@ -189,17 +189,17 @@
  Apache 
-p
+P
 ulsar ru
@@ -211,16 +211,17 @@
  in stan
+d
 alone mo
@@ -329,21 +329,21 @@
 nal int 
-PULSA
+BROKE
 R_PORT =
@@ -348,14 +348,13 @@
  = 6
-8
+6
 50;%0A
-%0A
     
@@ -364,59 +364,241 @@
 lic 
-PulsarContainer() %7B%0A        this(%222.1.0-incubating%22
+static final int BROKER_HTTP_PORT = 8080;%0A    public static final String METRICS_ENDPOINT = %22/metrics%22;%0A%0A    private static final String PULSAR_VERSION = %222.1.0-incubating%22;%0A%0A    public PulsarContainer() %7B%0A        this(PULSAR_VERSION
 );%0A 
@@ -776,22 +776,40 @@
 edPorts(
-PULSAR
+BROKER_PORT, BROKER_HTTP
 _PORT);%0A
@@ -834,392 +834,318 @@
 d(%22/
-bin/bash%22, %22-c%22, %22%22 +%0A            %22servicePort=6850 webServicePort=8280 webServicePortTls=8643 bin/apply-config-from-env.py conf/proxy.conf && %22 +%0A            %22bin/pulsar standalone & %22 +%0A            %22bin/pulsar proxy --zookeeper-servers localhost:2181 --global-zookeeper-servers localhost:2181%22%0A        );%0A%0A        waitingFor(Wait.forLogMessage(%22.*messaging service is ready.*%5C%5Cs%22, 1
+pulsar/bin/pulsar%22, %22standalone%22, %22--no-functions-worker%22, %22-nss%22);%0A        waitingFor(Wait.forHttp(METRICS_ENDPOINT).forStatusCode(200).forPort(BROKER_HTTP_PORT));%0A    %7D%0A%0A    public String getPulsarBrokerUrl() %7B%0A        return String.format(%22pulsar://%25s:%25s%22, getContainerIpAddress(), getMappedPort(BROKER_PORT
 ));%0A
@@ -1168,36 +1168,35 @@
 c String get
-PulsarBroker
+HttpService
 Url() %7B%0A    
@@ -1213,38 +1213,36 @@
  String.format(%22
-pulsar
+http
 ://%25s:%25s%22, this.
@@ -1236,21 +1236,16 @@
 %25s:%25s%22, 
-this.
 getConta
@@ -1265,32 +1265,38 @@
 (), 
-this.getFirstMappedPort(
+getMappedPort(BROKER_HTTP_PORT
 ));%0A
@@ -1305,7 +1305,7 @@
   %7D%0A
-%0A
 %7D%0A
+%0A

Update Pulsar Container (#858)