Skip to content

Commit

Permalink
Update imports to use JUnit 5 instead of JUnit 4 (openhab#11425)
Browse files Browse the repository at this point in the history
* Update imports to use JUnit 5 instead of JUnit 4
* Add commonly used JUnit 4 classes to forbidden packages

Related to: openhab/openhab-core#2534

Signed-off-by: Wouter Born <[email protected]>
  • Loading branch information
wborn authored Oct 24, 2021
1 parent 739cba7 commit a9fd3f2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

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;

Expand All @@ -32,9 +30,6 @@
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
Expand Down Expand Up @@ -85,8 +80,6 @@ public void test() throws InterruptedException {

@Test
public void forceOptimisticIsNotSupported() {
exceptionGrabber.expect(UnsupportedOperationException.class);

// @formatter:off
publishMessage(configTopicToMqtt(CONFIG_TOPIC),
"{ " +
Expand Down Expand Up @@ -114,6 +107,7 @@ public void forceOptimisticIsNotSupported() {
// @formatter:on
}

@Override
protected Set<String> getConfigTopics() {
return Set.of(CONFIG_TOPIC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

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;

/**
* Test for senec value parsing. All test data are from "original" senec (using vars.html).
*
* @author Erwin Guib - Initial Contribution
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
class SenecHomeHandlerTest {

protected static Object[][] data() {
Expand Down
2 changes: 1 addition & 1 deletion tools/static-code-analysis/checkstyle/ruleset.properties
Original file line number Diff line number Diff line change
@@ -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-
Expand Down

0 comments on commit a9fd3f2

Please sign in to comment.