Changeset 14126 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2018-08-11T19:08:26+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16590 - fix unit tests (patch by ris)

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java

    r14081 r14126  
    88import org.junit.contrib.java.lang.system.ExpectedSystemExit;
    99import org.openstreetmap.josm.TestUtils;
     10import org.openstreetmap.josm.data.cache.JCSCacheManager;
    1011import org.openstreetmap.josm.gui.MainApplication;
    1112import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor;
     
    4647        boolean[] workerShutdownCalled = {false};
    4748        boolean[] workerShutdownNowCalled = {false};
    48         boolean[] imageProviderShutdownCalled = {false};
     49        boolean[] imageProviderShutdownCalledNowFalse = {false};
     50        boolean[] imageProviderShutdownCalledNowTrue = {false};
     51        boolean[] jcsCacheManagerShutdownCalled = {false};
    4952
    5053        // critically we don't proceed into the actual implementation in any of these mock methods -
     
    7073        new MockUp<ImageProvider>() {
    7174            @Mock
     75            private void shutdown(Invocation invocation, boolean now) {
     76                if (now) {
     77                    // should have already been called with now = false
     78                    assertTrue(imageProviderShutdownCalledNowFalse[0]);
     79                    imageProviderShutdownCalledNowTrue[0] = true;
     80                } else {
     81                    imageProviderShutdownCalledNowFalse[0] = true;
     82                }
     83            }
     84        };
     85        new MockUp<JCSCacheManager>() {
     86            @Mock
    7287            private void shutdown(Invocation invocation) {
    73                 imageProviderShutdownCalled[0] = true;
     88                jcsCacheManagerShutdownCalled[0] = true;
    7489            }
    7590        };
     
    7792        // No layer
    7893
    79         new ExitAction().actionPerformed(null);
    80 
    81         assertTrue(workerShutdownCalled[0]);
    82         assertTrue(workerShutdownNowCalled[0]);
    83         assertTrue(imageProviderShutdownCalled[0]);
     94        try {
     95            new ExitAction().actionPerformed(null);
     96        } finally {
     97            // ExpectedSystemExit presumably works using an exception, so executing anything after the
     98            // previous line requires it to be put in a finally block
     99            assertTrue(workerShutdownCalled[0]);
     100            assertTrue(workerShutdownNowCalled[0]);
     101            assertTrue(imageProviderShutdownCalledNowFalse[0]);
     102            assertTrue(imageProviderShutdownCalledNowTrue[0]);
     103            assertTrue(jcsCacheManagerShutdownCalled[0]);
     104        }
    84105    }
    85106}
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java

    r14116 r14126  
    4646     */
    4747    @Test
    48     @Ignore("Test fails since r14052 - see #16590")
    4948    public void testTMSLayer() throws Exception {
    5049        final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
Note: See TracChangeset for help on using the changeset viewer.