1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.plugins;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertNotNull;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import java.util.Arrays;
|
---|
8 | import java.util.List;
|
---|
9 |
|
---|
10 | import org.junit.BeforeClass;
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.openstreetmap.josm.JOSMFixture;
|
---|
13 | import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin;
|
---|
14 | import org.openstreetmap.josm.tools.Utils;
|
---|
15 |
|
---|
16 | import nl.jqno.equalsverifier.EqualsVerifier;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests of {@link PluginHandler} class.
|
---|
20 | */
|
---|
21 | public class PluginHandlerTest {
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Setup test.
|
---|
25 | */
|
---|
26 | @BeforeClass
|
---|
27 | public static void setUp() {
|
---|
28 | JOSMFixture.createUnitTestFixture().init();
|
---|
29 | }
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}.
|
---|
33 | */
|
---|
34 | @Test
|
---|
35 | public void equalsContract() {
|
---|
36 | EqualsVerifier.forClass(DeprecatedPlugin.class).usingGetClass().verify();
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Unit test of {@link PluginHandler#buildListOfPluginsToLoad}.
|
---|
41 | */
|
---|
42 | @Test
|
---|
43 | public void testBuildListOfPluginsToLoad() {
|
---|
44 | final String old = System.getProperty("josm.plugins");
|
---|
45 | try {
|
---|
46 | System.setProperty("josm.plugins",
|
---|
47 | Utils.join(",", PluginHandler.DEPRECATED_PLUGINS) + "," +
|
---|
48 | Utils.join(",", Arrays.asList(PluginHandler.UNMAINTAINED_PLUGINS)));
|
---|
49 | List<PluginInformation> list = PluginHandler.buildListOfPluginsToLoad(null, null);
|
---|
50 | assertNotNull(list);
|
---|
51 | assertTrue(list.isEmpty());
|
---|
52 | } finally {
|
---|
53 | if (old != null) {
|
---|
54 | System.setProperty("josm.plugins", old);
|
---|
55 | } else {
|
---|
56 | System.clearProperty("josm.plugins");
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|