Suppress PMD rules SetDefaultTimeZone and SetDefaultLocale for NTP tests (#19732)

Ideally they should be rewritten to avoid this, but it is done for good reason and the original settings are restored after the test.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
This commit is contained in:
Nadahar
2025-11-30 10:09:18 +01:00
committed by GitHub
parent 42fab2147c
commit 2e802a812b
@@ -30,6 +30,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.mockito.ArgumentMatchers;
import org.openhab.binding.ntp.internal.NtpBindingConstants;
import org.openhab.binding.ntp.internal.handler.NtpHandler;
@@ -76,6 +78,7 @@ import org.openhab.core.types.State;
* @author Markus Rathgeb - Migrated tests from Groovy to pure Java
* @author Erdoan Hadzhiyusein - Migrated tests to Java 8 and integrated the new DateTimeType
*/
@Execution(ExecutionMode.SAME_THREAD)
public class NtpOSGiTest extends JavaOSGiTest {
private static TimeZone systemTimeZone;
private static Locale locale;
@@ -123,6 +126,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
}
@BeforeAll
@SuppressWarnings({ "PMD.SetDefaultTimeZone", "PMD.SetDefaultLocale" })
public static void setUpClass() {
// Initializing a new local server on this port
timeServer = new SimpleNTPServer(TEST_PORT);
@@ -178,6 +182,7 @@ public class NtpOSGiTest extends JavaOSGiTest {
}
@AfterAll
@SuppressWarnings({ "PMD.SetDefaultTimeZone", "PMD.SetDefaultLocale" })
public static void tearDownClass() {
// Stopping the local time server
timeServer.stopServer();