Changeset 14081 in josm for trunk


Ignore:
Timestamp:
2018-08-04T01:59:46+02:00 (10 months ago)
Author:
Don-vip
Message:

see #16010 - Ignore tests using JMockit on Java 11+, workaround to https://github.com/jmockit/jmockit1/issues/534

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r14075 r14081  
    99import java.io.PrintWriter;
    1010import java.nio.charset.StandardCharsets;
     11import java.text.DateFormat;
    1112import java.util.Collection;
    1213import java.util.Date;
     
    3536 */
    3637public class GpxWriter extends XmlWriter implements GpxConstants {
     38
     39    private final DateFormat gpxFormat = DateUtils.getGpxFormat();
    3740
    3841    /**
     
    117120                    Object val = obj.get(key);
    118121                    if (val instanceof Date) {
    119                         simpleTag(key, DateUtils.getGpxFormat().format(val));
     122                        simpleTag(key, gpxFormat.format(val));
    120123                    }
    121124                }
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r14068 r14081  
    4747import org.openstreetmap.josm.io.Compression;
    4848import org.openstreetmap.josm.testutils.FakeGraphics;
     49import org.openstreetmap.josm.testutils.mockers.WindowMocker;
    4950import org.openstreetmap.josm.tools.JosmRuntimeException;
    5051import org.openstreetmap.josm.tools.Utils;
     
    397398
    398399    /**
     400     * Use to assume that JMockit is working with the current JVM.
     401     */
     402    public static void assumeWorkingJMockit() {
     403        try {
     404            // Workaround to https://github.com/jmockit/jmockit1/issues/534
     405            // Inspired by https://issues.apache.org/jira/browse/SOLR-11606
     406            new WindowMocker();
     407        } catch (UnsupportedOperationException e) {
     408            Assume.assumeNoException(e);
     409        }
     410    }
     411
     412    /**
    399413     * Return WireMock server serving files under ticker directory
    400414     * @param ticketId Ticket numeric identifier
  • trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java

    r14052 r14081  
    77import org.junit.Test;
    88import org.junit.contrib.java.lang.system.ExpectedSystemExit;
     9import org.openstreetmap.josm.TestUtils;
    910import org.openstreetmap.josm.gui.MainApplication;
    1011import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor;
     
    1213import org.openstreetmap.josm.tools.ImageProvider;
    1314
     15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1416import mockit.Invocation;
    1517import mockit.Mock;
    1618import mockit.MockUp;
    17 
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1919
    2020/**
     
    2828    @Rule
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().platform();
     30    public JOSMTestRules test = new JOSMTestRules().platform().main();
    3131
    3232    /**
     
    4141    @Test
    4242    public void testActionPerformed() {
     43        TestUtils.assumeWorkingJMockit();
    4344        exit.expectSystemExitWithStatus(0);
    4445
  • trunk/test/unit/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTaskTest.java

    r14052 r14081  
    1111import org.junit.Rule;
    1212import org.junit.Test;
     13import org.openstreetmap.josm.TestUtils;
    1314import org.openstreetmap.josm.data.APIDataSet;
    1415import org.openstreetmap.josm.data.coor.LatLon;
     
    4950    @Before
    5051    public void bootStrap() {
     52        TestUtils.assumeWorkingJMockit();
    5153        new JOptionPaneSimpleMocker(ImmutableMap.of(
    5254            "A background upload is already in progress. Kindly wait for it to finish before uploading new changes", JOptionPane.OK_OPTION
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java

    r14052 r14081  
    77import org.junit.Test;
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.TestUtils;
    910import org.openstreetmap.josm.testutils.JOSMTestRules;
    1011import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
     
    3031    @Test
    3132    public void testAction() {
     33        TestUtils.assumeWorkingJMockit();
    3234        new JOptionPaneSimpleMocker(ImmutableMap.of(
    3335            "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java

    r14052 r14081  
    1313import org.junit.Rule;
    1414import org.junit.Test;
     15import org.openstreetmap.josm.TestUtils;
    1516import org.openstreetmap.josm.gui.ExtendedDialog;
    1617import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable.AllSettingsTableModel;
     
    5051    @Test
    5152    public void testPreferencesTable() {
     53        TestUtils.assumeWorkingJMockit();
    5254        new JOptionPaneSimpleMocker(ImmutableMap.of(
    5355            "Please select the row to edit.", JOptionPane.OK_OPTION,
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    r14062 r14081  
    3939
    4040import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     41import mockit.MockUp;
    4142
    4243/**
     
    393394    @Test
    394395    public void testUpdateOnlySelectedPlugin() throws Exception {
     396        TestUtils.assumeWorkingJMockit();
    395397        final PluginServer pluginServer = new PluginServer(
    396398            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
     
    586588    @Test
    587589    public void testUpdateWithNoAvailableUpdates() throws Exception {
     590        TestUtils.assumeWorkingJMockit();
    588591        final PluginServer pluginServer = new PluginServer(
    589592            new PluginServer.RemotePlugin(this.referenceDummyJarOld),
     
    724727    @Test
    725728    public void testInstallWithoutRestartRequired() throws Exception {
     729        TestUtils.assumeWorkingJMockit();
    726730        final boolean[] loadPluginsCalled = new boolean[] {false};
    727         new mockit.MockUp<PluginHandler>() {
     731        new MockUp<PluginHandler>() {
    728732            @mockit.Mock
    729733            private void loadPlugins(
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java

    r14052 r14081  
    9696    @Test
    9797    public void testUpdatePluginsDownloadBoth() throws IOException {
     98        TestUtils.assumeWorkingJMockit();
    9899        final PluginServer pluginServer = new PluginServer(
    99100            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
     
    159160    @Test
    160161    public void testUpdatePluginsSkipOne() throws IOException {
     162        TestUtils.assumeWorkingJMockit();
    161163        final PluginServer pluginServer = new PluginServer(
    162164            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
     
    237239    @Test
    238240    public void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException {
     241        TestUtils.assumeWorkingJMockit();
    239242        final PluginServer pluginServer = new PluginServer(
    240243            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
  • trunk/test/unit/org/openstreetmap/josm/testutils/mockers/WindowMocker.java

    r14052 r14081  
    1313 * MockUp for a {@link Window} which simply (and naively) makes its constructor(s) a no-op. This has
    1414 * the advantage of removing the isHeadless check. Though if course it also leaves you with
    15  * uninintialized objects, and so of course they don't *necessarily* work properly. But often they
     15 * uninitialized objects, and so of course they don't *necessarily* work properly. But often they
    1616 * work *just enough* to behave how a test needs them to. Exercise left to the reader to discover
    1717 * the limits here.
Note: See TracChangeset for help on using the changeset viewer.