Changeset 16945 in josm


Ignore:
Timestamp:
2020-08-28T20:16:22+02:00 (4 weeks ago)
Author:
simon04
Message:

see #19696 - Fix unit tests

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

Legend:

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

    r13927 r16945  
    128128        new PostDownloadHandler(null, newFuture("testRunExceptionFuture")).run();
    129129        assertTrue(Logging.getLastErrorAndWarnings().toString(),
    130                 Logging.getLastErrorAndWarnings().contains("E: java.util.concurrent.ExecutionException: testRunExceptionFuture"));
     130                Logging.getLastErrorAndWarnings().stream()
     131                        .anyMatch(e -> e.endsWith("E: java.util.concurrent.ExecutionException: testRunExceptionFuture")));
    131132    }
    132133
     
    159160        new PostDownloadHandler(newTask(Arrays.asList("foo", new Exception("bar"), new Object())), newFuture(null)).run();
    160161        assertTrue(Logging.getLastErrorAndWarnings().toString(),
    161                 Logging.getLastErrorAndWarnings().contains("E: java.lang.Exception: bar"));
     162                Logging.getLastErrorAndWarnings().stream()
     163                        .anyMatch(e -> e.endsWith("E: java.lang.Exception: bar")));
    162164    }
    163165}
  • trunk/test/unit/org/openstreetmap/josm/tools/LoggingTest.java

    r12802 r16945  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    54import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertFalse;
     
    199198        Consumer<String> test = string -> {
    200199            assertTrue(string.startsWith("java.io.IOException: x"));
    201             assertTrue(string.indexOf("testLogWithStackTraceLevelThrowable") >= 0);
     200            assertTrue(string.contains("testLogWithStackTraceLevelThrowable"));
    202201        };
    203202        testLogCaptured(Logging.LEVEL_ERROR, test, () -> Logging.logWithStackTrace(Logging.LEVEL_ERROR, new IOException("x")));
     
    207206                () -> Logging.logWithStackTrace(Logging.LEVEL_TRACE, new IOException()));
    208207
    209         testLogCaptured(Logging.LEVEL_TRACE, string -> assertTrue(string.indexOf("Cause:") >= 0),
     208        testLogCaptured(Logging.LEVEL_TRACE, string -> assertTrue(string.contains("Cause:")),
    210209                () -> Logging.logWithStackTrace(Logging.LEVEL_TRACE, new IOException(new IOException())));
    211210
     
    268267
    269268        assertEquals(1, Logging.getLastErrorAndWarnings().size());
    270         assertEquals("W: x", Logging.getLastErrorAndWarnings().get(0));
     269        assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"));
    271270
    272271        Logging.setLogLevel(Logging.LEVEL_ERROR);
     
    278277
    279278        assertEquals(2, Logging.getLastErrorAndWarnings().size());
    280         assertArrayEquals(new Object[] {"W: x", "E: y"}, Logging.getLastErrorAndWarnings().toArray());
     279        assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"));
     280        assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().get(1).endsWith("E: y"));
    281281
    282282        // limit somewhere reasonable
  • trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java

    r16595 r16945  
    9292        assertTrue(cache.isEmpty());
    9393        String error = Logging.getLastErrorAndWarnings().get(0);
    94         assertTrue(error, error.startsWith("W: Failed to parse external taginfo data at "));
     94        assertTrue(error, error.contains("W: Failed to parse external taginfo data at "));
    9595        assertTrue(error, error.contains(": Invalid token=EOF at (line no=3,"));
    9696    }
Note: See TracChangeset for help on using the changeset viewer.