From 0816045a5949de092c7a4ea9e25467fffdde6b6b Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Wed, 6 Jan 2021 14:30:40 +0100 Subject: [PATCH] Update Mockito, JUnit and use MockitoExtensions in itests (#9702) * Updates Mockito to 3.7.0 * Updates JUnit to 5.7.0 * Use MockitoExtensions where possible Signed-off-by: Wouter Born --- .../phonebook/PhonebookProfileTest.java | 17 +++++--------- .../itest.bndrun | 22 +++++++++---------- .../itest.bndrun | 20 ++++++++--------- .../itest.bndrun | 12 +++++----- .../itest.bndrun | 12 +++++----- .../itest.bndrun | 12 +++++----- .../itest.bndrun | 21 +++++++++--------- .../modbus/tests/AbstractModbusOSGiTest.java | 11 +++++----- .../binding/mqtt/DiscoverComponentsTest.java | 17 +++++--------- .../HomeAssistantMQTTImplementationTest.java | 12 +++++----- .../binding/mqtt/HomieImplementationTest.java | 11 +++++----- .../itest.bndrun | 21 +++++++++--------- .../logback.xml | 2 +- .../nest/handler/NestBridgeHandlerTest.java | 13 +++-------- .../itest.bndrun | 20 ++++++++--------- .../itest.bndrun | 20 ++++++++--------- .../itest.bndrun | 21 +++++++++--------- .../TradfriDiscoveryParticipantOSGITest.java | 17 +++++--------- .../itest.bndrun | 20 ++++++++--------- .../itest.bndrun | 12 +++++----- 20 files changed, 148 insertions(+), 165 deletions(-) diff --git a/bundles/org.openhab.binding.tr064/src/test/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfileTest.java b/bundles/org.openhab.binding.tr064/src/test/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfileTest.java index 13acf950a1f..9da947b45f1 100644 --- a/bundles/org.openhab.binding.tr064/src/test/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfileTest.java +++ b/bundles/org.openhab.binding.tr064/src/test/java/org/openhab/binding/tr064/internal/phonebook/PhonebookProfileTest.java @@ -14,7 +14,6 @@ package org.openhab.binding.tr064.internal.phonebook; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import static org.openhab.binding.tr064.internal.Tr064BindingConstants.*; import java.math.BigDecimal; @@ -27,11 +26,14 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.StringListType; import org.openhab.core.library.types.StringType; @@ -47,6 +49,8 @@ import org.openhab.core.util.UIDUtils; * * @author Christoph Weitkamp - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) class PhonebookProfileTest { private static final String INTERNAL_PHONE_NUMBER = "999"; @@ -97,8 +101,6 @@ class PhonebookProfileTest { }); } - private AutoCloseable mocksCloseable; - private @Mock ProfileCallback mockCallback; private @Mock ProfileContext mockContext; private @Mock PhonebookProvider mockPhonebookProvider; @@ -123,17 +125,10 @@ class PhonebookProfileTest { @BeforeEach public void setup() { - mocksCloseable = openMocks(this); - when(mockPhonebookProvider.getPhonebookByName(any(String.class))).thenReturn(Optional.of(phonebook)); when(mockPhonebookProvider.getPhonebooks()).thenReturn(Set.of(phonebook)); } - @AfterEach - public void afterEach() throws Exception { - mocksCloseable.close(); - } - @ParameterizedTest @MethodSource("parameters") public void testPhonebookProfileResolvesPhoneNumber(ParameterSet parameterSet) { diff --git a/itests/org.openhab.binding.astro.tests/itest.bndrun b/itests/org.openhab.binding.astro.tests/itest.bndrun index 7fc46a3ca9e..0702935ac75 100644 --- a/itests/org.openhab.binding.astro.tests/itest.bndrun +++ b/itests/org.openhab.binding.astro.tests/itest.bndrun @@ -16,22 +16,12 @@ Fragment-Host: org.openhab.binding.astro org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ ch.qos.logback.core;version='[1.2.3,1.2.4)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ slf4j.api;version='[1.7.25,1.7.26)',\ com.google.gson;version='[2.8.2,2.8.3)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ tec.uom.se;version='[1.0.10,1.0.11)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-jupiter-params;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -44,4 +34,14 @@ Fragment-Host: org.openhab.binding.astro org.openhab.core.config.discovery;version='[3.1.0,3.1.1)',\ org.openhab.core.io.console;version='[3.1.0,3.1.1)',\ org.openhab.core.storage.json;version='[3.1.0,3.1.1)',\ - org.openhab.core.thing;version='[3.1.0,3.1.1)' + org.openhab.core.thing;version='[3.1.0,3.1.1)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-jupiter-params;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.avmfritz.tests/itest.bndrun b/itests/org.openhab.binding.avmfritz.tests/itest.bndrun index f0232a7b250..cc980f7bc0e 100644 --- a/itests/org.openhab.binding.avmfritz.tests/itest.bndrun +++ b/itests/org.openhab.binding.avmfritz.tests/itest.bndrun @@ -18,7 +18,6 @@ Fragment-Host: org.openhab.binding.avmfritz org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ ch.qos.logback.core;version='[1.2.3,1.2.4)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ slf4j.api;version='[1.7.25,1.7.26)',\ org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\ org.jupnp;version='[2.5.2,2.5.3)',\ @@ -39,15 +38,7 @@ Fragment-Host: org.openhab.binding.avmfritz org.eclipse.jetty.xml;version='[9.4.20,9.4.21)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ @@ -68,4 +59,13 @@ Fragment-Host: org.openhab.binding.avmfritz org.openhab.core.io.console;version='[3.1.0,3.1.1)',\ org.openhab.core.io.net;version='[3.1.0,3.1.1)',\ org.openhab.core.test;version='[3.1.0,3.1.1)',\ - org.openhab.core.thing;version='[3.1.0,3.1.1)' + org.openhab.core.thing;version='[3.1.0,3.1.1)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.feed.tests/itest.bndrun b/itests/org.openhab.binding.feed.tests/itest.bndrun index 16723f55bea..24e9dc83287 100644 --- a/itests/org.openhab.binding.feed.tests/itest.bndrun +++ b/itests/org.openhab.binding.feed.tests/itest.bndrun @@ -39,11 +39,6 @@ Fragment-Host: org.openhab.binding.feed org.eclipse.jetty.xml;version='[9.4.20,9.4.21)',\ org.ops4j.pax.swissbox.optional.jcl;version='[1.8.3,1.8.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ @@ -71,4 +66,9 @@ Fragment-Host: org.openhab.binding.feed org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' \ No newline at end of file + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)' \ No newline at end of file diff --git a/itests/org.openhab.binding.hue.tests/itest.bndrun b/itests/org.openhab.binding.hue.tests/itest.bndrun index afb10419d70..3d58f359a0a 100644 --- a/itests/org.openhab.binding.hue.tests/itest.bndrun +++ b/itests/org.openhab.binding.hue.tests/itest.bndrun @@ -41,11 +41,6 @@ Fragment-Host: org.openhab.binding.hue org.eclipse.jetty.xml;version='[9.4.20,9.4.21)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ org.eclipse.jdt.annotation;version='[2.2.100,2.2.101)',\ @@ -72,4 +67,9 @@ Fragment-Host: org.openhab.binding.hue org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)' diff --git a/itests/org.openhab.binding.max.tests/itest.bndrun b/itests/org.openhab.binding.max.tests/itest.bndrun index 53036078279..491dc1769dd 100644 --- a/itests/org.openhab.binding.max.tests/itest.bndrun +++ b/itests/org.openhab.binding.max.tests/itest.bndrun @@ -36,11 +36,6 @@ Fragment-Host: org.openhab.binding.max org.eclipse.jetty.servlet;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.util;version='[9.4.20,9.4.21)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ @@ -58,4 +53,9 @@ Fragment-Host: org.openhab.binding.max org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)' diff --git a/itests/org.openhab.binding.modbus.tests/itest.bndrun b/itests/org.openhab.binding.modbus.tests/itest.bndrun index 120678d7840..47ad6aa28f5 100644 --- a/itests/org.openhab.binding.modbus.tests/itest.bndrun +++ b/itests/org.openhab.binding.modbus.tests/itest.bndrun @@ -33,7 +33,6 @@ Fragment-Host: org.openhab.binding.modbus org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ slf4j.api;version='[1.7.25,1.7.26)',\ com.google.gson;version='[2.8.2,2.8.3)',\ tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ @@ -48,16 +47,8 @@ Fragment-Host: org.openhab.binding.modbus ch.qos.logback.core;version='[1.2.3,1.2.4)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ nrjavaserial;version='[5.2.1,5.2.2)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -76,4 +67,14 @@ Fragment-Host: org.openhab.binding.modbus org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ org.openhab.core.transform;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)',\ + org.mockito.junit-jupiter;version='[3.7.0,3.7.1)' diff --git a/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java b/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java index 2f7e1a42b14..26516d9a41a 100644 --- a/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java +++ b/itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/AbstractModbusOSGiTest.java @@ -19,7 +19,6 @@ import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import java.util.ArrayList; import java.util.Collections; @@ -36,8 +35,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.binding.modbus.internal.ModbusHandlerFactory; import org.openhab.core.events.Event; import org.openhab.core.events.EventFilter; @@ -68,6 +71,8 @@ import org.slf4j.LoggerFactory; /** * @author Sami Salonen - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) @NonNullByDefault public abstract class AbstractModbusOSGiTest extends JavaOSGiTest { @@ -101,8 +106,6 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest { private final Logger logger = LoggerFactory.getLogger(AbstractModbusOSGiTest.class); - private @NonNullByDefault({}) AutoCloseable mocksCloseable; - protected @Mock @NonNullByDefault({}) ModbusManager mockedModbusManager; protected @NonNullByDefault({}) ManagedThingProvider thingProvider; protected @NonNullByDefault({}) ManagedItemProvider itemProvider; @@ -128,7 +131,6 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest { @BeforeEach public void setUpAbstractModbusOSGiTest() { logger.debug("setUpAbstractModbusOSGiTest BEGIN"); - mocksCloseable = openMocks(this); registerVolatileStorageService(); registerService(mockedModbusManager); registerService(stateSubscriber); @@ -167,7 +169,6 @@ public abstract class AbstractModbusOSGiTest extends JavaOSGiTest { logger.debug("Unlinking {} <-> {}", link.getItemName(), link.getLinkedUID()); assertNotNull(itemChannelLinkProvider.remove(link.getUID())); } - mocksCloseable.close(); logger.debug("tearDownAbstractModbusOSGiTest END"); } diff --git a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/DiscoverComponentsTest.java b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/DiscoverComponentsTest.java index d61a6230cd0..df0ef6073ce 100644 --- a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/DiscoverComponentsTest.java +++ b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/DiscoverComponentsTest.java @@ -14,7 +14,6 @@ package org.openhab.binding.mqtt; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import java.util.Collections; import java.util.HashSet; @@ -28,10 +27,13 @@ import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.binding.mqtt.generic.AvailabilityTracker; import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener; import org.openhab.binding.mqtt.generic.TransformationServiceProvider; @@ -51,11 +53,11 @@ import com.google.gson.GsonBuilder; * * @author David Graeff - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) @NonNullByDefault public class DiscoverComponentsTest extends JavaOSGiTest { - private @NonNullByDefault({}) AutoCloseable mocksCloseable; - private @Mock @NonNullByDefault({}) MqttBrokerConnection connection; private @Mock @NonNullByDefault({}) ComponentDiscovered discovered; private @Mock @NonNullByDefault({}) TransformationServiceProvider transformationServiceProvider; @@ -64,8 +66,6 @@ public class DiscoverComponentsTest extends JavaOSGiTest { @BeforeEach public void beforeEach() { - mocksCloseable = openMocks(this); - CompletableFuture<@Nullable Void> voidFutureComplete = new CompletableFuture<>(); voidFutureComplete.complete(null); doReturn(voidFutureComplete).when(connection).unsubscribeAll(); @@ -76,11 +76,6 @@ public class DiscoverComponentsTest extends JavaOSGiTest { doReturn(null).when(transformationServiceProvider).getTransformationService(any()); } - @AfterEach - public void afterEach() throws Exception { - mocksCloseable.close(); - } - @Test public void discoveryTimeTest() throws InterruptedException, ExecutionException, TimeoutException { // Create a scheduler diff --git a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/HomeAssistantMQTTImplementationTest.java b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/HomeAssistantMQTTImplementationTest.java index 66bb79f7b04..a7238deace8 100644 --- a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/HomeAssistantMQTTImplementationTest.java +++ b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/HomeAssistantMQTTImplementationTest.java @@ -17,7 +17,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import java.util.ArrayList; import java.util.Collections; @@ -37,7 +36,11 @@ import org.eclipse.jdt.annotation.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.binding.mqtt.generic.AvailabilityTracker; import org.openhab.binding.mqtt.generic.ChannelStateUpdateListener; import org.openhab.binding.mqtt.generic.MqttChannelTypeProvider; @@ -68,6 +71,8 @@ import com.google.gson.GsonBuilder; * * @author David Graeff - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) @NonNullByDefault public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest { private @NonNullByDefault({}) ConfigurationAdmin configurationAdmin; @@ -77,8 +82,6 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest { private int registeredTopics = 100; private @Nullable Throwable failure; - private @NonNullByDefault({}) AutoCloseable mocksCloseable; - private @Mock @NonNullByDefault({}) ChannelStateUpdateListener channelStateUpdateListener; private @Mock @NonNullByDefault({}) AvailabilityTracker availabilityTracker; private @Mock @NonNullByDefault({}) TransformationServiceProvider transformationServiceProvider; @@ -95,7 +98,6 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest { @BeforeEach public void beforeEach() throws Exception { registerVolatileStorageService(); - mocksCloseable = openMocks(this); configurationAdmin = getService(ConfigurationAdmin.class); mqttService = getService(MqttService.class); @@ -133,8 +135,6 @@ public class HomeAssistantMQTTImplementationTest extends JavaOSGiTest { connection.removeConnectionObserver(failIfChange); connection.stop().get(2, TimeUnit.SECONDS); } - - mocksCloseable.close(); } @Test diff --git a/itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/HomieImplementationTest.java b/itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/HomieImplementationTest.java index d825e89cdb8..674519c0f96 100644 --- a/itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/HomieImplementationTest.java +++ b/itests/org.openhab.binding.mqtt.homie.tests/src/main/java/org/openhab/binding/mqtt/HomieImplementationTest.java @@ -17,7 +17,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -35,8 +34,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.binding.mqtt.generic.ChannelState; import org.openhab.binding.mqtt.generic.tools.ChildMap; import org.openhab.binding.mqtt.generic.tools.WaitForTopicValue; @@ -66,6 +69,8 @@ import org.osgi.service.cm.ConfigurationAdmin; * * @author David Graeff - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) @NonNullByDefault public class HomieImplementationTest extends JavaOSGiTest { private static final String BASE_TOPIC = "homie"; @@ -78,8 +83,6 @@ public class HomieImplementationTest extends JavaOSGiTest { private @NonNullByDefault({}) MqttBrokerConnection connection; private int registeredTopics = 100; - private @NonNullByDefault({}) AutoCloseable mocksCloseable; - // The handler is not tested here, so just mock the callback private @Mock @NonNullByDefault({}) DeviceCallback callback; @@ -100,7 +103,6 @@ public class HomieImplementationTest extends JavaOSGiTest { @BeforeEach public void beforeEach() throws Exception { registerVolatileStorageService(); - mocksCloseable = openMocks(this); configurationAdmin = getService(ConfigurationAdmin.class); mqttService = getService(MqttService.class); @@ -168,7 +170,6 @@ public class HomieImplementationTest extends JavaOSGiTest { if (scheduler != null) { scheduler.shutdownNow(); } - mocksCloseable.close(); } @Test diff --git a/itests/org.openhab.binding.nest.tests/itest.bndrun b/itests/org.openhab.binding.nest.tests/itest.bndrun index be6d08ebd04..6898f1728e5 100644 --- a/itests/org.openhab.binding.nest.tests/itest.bndrun +++ b/itests/org.openhab.binding.nest.tests/itest.bndrun @@ -39,7 +39,6 @@ Fragment-Host: org.openhab.binding.nest org.eclipse.jetty.websocket.client;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.websocket.common;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.xml;version='[9.4.20,9.4.21)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ org.ops4j.pax.swissbox.optional.jcl;version='[1.8.3,1.8.4)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\ @@ -49,15 +48,7 @@ Fragment-Host: org.openhab.binding.nest tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ tec.uom.se;version='[1.0.10,1.0.11)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ org.apache.aries.jax.rs.whiteboard;version='[1.0.9,1.0.10)',\ @@ -86,4 +77,14 @@ Fragment-Host: org.openhab.binding.nest org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.junit-jupiter;version='[3.7.0,3.7.1)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.nest.tests/logback.xml b/itests/org.openhab.binding.nest.tests/logback.xml index 161b219083c..4406c9eabca 100644 --- a/itests/org.openhab.binding.nest.tests/logback.xml +++ b/itests/org.openhab.binding.nest.tests/logback.xml @@ -10,7 +10,7 @@ - + diff --git a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestBridgeHandlerTest.java b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestBridgeHandlerTest.java index 9bba2713e81..dbcc2749a64 100644 --- a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestBridgeHandlerTest.java +++ b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestBridgeHandlerTest.java @@ -16,15 +16,15 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.openMocks; import javax.ws.rs.client.ClientBuilder; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import org.openhab.binding.nest.internal.config.NestBridgeConfiguration; import org.openhab.binding.nest.internal.handler.NestBridgeHandler; import org.openhab.binding.nest.internal.handler.NestRedirectUrlSupplier; @@ -42,12 +42,11 @@ import org.osgi.service.jaxrs.client.SseEventSourceFactory; * * @author David Bennett - Initial contribution */ +@ExtendWith(MockitoExtension.class) public class NestBridgeHandlerTest { private ThingHandler handler; - private AutoCloseable mocksCloseable; - private @Mock Bridge bridge; private @Mock ThingHandlerCallback callback; private @Mock ClientBuilder clientBuilder; @@ -57,16 +56,10 @@ public class NestBridgeHandlerTest { @BeforeEach public void beforeEach() { - mocksCloseable = openMocks(this); handler = new NestTestBridgeHandler(bridge, clientBuilder, eventSourceFactory, "http://localhost"); handler.setCallback(callback); } - @AfterEach - public void afterEach() throws Exception { - mocksCloseable.close(); - } - @SuppressWarnings("null") @Test public void initializeShouldCallTheCallback() { diff --git a/itests/org.openhab.binding.ntp.tests/itest.bndrun b/itests/org.openhab.binding.ntp.tests/itest.bndrun index 03592c0b725..c3a5914cb7a 100644 --- a/itests/org.openhab.binding.ntp.tests/itest.bndrun +++ b/itests/org.openhab.binding.ntp.tests/itest.bndrun @@ -26,7 +26,6 @@ Fragment-Host: org.openhab.binding.ntp org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\ org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ slf4j.api;version='[1.7.25,1.7.26)',\ tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ @@ -38,15 +37,7 @@ Fragment-Host: org.openhab.binding.ntp org.eclipse.jetty.servlet;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.util;version='[9.4.20,9.4.21)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -63,4 +54,13 @@ Fragment-Host: org.openhab.binding.ntp org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.systeminfo.tests/itest.bndrun b/itests/org.openhab.binding.systeminfo.tests/itest.bndrun index cdd4d945f9f..654ed6cf5c8 100644 --- a/itests/org.openhab.binding.systeminfo.tests/itest.bndrun +++ b/itests/org.openhab.binding.systeminfo.tests/itest.bndrun @@ -25,7 +25,6 @@ Fragment-Host: org.openhab.binding.systeminfo org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\ org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\ slf4j.api;version='[1.7.25,1.7.26)',\ ch.qos.logback.core;version='[1.2.3,1.2.4)',\ @@ -41,15 +40,7 @@ Fragment-Host: org.openhab.binding.systeminfo org.eclipse.jetty.servlet;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.util;version='[9.4.20,9.4.21)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -66,4 +57,13 @@ Fragment-Host: org.openhab.binding.systeminfo org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.tradfri.tests/itest.bndrun b/itests/org.openhab.binding.tradfri.tests/itest.bndrun index fc1358c45e6..97c0c06fee9 100644 --- a/itests/org.openhab.binding.tradfri.tests/itest.bndrun +++ b/itests/org.openhab.binding.tradfri.tests/itest.bndrun @@ -26,7 +26,6 @@ Fragment-Host: org.openhab.binding.tradfri com.google.gson;version='[2.8.2,2.8.3)',\ javax.jmdns;version='[3.5.6,3.5.7)',\ org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ tec.uom.se;version='[1.0.10,1.0.11)',\ org.eclipse.jetty.http;version='[9.4.20,9.4.21)',\ @@ -40,15 +39,7 @@ Fragment-Host: org.openhab.binding.tradfri org.eclipse.californium.scandium;version='[2.0.0,2.0.1)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -67,4 +58,14 @@ Fragment-Host: org.openhab.binding.tradfri org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.junit-jupiter;version='[3.7.0,3.7.1)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryParticipantOSGITest.java b/itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryParticipantOSGITest.java index 7bfa67af5ef..31878b8da50 100644 --- a/itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryParticipantOSGITest.java +++ b/itests/org.openhab.binding.tradfri.tests/src/main/java/org/openhab/binding/tradfri/internal/discovery/TradfriDiscoveryParticipantOSGITest.java @@ -16,15 +16,17 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.openMocks; import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*; import javax.jmdns.ServiceInfo; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultFlag; import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant; @@ -37,19 +39,17 @@ import org.openhab.core.thing.ThingUID; * * @author Kai Kreuzer - Initial contribution */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.WARN) public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest { private MDNSDiscoveryParticipant discoveryParticipant; - private AutoCloseable mocksCloseable; - private @Mock ServiceInfo tradfriGateway; private @Mock ServiceInfo otherDevice; @BeforeEach public void beforeEach() { - mocksCloseable = openMocks(this); - discoveryParticipant = getService(MDNSDiscoveryParticipant.class, TradfriDiscoveryParticipant.class); when(tradfriGateway.getType()).thenReturn("_coap._udp.local."); @@ -65,11 +65,6 @@ public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest { when(otherDevice.getPropertyString("version")).thenReturn("1.1"); } - @AfterEach - public void afterEach() throws Exception { - mocksCloseable.close(); - } - @Test public void correctSupportedTypes() { assertThat(discoveryParticipant.getSupportedThingTypeUIDs().size(), is(1)); diff --git a/itests/org.openhab.binding.wemo.tests/itest.bndrun b/itests/org.openhab.binding.wemo.tests/itest.bndrun index 6bbd931d7a3..30dcc0dd4e1 100644 --- a/itests/org.openhab.binding.wemo.tests/itest.bndrun +++ b/itests/org.openhab.binding.wemo.tests/itest.bndrun @@ -25,7 +25,6 @@ Fragment-Host: org.openhab.binding.wemo org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\ org.jupnp;version='[2.5.2,2.5.3)',\ - org.objenesis;version='[2.6.0,2.6.1)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ slf4j.api;version='[1.7.25,1.7.26)',\ tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\ @@ -43,15 +42,7 @@ Fragment-Host: org.openhab.binding.wemo org.eclipse.jetty.xml;version='[9.4.20,9.4.21)',\ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ - net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\ - net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ - org.mockito.mockito-core;version='[3.4.6,3.4.7)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\ @@ -77,4 +68,13 @@ Fragment-Host: org.openhab.binding.wemo org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.core.thing;version='[3.1.0,3.1.1)',\ org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\ - xstream;version='[1.4.15,1.4.16)' + xstream;version='[1.4.15,1.4.16)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)',\ + net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\ + net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\ + org.mockito.mockito-core;version='[3.7.0,3.7.1)',\ + org.objenesis;version='[3.1.0,3.1.1)' diff --git a/itests/org.openhab.persistence.mapdb.tests/itest.bndrun b/itests/org.openhab.persistence.mapdb.tests/itest.bndrun index eb7886139d9..789b5350c78 100644 --- a/itests/org.openhab.persistence.mapdb.tests/itest.bndrun +++ b/itests/org.openhab.persistence.mapdb.tests/itest.bndrun @@ -34,11 +34,6 @@ Fragment-Host: org.openhab.persistence.mapdb org.eclipse.jetty.servlet;version='[9.4.20,9.4.21)',\ org.eclipse.jetty.util;version='[9.4.20,9.4.21)',\ biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\ - junit-jupiter-api;version='[5.6.2,5.6.3)',\ - junit-jupiter-engine;version='[5.6.2,5.6.3)',\ - junit-platform-commons;version='[1.6.2,1.6.3)',\ - junit-platform-engine;version='[1.6.2,1.6.3)',\ - junit-platform-launcher;version='[1.6.2,1.6.3)',\ org.hamcrest;version='[2.2.0,2.2.1)',\ org.opentest4j;version='[1.2.0,1.2.1)',\ com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\ @@ -50,4 +45,9 @@ Fragment-Host: org.openhab.persistence.mapdb org.openhab.core.persistence;version='[3.1.0,3.1.1)',\ org.openhab.core.test;version='[3.1.0,3.1.1)',\ org.openhab.persistence.mapdb;version='[3.1.0,3.1.1)',\ - org.openhab.persistence.mapdb.tests;version='[3.1.0,3.1.1)' + org.openhab.persistence.mapdb.tests;version='[3.1.0,3.1.1)',\ + junit-jupiter-api;version='[5.7.0,5.7.1)',\ + junit-jupiter-engine;version='[5.7.0,5.7.1)',\ + junit-platform-commons;version='[1.7.0,1.7.1)',\ + junit-platform-engine;version='[1.7.0,1.7.1)',\ + junit-platform-launcher;version='[1.7.0,1.7.1)'