Skip to content

Run the NMS integration tests against an ActiveMQ Testcontainer - #392

Merged
lahma merged 1 commit into
mainfrom
4x/testcontainers-nms
Nov 3, 2026
Merged

lahma merged 1 commit into
mainfrom
4x/testcontainers-nms

Conversation

@lahma

@lahma lahma commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Spring.Messaging.Nms.Integration.Tests now starts its own ActiveMQ broker through Testcontainers, with the same setup #390 uses for SQL Server. It runs in the IntegrationTest target and the integration-linux CI job, on both TFMs.

  • Broker. test/Shared/ActiveMqTestEnvironment.cs runs ActiveMQ Classic (apache/activemq-classic:6.2.0), the broker Apache.NMS.ActiveMQ's OpenWire client is written for.
    • It uses the generic Testcontainers ContainerBuilder. The OpenWire port is bound to a random host port.
    • It waits for the broker's "Connector openwire started" log line. A port check would pass too early, because Docker's proxy accepts connections before the broker is listening.
    • It publishes SPRING_TEST_ACTIVEMQ_BROKER_URI. If that variable is already set, it uses that broker and starts no container.
    • Startup, failure handling and disposal follow SqlServerTestEnvironment.
  • Configs. The two XML contexts resolve ${SPRING_TEST_ACTIVEMQ_BROKER_URI} through VariablePlaceholderConfigurer instead of hard-coding tcp://localhost:61616.
  • Runs on .NET 10 too. Apache.NMS.ActiveMQ 2.3.0 ships only netstandard2.0, so the net472-only package condition was a leftover. The project now targets net10.0;net472, and ConnectionThrowException is no longer limited to .NET Framework.
  • Rot fixed:
    • SendAndRecieveAsync slept for a second and called that an assertion. It now waits, with a 30-second timeout, for a signal from the listener.
    • The listener's message counter is now Interlocked; the container runs with concurrency 10.
    • ConnectionThrowException expects a connection failure, and it only got one because of the typo tcp://localaaahost. It now uses the reserved .invalid TLD (RFC 6761), so it fails deterministically.
  • Build.
    • IntegrationTest picks up the NMS project.
    • --test-integration-nms selects it.
    • Test modules run one at a time when an external broker is configured, as they do for an external SQL Server.
  • Docs. README "Running tests" and AGENTS.md "Integration tests" mention the broker and its override.
  • Packages. Testcontainers 4.16.0, the same version as Testcontainers.MsSql. It is test-only.

Verification

🤖 Generated with Claude Code

https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk

Spring.Messaging.Nms.Integration.Tests now provisions its own broker: an
apache/activemq-classic:6.2.0 container, started with Testcontainers' generic
ContainerBuilder, on a random host port, and ready once the broker logs that
the OpenWire connector started. test/Shared/ActiveMqTestEnvironment.cs (linked,
shaped like SqlServerTestEnvironment) publishes SPRING_TEST_ACTIVEMQ_BROKER_URI;
if that variable is already set, no container is started.

- The project multi-targets net10.0 and net472: Apache.NMS.ActiveMQ 2.3.0 is
  netstandard2.0, so the net472-only reference was a leftover.
- The XML contexts read the broker URI through VariablePlaceholderConfigurer.
- ConnectionThrowException runs on both TFMs and uses a host that can never
  resolve (.invalid); the listener test waits on a semaphore, not a sleep.
- The IntegrationTest target runs the project; --test-integration-nms still
  adds it to Test. An external broker or SQL Server serializes the modules.
- Directory.Packages.props: Testcontainers 4.16.0 (same as Testcontainers.MsSql).
- README and AGENTS.md describe the broker and the override variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
@lahma
lahma merged commit 43fa09b into main Nov 3, 2026
4 checks passed
@lahma
lahma deleted the 4x/testcontainers-nms branch November 3, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant