Documentation
¶
Overview ¶
Package activemq provides a testcontainers module for Apache ActiveMQ Classic.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAdminCredentials ¶
func WithAdminCredentials(user, password string) testcontainers.CustomizeRequestOption
WithAdminCredentials sets ACTIVEMQ_WEB_USER and ACTIVEMQ_WEB_PASSWORD. The image entrypoint uses these to update conf/users.properties, which configures the JAAS PropertiesLoginModule used for broker connection/messaging security when connection-level authentication is enabled.
NOTE: these variables do NOT affect web-console or Jolokia authentication. The web console and /api/jolokia/* endpoints are protected by Jetty's HashLoginService reading conf/jetty-realm.properties, which is hardcoded to "admin: admin, admin" and is not configurable via environment variables. AdminUser() and AdminPassword() always return those built-in values.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
// contains filtered or unexported fields
}
Container represents the ActiveMQ container type used in the module.
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the ActiveMQ container type with a given image.
Example ¶
ExampleRun demonstrates how to start an Apache ActiveMQ Classic container and retrieve the broker URL and web-console credentials.
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/activemq"
)
func main() {
// runActiveMQContainer {
ctx := context.Background()
activemqContainer, err := activemq.Run(ctx,
"apache/activemq-classic:5.18.7",
activemq.WithAdminCredentials("test", "test"),
)
defer func() {
if err := testcontainers.TerminateContainer(activemqContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := activemqContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
// adminUser {
user := activemqContainer.AdminUser()
// }
// adminPassword {
pass := activemqContainer.AdminPassword()
// }
fmt.Printf("%s:%s\n", user, pass)
}
Output: true admin:admin
func (*Container) AdminPassword ¶
AdminPassword returns the web-console password. The ActiveMQ Classic image protects the web console with Jetty's HashLoginService (conf/jetty-realm.properties), which is hardcoded to "admin: admin, admin" and cannot be overridden via environment variables. This method therefore always returns "admin".
func (*Container) AdminUser ¶
AdminUser returns the web-console username. The ActiveMQ Classic image protects the web console with Jetty's HashLoginService (conf/jetty-realm.properties), which is hardcoded to "admin: admin, admin" and cannot be overridden via environment variables. This method therefore always returns "admin".