source: josm/trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java@ 10121

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

add more debug messages + assertions to debug failing unit test

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertNull;
7
8import java.util.Collection;
9
10import javax.swing.event.ChangeEvent;
11import javax.swing.event.ChangeListener;
12
13import org.junit.BeforeClass;
14import org.junit.Test;
15import org.openstreetmap.josm.JOSMFixture;
16import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor;
17import org.openstreetmap.josm.plugins.PluginHandler;
18import org.openstreetmap.josm.plugins.PluginInformation;
19
20/**
21 * Unit tests of {@link MainApplication} class.
22 */
23public class MainApplicationTest {
24
25 /**
26 * Setup test.
27 */
28 @BeforeClass
29 public static void setUp() {
30 JOSMFixture.createUnitTestFixture().init(true);
31 }
32
33 /**
34 * Test of {@link MainApplication#updateAndLoadEarlyPlugins} and {@link MainApplication#loadLatePlugins} methods.
35 */
36 @Test
37 public void testUpdateAndLoadPlugins() {
38 final String old = System.getProperty("josm.plugins");
39 try {
40 System.setProperty("josm.plugins", "buildings_tools,plastic_laf");
41 assertEquals("buildings_tools,plastic_laf", System.getProperty("josm.plugins"));
42 SplashProgressMonitor monitor = new SplashProgressMonitor("foo", new ChangeListener() {
43 @Override
44 public void stateChanged(ChangeEvent e) {
45 // Do nothing
46 }
47 });
48 Collection<PluginInformation> plugins = MainApplication.updateAndLoadEarlyPlugins(null, monitor);
49 assertEquals("buildings_tools,plastic_laf", System.getProperty("josm.plugins"));
50 assertEquals(2, plugins.size());
51 assertNotNull(PluginHandler.getPlugin("plastic_laf"));
52 assertNull(PluginHandler.getPlugin("buildings_tools"));
53 MainApplication.loadLatePlugins(null, monitor, plugins);
54 assertNotNull(PluginHandler.getPlugin("buildings_tools"));
55 } finally {
56 if (old != null) {
57 System.setProperty("josm.plugins", old);
58 } else {
59 System.clearProperty("josm.plugins");
60 }
61 }
62 }
63}
Note: See TracBrowser for help on using the repository browser.