HiveMQ Testcontainer 1.1.0 Released

Written by Yannick Weber

Category: HiveMQ Testing HiveMQ MQTT Client MQTT Client

Published: June 12, 2020


HiveMQ Testcontainer 1.1.0

The HiveMQ team is pleased to announce the release of the HiveMQ Testcontainer 1.1.0. This new version adds the following improvements:

  • Automatic packaging and loading of HiveMQ extensions with Maven
  • Enabling and disabling of extensions that are loaded from a file

Loading and packaging a HiveMQ extension Maven project

JUnit 4

1
2
3
4
5
    @Rule
    public final @NotNull HiveMQTestContainerRule extension =
    new HiveMQTestContainerRule()
        .withExtension(new MavenHiveMQExtensionSupplier("path/to/extension/pom.xml").get());
        

JUnit 5

1
2
3
4
5
    @RegisterExtension
    public final @NotNull HiveMQTestContainerExtension extension =
        new HiveMQTestContainerExtension()
            .withExtension(new MavenHiveMQExtensionSupplier("path/to/extension/pom.xml").get());
            

Using the HiveMQ Testcontainer inside a HiveMQ extension Maven project

If you are using the HiveMQ Testcontainer inside the Maven project of your HiveMQ extension, you can now use MavenHiveMQExtensionSupplier.direct()to load your extension directly into the HiveMQ Testcontainer.

JUnit 4

1
2
3
4
5
    @Rule
    public final @NotNull HiveMQTestContainerRule extension =
        new HiveMQTestContainerRule()
            .withExtension(MavenHiveMQExtensionSupplier.direct().get());
        

JUnit 5

1
2
3
4
5
    @RegisterExtension
    public final @NotNull HiveMQTestContainerExtension extension =
        new HiveMQTestContainerExtension()
            .withExtension(MavenHiveMQExtensionSupplier.direct().get());
            

Enabling and disabling HiveMQ extensions that are loaded from a file

It is now possible to disable and enable the HiveMQ extensions that are loaded from a file during runtime.

JUnit 4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@Rule
public final @NotNull HiveMQTestContainerRule rule =
        new HiveMQTestContainerRule("hivemq/hivemq4", "latest")
            .withExtension(new File("src/test/resources/modifier-extension"));
            
@Test
void test_disable_enable_extension() throws ExecutionException, InterruptedException {
    extension.disableExtension("Modifier Extension", "modifier-extension");
    extension.enableExtension("Modifier Extension", "modifier-extension");
}
    

JUnit 5

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@RegisterExtension
public final @NotNull HiveMQTestContainerExtension extension =
        new HiveMQTestContainerExtension("hivemq/hivemq4", "latest")
            .withExtension(new File("src/test/resources/modifier-extension"));
            
@Test
void test_disable_enable_extension() throws ExecutionException, InterruptedException {
    extension.disableExtension("Modifier Extension", "modifier-extension");
    extension.enableExtension("Modifier Extension", "modifier-extension");
}
    

You can also disable and enable HiveMQ extensions that are loaded as Maven projects:

JUnit 4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@Rule
public final @NotNull HiveMQTestContainerRule rule =
    new HiveMQTestContainerRule()
        .withExtension(MavenHiveMQExtensionSupplier.direct().get());
            
@Test
void test_disable_enable_extension() throws ExecutionException, InterruptedException {
    extension.disableExtension("Maven Extension", "maven-extension");
    extension.enableExtension("Maven Extension", "maven-extension");
}

JUnit 5

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@RegisterExtension
public final @NotNull HiveMQTestContainerExtension extension =
    new HiveMQTestContainerExtension()
        .withExtension(MavenHiveMQExtensionSupplier.direct().get());
            
@Test
void test_disable_enable_extension() throws ExecutionException, InterruptedException {
    extension.disableExtension("Maven Extension", "maven-extension");
    extension.enableExtension("Maven Extension", "maven-extension");
}
    

About Yannick Weber

Yannick is a software developer at HiveMQ and maintainer of the HiveMQ Testcontainer.
Contact Yannick

Flow Control - MQTT 5 Essentials Part 12
Building a Reliable and Scalable IoT Platform