testcontainers-cpp 0.2.0
Native C++20 Testcontainers over the Docker Engine API
Loading...
Searching...
No Matches
testcontainers::modules::MosquittoContainer Class Reference

A running Mosquitto broker: connection getters plus the owned container. More...

#include <testcontainers/modules/Mosquitto.hpp>

Public Member Functions

const std::string & host () const noexcept
 The address a client in the test process connects to.
std::uint16_t port () const noexcept
 The host port published for the MQTT port 1883.
const std::string & broker_url () const noexcept
 The broker URL, e.g.
Containercontainer () noexcept
 The underlying container handle: exec mosquitto_pub/mosquitto_sub (both ship in the image), read logs, copy files, stop() early, keep() it past the test.
const Containercontainer () const noexcept

Friends

class MosquittoImage

Detailed Description

A running Mosquitto broker: connection getters plus the owned container.

Move-only — it owns the core Container, whose destructor force-removes the broker (RAII teardown; container().keep() or reuse opt out, see Container).

Member Function Documentation

◆ host()

const std::string & testcontainers::modules::MosquittoContainer::host ( ) const
inlinenoexcept

The address a client in the test process connects to.

Resolved once, when the container started.

◆ port()

std::uint16_t testcontainers::modules::MosquittoContainer::port ( ) const
inlinenoexcept

The host port published for the MQTT port 1883.

Resolved once, when the container started; a container restarted by hand gets fresh ephemeral ports — re-resolve via container() then.

◆ broker_url()

const std::string & testcontainers::modules::MosquittoContainer::broker_url ( ) const
inlinenoexcept

The broker URL, e.g.

tcp://localhost:32768 — the serverURI form the Paho C/C++ clients take (they also accept the identical mqtt:// spelling). Clients that take host and port directly (libmosquitto, mosquitto_pub/_sub) use host() / port() instead.

◆ container() [1/2]

Container & testcontainers::modules::MosquittoContainer::container ( )
inlinenoexcept

The underlying container handle: exec mosquitto_pub/mosquitto_sub (both ship in the image), read logs, copy files, stop() early, keep() it past the test.

◆ container() [2/2]

const Container & testcontainers::modules::MosquittoContainer::container ( ) const
inlinenoexcept

◆ MosquittoImage

friend class MosquittoImage
friend