JUnit5 migration in netty-mqtt. Junit-platform.properties and logback-test.xml where added to java resource directory.
Signed-off-by: Oleksandra Matviienko <al.zzzeebra@gmail.com>
This commit is contained in:
parent
a696c5191c
commit
1e581ffea4
@ -82,11 +82,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
|
||||
@ -16,9 +16,10 @@
|
||||
package org.thingsboard.mqtt.integration;
|
||||
|
||||
import org.junit.extensions.cpsuite.ClasspathSuite;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@RunWith(ClasspathSuite.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@ClasspathSuite.ClassnameFilters({
|
||||
"org.thingsboard.mqtt.integration.*Test",
|
||||
})
|
||||
|
||||
@ -23,10 +23,10 @@ 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.thingsboard.common.util.AbstractListeningExecutor;
|
||||
import org.thingsboard.mqtt.MqttClient;
|
||||
import org.thingsboard.mqtt.MqttClientConfig;
|
||||
@ -53,7 +53,7 @@ public class MqttIntegrationTest {
|
||||
|
||||
AbstractListeningExecutor handlerExecutor;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws Exception {
|
||||
this.handlerExecutor = new AbstractListeningExecutor() {
|
||||
@Override
|
||||
@ -69,7 +69,7 @@ public class MqttIntegrationTest {
|
||||
this.mqttServer.init();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void destroy() throws InterruptedException {
|
||||
if (this.mqttClient != null) {
|
||||
this.mqttClient.disconnect();
|
||||
@ -100,7 +100,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 +111,7 @@ public class MqttIntegrationTest {
|
||||
List<MqttMessageType> allReceivedEvents = this.mqttServer.getEventsFromClient();
|
||||
long disconnectCount = allReceivedEvents.stream().filter(type -> type == MqttMessageType.DISCONNECT).count();
|
||||
|
||||
Assert.assertEquals(1, disconnectCount);
|
||||
Assertions.assertEquals(1, disconnectCount);
|
||||
}
|
||||
|
||||
private Future<Void> publishMsg() {
|
||||
|
||||
3
netty-mqtt/src/test/resources/junit-platform.properties
Normal file
3
netty-mqtt/src/test/resources/junit-platform.properties
Normal file
@ -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
|
||||
14
netty-mqtt/src/test/resources/logback-test.xml
Normal file
14
netty-mqtt/src/test/resources/logback-test.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<configuration>
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Loading…
x
Reference in New Issue
Block a user