diff --git a/netty-mqtt/pom.xml b/netty-mqtt/pom.xml index 6834bb1aca..b0111b9bcd 100644 --- a/netty-mqtt/pom.xml +++ b/netty-mqtt/pom.xml @@ -82,21 +82,11 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - org.awaitility awaitility test - - io.takari.junit - takari-cpsuite - test - diff --git a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/IntegrationTestSuite.java b/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/IntegrationTestSuite.java deleted file mode 100644 index 921d50a91e..0000000000 --- a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/IntegrationTestSuite.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright © 2016-2024 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.thingsboard.mqtt.integration; - -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.runner.RunWith; - -@RunWith(ClasspathSuite.class) -@ClasspathSuite.ClassnameFilters({ - "org.thingsboard.mqtt.integration.*Test", -}) -public class IntegrationTestSuite { - -} \ No newline at end of file diff --git a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/MqttIntegrationTest.java b/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/MqttIntegrationTest.java index 04103bf67b..7f71bc58a6 100644 --- a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/MqttIntegrationTest.java +++ b/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/MqttIntegrationTest.java @@ -23,10 +23,11 @@ import io.netty.handler.codec.mqtt.MqttQoS; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.Promise; import lombok.extern.slf4j.Slf4j; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.ResourceLock; import org.thingsboard.common.util.AbstractListeningExecutor; import org.thingsboard.mqtt.MqttClient; import org.thingsboard.mqtt.MqttClientConfig; @@ -39,6 +40,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +@ResourceLock("port8885") // test MQTT server port @Slf4j public class MqttIntegrationTest { @@ -53,7 +55,7 @@ public class MqttIntegrationTest { AbstractListeningExecutor handlerExecutor; - @Before + @BeforeEach public void init() throws Exception { this.handlerExecutor = new AbstractListeningExecutor() { @Override @@ -69,7 +71,7 @@ public class MqttIntegrationTest { this.mqttServer.init(); } - @After + @AfterEach public void destroy() throws InterruptedException { if (this.mqttClient != null) { this.mqttClient.disconnect(); @@ -100,7 +102,7 @@ public class MqttIntegrationTest { log.warn("Waiting for messages acknowledgments..."); boolean awaitResult = latch.await(10, TimeUnit.SECONDS); - Assert.assertTrue(awaitResult); + Assertions.assertTrue(awaitResult); log.warn("Messages are delivered successfully..."); //when @@ -111,7 +113,7 @@ public class MqttIntegrationTest { List allReceivedEvents = this.mqttServer.getEventsFromClient(); long disconnectCount = allReceivedEvents.stream().filter(type -> type == MqttMessageType.DISCONNECT).count(); - Assert.assertEquals(1, disconnectCount); + Assertions.assertEquals(1, disconnectCount); } private Future publishMsg() { diff --git a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/server/MqttServer.java b/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/server/MqttServer.java index 40663165e6..6bbdace643 100644 --- a/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/server/MqttServer.java +++ b/netty-mqtt/src/test/java/org/thingsboard/mqtt/integration/server/MqttServer.java @@ -46,7 +46,7 @@ public class MqttServer { private EventLoopGroup workerGroup; public void init() throws Exception { - log.info("Starting MQTT server..."); + log.info("Starting MQTT server on port {}...", mqttPort); bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); diff --git a/netty-mqtt/src/test/resources/junit-platform.properties b/netty-mqtt/src/test/resources/junit-platform.properties new file mode 100644 index 0000000000..f2ed301920 --- /dev/null +++ b/netty-mqtt/src/test/resources/junit-platform.properties @@ -0,0 +1,3 @@ +junit.jupiter.execution.parallel.enabled = true +junit.jupiter.execution.parallel.mode.default = concurrent +junit.jupiter.execution.parallel.mode.classes.default = concurrent diff --git a/netty-mqtt/src/test/resources/logback-test.xml b/netty-mqtt/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..52f2a77588 --- /dev/null +++ b/netty-mqtt/src/test/resources/logback-test.xml @@ -0,0 +1,14 @@ + + + + + + %d{ISO8601} [%thread] %-5level %logger{36} - %msg%n + + + + + + + +