Skip to content

Optimise tests

Justin Lewis Salmon requested to merge optimise-tests into master

This MR aims to optimise many tests across all three layers, as some were running slowly or occasionally hanging completely, leading to builds needing to be cancelled.

What has changed?

There were some changes made to the code itself in order to make the tests run properly:

New property c2mon.server.jms.embedded

Previously, the embedded broker was started up automatically by ActiveMQ itself when the URL was of the format vm://localhost. While this works, it has been seen to cause problems in tests when multiple tests attempt to start brokers. This can often be fixed by using @DirtiesContext, but this significantly slows down the tests. Manually starting/stopping the embedded broker inside unit tests fixes this problem and makes the build much more stable.

Hence the new property c2mon.server.jms.embedded=true

Lazily initialising JmsProxyImpl

Previously, the JmsProxyImpl would try to connect to a C2MON server inside a @PostConstruct. This caused problems inside tests as it could be called too early, resulting in refused connections to the embedded broker.

Lazily initialising the connection solves this problem, and also slightly improves startup performance.

Other changes

  • Refactored Spring configuration in c2mon-client-core to Java as part of #101

Merge request reports