source: josm/trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java@ 10378

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

Checkstyle 6.19: enable SingleSpaceSeparator and fix violations

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.plugin;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6
7import java.io.File;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.Collections;
11
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.TestUtils;
16import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
17import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
18import org.openstreetmap.josm.plugins.PluginDownloadTask;
19import org.openstreetmap.josm.plugins.PluginInformation;
20
21/**
22 * Unit tests of {@link PluginPreference} class.
23 */
24public class PluginPreferenceTest {
25
26 /**
27 * Setup test.
28 */
29 @BeforeClass
30 public static void setUpBeforeClass() {
31 JOSMFixture.createUnitTestFixture().init();
32 }
33
34 /**
35 * Unit test of {@link PluginPreference#PluginPreference}.
36 */
37 @Test
38 public void testPluginPreference() {
39 assertNotNull(new PluginPreference.Factory().createPreferenceSetting());
40 }
41
42 /**
43 * Unit test of {@link PluginPreference#buildDownloadSummary}.
44 * @throws Exception if an error occurs
45 */
46 @Test
47 public void testBuildDownloadSummary() throws Exception {
48 final PluginInformation dummy = new PluginInformation(
49 new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin");
50 assertEquals("", PluginPreference.buildDownloadSummary(
51 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "")));
52 assertEquals("", PluginPreference.buildDownloadSummary(
53 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), "")));
54 assertEquals("The following plugin has been downloaded <strong>successfully</strong>:<ul><li>dummy_plugin (31772)</li></ul>"+
55 "Downloading the following plugin has <strong>failed</strong>:<ul><li>dummy_plugin</li></ul>"+
56 "<br>Error message(untranslated): test",
57 PluginPreference.buildDownloadSummary(
58 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), "") {
59 @Override
60 public Collection<PluginInformation> getFailedPlugins() {
61 return Collections.singleton(dummy);
62 }
63
64 @Override
65 public Collection<PluginInformation> getDownloadedPlugins() {
66 return Collections.singleton(dummy);
67 }
68
69 @Override
70 public Exception getLastException() {
71 return new Exception("test");
72 }
73 }));
74 }
75
76 /**
77 * Unit test of {@link PluginPreference#notifyDownloadResults}.
78 */
79 @Test
80 public void testNotifyDownloadResults() {
81 PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "");
82 PluginPreference.notifyDownloadResults(null, task, false);
83 PluginPreference.notifyDownloadResults(null, task, true);
84 }
85
86 /**
87 * Unit test of {@link PluginPreference#addGui}.
88 */
89 @Test
90 public void testAddGui() {
91 PreferencesTestUtils.doTestPreferenceSettingAddGui(new PluginPreference.Factory(), null);
92 }
93}
Note: See TracBrowser for help on using the repository browser.