diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
index 9fba4cd..7314aa1 100644
a
|
b
|
public class JOSMTestRules implements TestRule {
|
160 | 160 | * @throws InitializationError If an error occured while creating the required environment. |
161 | 161 | */ |
162 | 162 | protected void before() throws InitializationError { |
163 | | cleanUpFromJosmFixture(); |
164 | | |
165 | 163 | // Tests are running headless by default. |
166 | 164 | System.setProperty("java.awt.headless", "true"); |
| 165 | |
| 166 | cleanUpFromJosmFixture(); |
| 167 | |
167 | 168 | // All tests use the same timezone. |
168 | 169 | TimeZone.setDefault(DateUtils.UTC); |
169 | 170 | // Set log level to info |
diff --git a/test/unit/org/openstreetmap/josm/tools/GeometryTest.java b/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
index f6eb1cc..fbaa6dd 100644
a
|
b
|
import java.io.FileInputStream;
|
5 | 5 | import java.util.List; |
6 | 6 | |
7 | 7 | import org.junit.Assert; |
8 | | import org.junit.BeforeClass; |
| 8 | import org.junit.Rule; |
9 | 9 | import org.junit.Test; |
10 | | import org.openstreetmap.josm.JOSMFixture; |
11 | 10 | import org.openstreetmap.josm.TestUtils; |
12 | 11 | import org.openstreetmap.josm.actions.search.SearchCompiler; |
13 | 12 | import org.openstreetmap.josm.data.coor.EastNorth; |
… |
… |
import org.openstreetmap.josm.data.osm.DataSet;
|
15 | 14 | import org.openstreetmap.josm.data.osm.Relation; |
16 | 15 | import org.openstreetmap.josm.data.osm.Way; |
17 | 16 | import org.openstreetmap.josm.io.OsmReader; |
| 17 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 18 | |
| 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
18 | 20 | |
19 | 21 | /** |
20 | 22 | * Unit tests of {@link Geometry} class. |
21 | 23 | */ |
22 | 24 | public class GeometryTest { |
23 | | |
24 | 25 | /** |
25 | | * Setup test. |
| 26 | * Primitives need preferences and projection. |
26 | 27 | */ |
27 | | @BeforeClass |
28 | | public static void setUp() { |
29 | | JOSMFixture.createUnitTestFixture().init(); |
30 | | } |
| 28 | @Rule |
| 29 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 30 | public JOSMTestRules test = new JOSMTestRules().preferences().projection(); |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Test of {@link Geometry#getLineLineIntersection} method. |
diff --git a/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java b/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java
index d8c8af0..125042f 100644
a
|
b
|
package org.openstreetmap.josm.tools;
|
3 | 3 | |
4 | 4 | import static org.junit.Assert.assertEquals; |
5 | 5 | |
6 | | import org.junit.BeforeClass; |
| 6 | import org.junit.Rule; |
7 | 7 | import org.junit.Test; |
8 | | import org.openstreetmap.josm.JOSMFixture; |
| 8 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 9 | |
| 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Unit tests of {@link OverpassTurboQueryWizard} class. |
12 | 14 | */ |
13 | 15 | public class OverpassTurboQueryWizardTest { |
14 | | |
15 | 16 | /** |
16 | | * Setup test. |
| 17 | * Base test environment is enough |
17 | 18 | */ |
18 | | @BeforeClass |
19 | | public static void setUp() { |
20 | | JOSMFixture.createUnitTestFixture().init(false); |
21 | | OverpassTurboQueryWizard.getInstance(); |
22 | | } |
| 19 | @Rule |
| 20 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 21 | public JOSMTestRules test = new JOSMTestRules(); |
23 | 22 | |
24 | 23 | /** |
25 | 24 | * Test key=value. |
diff --git a/test/unit/org/openstreetmap/josm/tools/PredicatesTest.java b/test/unit/org/openstreetmap/josm/tools/PredicatesTest.java
index dded4b1..a0f76ba 100644
a
|
b
|
import java.util.List;
|
10 | 10 | import java.util.Properties; |
11 | 11 | import java.util.regex.Pattern; |
12 | 12 | |
13 | | import org.junit.BeforeClass; |
| 13 | import org.junit.Rule; |
14 | 14 | import org.junit.Test; |
15 | | import org.openstreetmap.josm.JOSMFixture; |
16 | 15 | import org.openstreetmap.josm.data.osm.Node; |
17 | 16 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 17 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 18 | |
| 19 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
18 | 20 | |
19 | 21 | /** |
20 | 22 | * This test tests the {@link Predicate}s created by the {@link Predicates} class. |
… |
… |
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
23 | 25 | */ |
24 | 26 | public class PredicatesTest { |
25 | 27 | /** |
26 | | * Not needed by this test, but JOSM has so many dependencies :-( |
| 28 | * Some of this depends on preferences. |
27 | 29 | */ |
28 | | @BeforeClass |
29 | | public static void setUpClass() { |
30 | | JOSMFixture.createUnitTestFixture().init(); |
31 | | } |
| 30 | @Rule |
| 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 32 | public JOSMTestRules test = new JOSMTestRules().preferences(); |
32 | 33 | |
33 | 34 | /** |
34 | 35 | * Test {@link Predicates#alwaysTrue()} |
diff --git a/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java b/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
index 3eae839..20c343f 100644
a
|
b
|
import java.util.HashMap;
|
6 | 6 | import java.util.Map; |
7 | 7 | |
8 | 8 | import org.junit.Assert; |
9 | | import org.junit.BeforeClass; |
| 9 | import org.junit.Rule; |
10 | 10 | import org.junit.Test; |
11 | | import org.openstreetmap.josm.JOSMFixture; |
| 11 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| 12 | |
| 13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
12 | 14 | |
13 | 15 | /** |
14 | 16 | * Unit tests of {@link TextTagParser} class. |
15 | 17 | */ |
16 | 18 | public class TextTagParserTest { |
17 | | |
18 | 19 | /** |
19 | | * Setup test. |
| 20 | * Some of this depends on preferences. |
20 | 21 | */ |
21 | | @BeforeClass |
22 | | public static void setUp() { |
23 | | JOSMFixture.createUnitTestFixture().init(); |
24 | | } |
| 22 | @Rule |
| 23 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 24 | public JOSMTestRules test = new JOSMTestRules().preferences(); |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Test of {@link TextTagParser#unescape} method. |
diff --git a/test/unit/org/openstreetmap/josm/tools/WindowGeometryTest.java b/test/unit/org/openstreetmap/josm/tools/WindowGeometryTest.java
index b0c11b8..f4b982f 100644
a
|
b
|
import java.awt.Rectangle;
|
13 | 13 | import javax.swing.JLabel; |
14 | 14 | import javax.swing.JPanel; |
15 | 15 | |
16 | | import org.junit.BeforeClass; |
| 16 | import org.junit.Rule; |
17 | 17 | import org.junit.Test; |
18 | | import org.openstreetmap.josm.JOSMFixture; |
19 | 18 | import org.openstreetmap.josm.Main; |
| 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
20 | 20 | import org.openstreetmap.josm.tools.WindowGeometry.WindowGeometryException; |
21 | 21 | |
| 22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
22 | 23 | import nl.jqno.equalsverifier.EqualsVerifier; |
23 | 24 | import nl.jqno.equalsverifier.Warning; |
24 | 25 | |
… |
… |
import nl.jqno.equalsverifier.Warning;
|
26 | 27 | * Unit tests of {@link WindowGeometry} class. |
27 | 28 | */ |
28 | 29 | public class WindowGeometryTest { |
29 | | |
30 | 30 | /** |
31 | | * Setup test. |
| 31 | * Some of this depends on preferences. |
32 | 32 | */ |
33 | | @BeforeClass |
34 | | public static void setUp() { |
35 | | JOSMFixture.createUnitTestFixture().init(); |
36 | | } |
| 33 | @Rule |
| 34 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| 35 | public JOSMTestRules test = new JOSMTestRules().preferences(); |
37 | 36 | |
38 | 37 | /** |
39 | 38 | * Test of {@link WindowGeometry#centerInWindow} method. |
… |
… |
public class WindowGeometryTest {
|
52 | 51 | Dimension dim = new Dimension(200, 100); |
53 | 52 | assertEquals(new WindowGeometry(new Point(0, 0), dim), WindowGeometry.centerOnScreen(dim)); |
54 | 53 | assertEquals(new WindowGeometry(new Point(300, 250), dim), WindowGeometry.centerOnScreen(dim, null)); |
| 54 | |
| 55 | Main.pref.put("gui.geometry", "x=0,y=0,width=800,height=600"); |
| 56 | assertEquals(new WindowGeometry(new Point(300, 250), dim), WindowGeometry.centerOnScreen(dim)); |
55 | 57 | } |
56 | 58 | |
57 | 59 | /** |