source: josm/trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java@ 11241

Last change on this file since 11241 was 10758, checked in by Don-vip, 8 years ago

sonar - squid:S3578 - Test methods should comply with a naming convention

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertFalse;
6import static org.junit.Assert.assertNotNull;
7import static org.junit.Assert.assertTrue;
8
9import java.util.ArrayList;
10import java.util.Arrays;
11import java.util.List;
12
13import org.junit.BeforeClass;
14import org.junit.Test;
15import org.openstreetmap.josm.JOSMFixture;
16import org.openstreetmap.josm.Main;
17import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin;
18import org.openstreetmap.josm.tools.Utils;
19
20import nl.jqno.equalsverifier.EqualsVerifier;
21
22/**
23 * Unit tests of {@link PluginHandler} class.
24 */
25public class PluginHandlerTest {
26
27 /**
28 * Setup test.
29 */
30 @BeforeClass
31 public static void setUp() {
32 JOSMFixture.createUnitTestFixture().init();
33 }
34
35 /**
36 * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}.
37 */
38 @Test
39 public void testEqualsContract() {
40 EqualsVerifier.forClass(DeprecatedPlugin.class).usingGetClass().verify();
41 }
42
43 /**
44 * Unit test of {@link PluginHandler#buildListOfPluginsToLoad}.
45 */
46 @Test
47 public void testBuildListOfPluginsToLoad() {
48 final String old = System.getProperty("josm.plugins");
49 try {
50 System.setProperty("josm.plugins",
51 Utils.join(",", PluginHandler.DEPRECATED_PLUGINS) + "," +
52 Utils.join(",", Arrays.asList(PluginHandler.UNMAINTAINED_PLUGINS)));
53 List<PluginInformation> list = PluginHandler.buildListOfPluginsToLoad(null, null);
54 assertNotNull(list);
55 assertTrue(list.isEmpty());
56 } finally {
57 if (old != null) {
58 System.setProperty("josm.plugins", old);
59 } else {
60 System.clearProperty("josm.plugins");
61 }
62 }
63 }
64
65 /**
66 * Unit test of {@link PluginHandler#filterDeprecatedPlugins}.
67 */
68 @Test
69 public void testFilterDeprecatedPlugins() {
70 List<String> plugins = new ArrayList<>(Arrays.asList("foo", "bar", "imagery"));
71 PluginHandler.filterDeprecatedPlugins(Main.parent, plugins);
72 assertEquals(2, plugins.size());
73 assertFalse(plugins.contains("imagery"));
74 }
75
76 /**
77 * Unit test of {@link PluginHandler#filterUnmaintainedPlugins}.
78 */
79 @Test
80 public void testFilterUnmaintainedPlugins() {
81 List<String> plugins = new ArrayList<>(Arrays.asList("foo", "bar", "gpsbabelgui"));
82 PluginHandler.filterUnmaintainedPlugins(Main.parent, plugins);
83 assertEquals(2, plugins.size());
84 assertFalse(plugins.contains("gpsbabelgui"));
85 }
86}
Note: See TracBrowser for help on using the repository browser.