diff --git a/docs/modules/activemq.md b/docs/modules/activemq.md new file mode 100644 index 000000000..eba03874f --- /dev/null +++ b/docs/modules/activemq.md @@ -0,0 +1,47 @@ +# Apache ActiveMQ Artemis + +[Apache ActiveMQ Artemis](https://activemq.apache.org/components/artemis/) is an open source project to build a multi-protocol, embeddable, very high performance, clustered, asynchronous messaging system. + +Add the following dependency to your project file: + +```shell title="NuGet" +dotnet add package Testcontainers.ActiveMq +``` + +You can start an Apache ActiveMQ Artemis container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. + +=== "Base test class" + ```csharp + --8<-- "tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs:UseArtemisContainer" + } + ``` +=== "Without auth" + ```csharp + --8<-- "tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs:UseArtemisContainerNoAuth" + ``` +=== "Default credentials" + ```csharp + --8<-- "tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs:UseArtemisContainerDefaultAuth" + ``` +=== "Custom credentials" + ```csharp + --8<-- "tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs:UseArtemisContainerCustomAuth" + ``` + +Connect to the container and produce a message: + +=== "EstablishesConnection" + ```csharp + --8<-- "tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs:ArtemisContainerEstablishesConnection" + ``` + +The test example uses the following NuGet dependencies: + +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.ActiveMq.Tests/Testcontainers.ActiveMq.Tests.csproj:PackageReferences" + ``` + +To execute the tests, use the command `dotnet test` from a terminal. + +--8<-- "docs/modules/_call_out_test_projects.txt" \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index e5ed1099a..a7d0d403b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -48,10 +48,11 @@ nav: - examples/aspnet.md - Modules: - modules/index.md - - modules/cassandra.md - - modules/pulsar.md - - modules/eventhubs.md - - modules/servicebus.md + - modules/activemq.md # Apache + - modules/cassandra.md # Apache + - modules/pulsar.md # Apache + - modules/eventhubs.md # Azure + - modules/servicebus.md # Azure - modules/db2.md - modules/elasticsearch.md - modules/mongodb.md diff --git a/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs b/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs index 704e44f68..baafb31d8 100644 --- a/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs +++ b/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs @@ -1,5 +1,6 @@ namespace Testcontainers.ActiveMq; +// # --8<-- [start:UseArtemisContainer] public abstract class ArtemisContainerTest : IAsyncLifetime { private readonly ArtemisContainer _artemisContainer; @@ -24,7 +25,9 @@ public Task DisposeAsync() { return _artemisContainer.DisposeAsync().AsTask(); } + // # --8<-- [end:UseArtemisContainer] + // # --8<-- [start:ArtemisContainerEstablishesConnection] [Fact] [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] public async Task EstablishesConnection() @@ -67,7 +70,9 @@ await producer.SendAsync(producedMessage) Assert.Equal(producedMessage.Text, receivedMessage.Body()); } + // # --8<-- [end:ArtemisContainerEstablishesConnection] + // # --8<-- [start:UseArtemisContainerDefaultAuth] [UsedImplicitly] public sealed class DefaultCredentialsConfiguration : ArtemisContainerTest { @@ -76,7 +81,9 @@ public DefaultCredentialsConfiguration() { } } + // # --8<-- [end:UseArtemisContainerDefaultAuth] + // # --8<-- [start:UseArtemisContainerCustomAuth] [UsedImplicitly] public sealed class CustomCredentialsConfiguration : ArtemisContainerTest { @@ -89,7 +96,9 @@ public CustomCredentialsConfiguration() { } } + // # --8<-- [end:UseArtemisContainerCustomAuth] + // # --8<-- [start:UseArtemisContainerNoAuth] [UsedImplicitly] public sealed class NoAuthCredentialsConfiguration : ArtemisContainerTest { @@ -98,4 +107,5 @@ public NoAuthCredentialsConfiguration() { } } + // # --8<-- [end:UseArtemisContainerNoAuth] } \ No newline at end of file diff --git a/tests/Testcontainers.ActiveMq.Tests/Testcontainers.ActiveMq.Tests.csproj b/tests/Testcontainers.ActiveMq.Tests/Testcontainers.ActiveMq.Tests.csproj index 54c6102e3..3f600a5ff 100644 --- a/tests/Testcontainers.ActiveMq.Tests/Testcontainers.ActiveMq.Tests.csproj +++ b/tests/Testcontainers.ActiveMq.Tests/Testcontainers.ActiveMq.Tests.csproj @@ -5,11 +5,13 @@ false + +