Changeset 10983 in josm for trunk/test/unit
- Timestamp:
- 2016-09-10T01:45:13+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
r10123 r10983 6 6 import static org.junit.Assert.assertNull; 7 7 8 import java.io.ByteArrayOutputStream; 9 import java.io.IOException; 10 import java.io.PrintStream; 8 11 import java.util.Arrays; 9 12 import java.util.Collection; … … 15 18 import org.junit.Test; 16 19 import org.openstreetmap.josm.JOSMFixture; 20 import org.openstreetmap.josm.data.Version; 17 21 import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor; 18 22 import org.openstreetmap.josm.plugins.PluginHandler; … … 33 37 public static void setUp() { 34 38 JOSMFixture.createUnitTestFixture().init(true); 39 } 40 41 private void testShow(final String arg, String expected) throws InterruptedException, IOException { 42 PrintStream old = System.out; 43 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { 44 System.setOut(new PrintStream(baos)); 45 Thread t = new Thread() { 46 @Override 47 public void run() { 48 MainApplication.main(new String[] {arg}); 49 } 50 }; 51 t.run(); 52 t.join(); 53 System.out.flush(); 54 assertEquals(expected, baos.toString().trim()); 55 } finally { 56 System.setOut(old); 57 } 58 } 59 60 /** 61 * Test of {@link MainApplication#main} with argument {@code --version}. 62 * @throws Exception in case of error 63 */ 64 @Test 65 public void testShowVersion() throws Exception { 66 testShow("--version", Version.getInstance().getAgentString()); 67 } 68 69 /** 70 * Test of {@link MainApplication#main} with argument {@code --help}. 71 * @throws Exception in case of error 72 */ 73 @Test 74 public void testShowHelp() throws Exception { 75 testShow("--help", MainApplication.getHelp().trim()); 35 76 } 36 77 … … 72 113 73 114 private static PluginInformation newPluginInformation(String plugin) throws PluginListParseException { 74 //return new PluginInformation(new File(TestUtils.getTestDataRoot()+File.separator+"plugin"+File.separator+plugin+".jar"));75 115 return PluginListParser.createInfo(plugin+".jar", "https://svn.openstreetmap.org/applications/editors/josm/dist/"+plugin+".jar", 76 116 "");
Note:
See TracChangeset
for help on using the changeset viewer.