source: josm/trunk/test/unit/org/openstreetmap/josm/data/PreferencesUtilsTest.java@ 17275

Last change on this file since 17275 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import org.junit.jupiter.api.BeforeEach;
7import org.junit.jupiter.api.Test;
8import org.junit.jupiter.api.extension.RegisterExtension;
9import org.openstreetmap.josm.testutils.JOSMTestRules;
10
11import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12import net.trajano.commons.testing.UtilityClassTestUtil;
13
14/**
15 * Unit tests for class {@link PreferencesUtils}.
16 */
17class PreferencesUtilsTest {
18
19 /**
20 * Setup test.
21 */
22 @RegisterExtension
23 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
24 public JOSMTestRules test = new JOSMTestRules().preferences();
25
26 /**
27 * Setup test.
28 */
29 @BeforeEach
30 public void setUp() {
31 PreferencesUtils.resetLog();
32 }
33
34 /**
35 * Test method for {@link PreferencesUtils#log}.
36 */
37 @Test
38 void testLog() {
39 assertEquals("", PreferencesUtils.getLog());
40 PreferencesUtils.log("test");
41 assertEquals("test\n", PreferencesUtils.getLog());
42 PreferencesUtils.log("%d\n", 100);
43 assertEquals("test\n100\n", PreferencesUtils.getLog());
44 PreferencesUtils.log("test");
45 assertEquals("test\n100\ntest\n", PreferencesUtils.getLog());
46 }
47
48 /**
49 * Tests that {@code PreferencesUtils} satisfies utility class criteria.
50 * @throws ReflectiveOperationException if an error occurs
51 */
52 @Test
53 void testUtilityClass() throws ReflectiveOperationException {
54 UtilityClassTestUtil.assertUtilityClassWellDefined(PreferencesUtils.class);
55 }
56}
Note: See TracBrowser for help on using the repository browser.