]> git.basschouten.com Git - openhab-addons.git/commitdiff
Update imports to use JUnit 5 instead of JUnit 4 (#11425)
authorWouter Born <github@maindrain.net>
Sun, 24 Oct 2021 08:36:47 +0000 (10:36 +0200)
committerGitHub <noreply@github.com>
Sun, 24 Oct 2021 08:36:47 +0000 (10:36 +0200)
* Update imports to use JUnit 5 instead of JUnit 4
* Add commonly used JUnit 4 classes to forbidden packages

Related to: https://github.com/openhab/openhab-core/pull/2534

Signed-off-by: Wouter Born <github@maindrain.net>
bundles/org.openhab.binding.fmiweather/src/test/java/org/openhab/binding/fmiweather/AbstractWeatherHandlerTest.java
bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/LockTests.java
bundles/org.openhab.binding.senechome/src/test/java/org/openhab/binding/senechome/internal/SenecHomeHandlerTest.java
tools/static-code-analysis/checkstyle/ruleset.properties

index 38f50d646a480c03838985f340b757923d59c59e..b9e28e94396e74c613f6e717ca1a918cfcd0aae2 100644 (file)
@@ -12,7 +12,6 @@
  */
 package org.openhab.binding.fmiweather;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.jupiter.api.Assertions.*;
 
 import java.lang.reflect.InvocationTargetException;
index 8b9ef9f29282b51d12df651d9356254f2a58ac08..af70489d7540edad8b3beff4f48d1ddd062bbfc1 100644 (file)
@@ -17,9 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Set;
 
-import org.junit.Rule;
 import org.junit.jupiter.api.Test;
-import org.junit.rules.ExpectedException;
 import org.openhab.binding.mqtt.generic.values.OnOffValue;
 import org.openhab.core.library.types.OnOffType;
 
@@ -32,9 +30,6 @@ import org.openhab.core.library.types.OnOffType;
 public class LockTests extends AbstractComponentTests {
     public static final String CONFIG_TOPIC = "lock/0x0000000000000000_lock_zigbee2mqtt";
 
-    @Rule
-    public ExpectedException exceptionGrabber = ExpectedException.none();
-
     @Test
     public void test() throws InterruptedException {
         // @formatter:off
@@ -85,8 +80,6 @@ public class LockTests extends AbstractComponentTests {
 
     @Test
     public void forceOptimisticIsNotSupported() {
-        exceptionGrabber.expect(UnsupportedOperationException.class);
-
         // @formatter:off
         publishMessage(configTopicToMqtt(CONFIG_TOPIC),
                 "{ " +
@@ -114,6 +107,7 @@ public class LockTests extends AbstractComponentTests {
         // @formatter:on
     }
 
+    @Override
     protected Set<String> getConfigTopics() {
         return Set.of(CONFIG_TOPIC);
     }
index d338f5e993ab1af5b24231b14614d070523b97a8..619a3a02ab929be5ac83f5f509dc013d0517c9a1 100644 (file)
@@ -17,11 +17,11 @@ import java.math.RoundingMode;
 
 import org.eclipse.jetty.client.HttpClient;
 import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
-import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openhab.core.thing.Thing;
 
 /**
@@ -29,7 +29,7 @@ import org.openhab.core.thing.Thing;
  *
  * @author Erwin Guib - Initial Contribution
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 class SenecHomeHandlerTest {
 
     protected static Object[][] data() {
index 9bb30ab9dc899c050a9041159b81661156d9bb25..195bd23277e4e6592c65d0ac1721b1d9c7fe8dd9 100644 (file)
@@ -1,6 +1,6 @@
 checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) {0}-{1} Contributors to the openHAB project$\\n^ \\*$\\n^ \\* See the NOTICE file\\(s\\) distributed with this work for additional$\\n^ \\* information.$\\n^ \\*$\\n^ \\* This program and the accompanying materials are made available under the$\\n^ \\* terms of the Eclipse Public License 2\\.0 which is available at$\\n^ \\* http://www.eclipse.org/legal/epl\\-2\\.0$\\n^ \\*$\\n^ \\* SPDX-License-Identifier: EPL-2.0$
 checkstyle.headerCheck.values=2010,2021
-checkstyle.forbiddenPackageUsageCheck.forbiddenPackages=com.google.common,gnu.io,javax.comm,org.apache.commons,org.joda.time,si.uom,tech.units
+checkstyle.forbiddenPackageUsageCheck.forbiddenPackages=com.google.common,gnu.io,javax.comm,org.apache.commons,org.joda.time,org.junit.Assert,org.junit.Test,si.uom,tech.units
 checkstyle.forbiddenPackageUsageCheck.exceptions=
 checkstyle.requiredFilesCheck.files=pom.xml
 checkstyle.karafAddonFeatureCheck.featureNameMappings=-transform-:-transformation-,-io-:-misc-