Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/modules/activemq.md
Original file line number Diff line number Diff line change
@@ -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"
26 changes: 14 additions & 12 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ nav:
- index.md
- cicd/index.md
- custom_configuration/index.md
- api/create_docker_image.md
- api/create_docker_container.md
- api/create_docker_network.md
- api/low_level_api_access.md
- api/resource_reaper.md
- api/resource_reuse.md
- api/wait_strategies.md
- api/best_practices.md
- Testcontainers API:
- api/create_docker_image.md
- api/create_docker_container.md
- api/create_docker_network.md
- api/low_level_api_access.md
- api/resource_reaper.md
- api/resource_reuse.md
- api/wait_strategies.md
- api/best_practices.md
- dind/index.md
- full_framework/index.md
- test_frameworks/xunit_net.md
- Examples:
- 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
Expand Down
10 changes: 10 additions & 0 deletions tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Testcontainers.ActiveMq;

// # --8<-- [start:UseArtemisContainer]
public abstract class ArtemisContainerTest : IAsyncLifetime
{
private readonly ArtemisContainer _artemisContainer;
Expand All @@ -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()
Expand Down Expand Up @@ -67,7 +70,9 @@ await producer.SendAsync(producedMessage)

Assert.Equal(producedMessage.Text, receivedMessage.Body<string>());
}
// # --8<-- [end:ArtemisContainerEstablishesConnection]

// # --8<-- [start:UseArtemisContainerDefaultAuth]
[UsedImplicitly]
public sealed class DefaultCredentialsConfiguration : ArtemisContainerTest
{
Expand All @@ -76,7 +81,9 @@ public DefaultCredentialsConfiguration()
{
}
}
// # --8<-- [end:UseArtemisContainerDefaultAuth]

// # --8<-- [start:UseArtemisContainerCustomAuth]
[UsedImplicitly]
public sealed class CustomCredentialsConfiguration : ArtemisContainerTest
{
Expand All @@ -89,7 +96,9 @@ public CustomCredentialsConfiguration()
{
}
}
// # --8<-- [end:UseArtemisContainerCustomAuth]

// # --8<-- [start:UseArtemisContainerNoAuth]
[UsedImplicitly]
public sealed class NoAuthCredentialsConfiguration : ArtemisContainerTest
{
Expand All @@ -98,4 +107,5 @@ public NoAuthCredentialsConfiguration()
{
}
}
// # --8<-- [end:UseArtemisContainerNoAuth]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
<IsPublishable>false</IsPublishable>
</PropertyGroup>
<ItemGroup>
<!-- -8<- [start:PackageReferences] -->
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="xunit.runner.visualstudio"/>
<PackageReference Include="xunit"/>
<PackageReference Include="Apache.NMS.ActiveMQ"/>
<!-- -8<- [end:PackageReferences] -->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers.ActiveMq/Testcontainers.ActiveMq.csproj"/>
Expand Down