Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (3 years ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/cache/HostLimitQueueTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.data.cache;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.io.IOException;
     
    1212
    1313import org.apache.commons.jcs3.access.behavior.ICacheAccess;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1616import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader;
    1717import org.openstreetmap.josm.data.imagery.TileJobOptions;
     
    2525 * @author Wiktor Niesiobedzki
    2626 */
    27 public class HostLimitQueueTest {
     27class HostLimitQueueTest {
    2828    /**
    2929     * Setup test.
    3030     */
    31     @Rule
     31    @RegisterExtension
    3232    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3333    public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20 * 1000);
     
    7979     */
    8080    @Test
    81     public void testSingleThreadPerHost() throws Exception {
     81    void testSingleThreadPerHost() throws Exception {
    8282        ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 1);
    8383        ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, "");
     
    9696        // so it should take ~8 seconds to finish
    9797        // if it's shorter, it means that host limit does not work
    98         assertTrue("Expected duration between 8 and 11 seconds not met. Actual duration: " + (duration /1000),
    99                 duration < 11*1000 & duration > 8*1000);
     98        assertTrue(duration < 11*1000 & duration > 8*1000,
     99                "Expected duration between 8 and 11 seconds not met. Actual duration: " + (duration /1000));
    100100    }
    101101
     
    105105     */
    106106    @Test
    107     public void testMultipleThreadPerHost() throws Exception {
     107    void testMultipleThreadPerHost() throws Exception {
    108108        ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 2);
    109109        ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, "");
     
    121121        // so it should take ~5 seconds to finish
    122122        // if it's shorter, it means that host limit does not work
    123         assertTrue("Expected duration between 4 and 6 seconds not met. Actual duration: " + (duration /1000),
    124                 duration < 6*1000 & duration > 4*1000);
     123        assertTrue(duration < 6*1000 & duration > 4*1000,
     124                "Expected duration between 4 and 6 seconds not met. Actual duration: " + (duration /1000));
    125125    }
    126126
     
    130130     */
    131131    @Test
    132     public void testTwoHosts() throws Exception {
     132    void testTwoHosts() throws Exception {
    133133        ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 1);
    134134        ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, "");
     
    147147        // so it should take ~5 seconds to finish
    148148        // if it's shorter, it means that host limit does not work
    149         assertTrue("Expected duration between 4 and 6 seconds not met. Actual duration: " + (duration /1000),
    150                 duration < 6*1000 & duration > 4*1000);
     149        assertTrue(duration < 6*1000 & duration > 4*1000,
     150                "Expected duration between 4 and 6 seconds not met. Actual duration: " + (duration /1000));
    151151    }
    152152}
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCacheManagerTest.java

    r16398 r17275  
    22package org.openstreetmap.josm.data.cache;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.io.File;
     
    1111import org.apache.commons.jcs3.access.CacheAccess;
    1212import org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskCacheAttributes;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
     
    2121 * Unit tests for class {@link JCSCacheManager}.
    2222 */
    23 public class JCSCacheManagerTest {
     23class JCSCacheManagerTest {
    2424
    2525    /**
    2626     * Setup test.
    2727     */
    28     @Rule
     28    @RegisterExtension
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3030    public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000);
     
    3535     */
    3636    @Test
    37     public void testUtilityClass() throws ReflectiveOperationException {
     37    void testUtilityClass() throws ReflectiveOperationException {
    3838        UtilityClassTestUtil.assertUtilityClassWellDefined(JCSCacheManager.class);
    3939    }
     
    4444     */
    4545    @Test
    46     public void testLoggingAdaptor12054() throws IOException {
     46    void testLoggingAdaptor12054() throws IOException {
    4747        JCSCacheManager.getCache("foobar", 1, 0, "foobar"); // cause logging adaptor to be initialized
    4848        Logger.getLogger("org.apache.commons.jcs3").warning("{switch:0}");
     
    5050
    5151    @Test
    52     public void testUseBigDiskFile() throws IOException {
     52    void testUseBigDiskFile() throws IOException {
    5353        if (JCSCacheManager.USE_BLOCK_CACHE.get()) {
    5454            // test only when using block cache
     
    6565
    6666            CacheAccess<Object, Object> cache = JCSCacheManager.getCache("testUseBigDiskFile", 1, 100, "foobar");
    67             assertEquals("BlockDiskCache use file size to calculate its size", 10*1024,
    68                     ((BlockDiskCacheAttributes) cache.getCacheControl().getAuxCaches()[0].getAuxiliaryCacheAttributes()).getMaxKeySize());
     67            assertEquals(10*1024,
     68                    ((BlockDiskCacheAttributes) cache.getCacheControl().getAuxCaches()[0].getAuxiliaryCacheAttributes()).getMaxKeySize(),
     69                    "BlockDiskCache use file size to calculate its size");
    6970        }
    7071    }
Note: See TracChangeset for help on using the changeset viewer.