Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/data/cache
- Timestamp:
- 2020-10-28T20:41:00+01:00 (3 years ago)
- 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 2 2 package org.openstreetmap.josm.data.cache; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 7 import java.io.IOException; … … 12 12 13 13 import org.apache.commons.jcs3.access.behavior.ICacheAccess; 14 import org.junit. Rule;15 import org.junit. Test;14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 16 16 import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader; 17 17 import org.openstreetmap.josm.data.imagery.TileJobOptions; … … 25 25 * @author Wiktor Niesiobedzki 26 26 */ 27 publicclass HostLimitQueueTest {27 class HostLimitQueueTest { 28 28 /** 29 29 * Setup test. 30 30 */ 31 @R ule31 @RegisterExtension 32 32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 33 33 public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20 * 1000); … … 79 79 */ 80 80 @Test 81 publicvoid testSingleThreadPerHost() throws Exception {81 void testSingleThreadPerHost() throws Exception { 82 82 ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 1); 83 83 ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, ""); … … 96 96 // so it should take ~8 seconds to finish 97 97 // 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)); 100 100 } 101 101 … … 105 105 */ 106 106 @Test 107 publicvoid testMultipleThreadPerHost() throws Exception {107 void testMultipleThreadPerHost() throws Exception { 108 108 ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 2); 109 109 ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, ""); … … 121 121 // so it should take ~5 seconds to finish 122 122 // 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)); 125 125 } 126 126 … … 130 130 */ 131 131 @Test 132 publicvoid testTwoHosts() throws Exception {132 void testTwoHosts() throws Exception { 133 133 ThreadPoolExecutor tpe = TMSCachedTileLoader.getNewThreadPoolExecutor("test-%d", 3, 1); 134 134 ICacheAccess<String, CacheEntry> cache = JCSCacheManager.getCache("test", 3, 0, ""); … … 147 147 // so it should take ~5 seconds to finish 148 148 // 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)); 151 151 } 152 152 } -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCacheManagerTest.java
r16398 r17275 2 2 package org.openstreetmap.josm.data.cache; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.io.File; … … 11 11 import org.apache.commons.jcs3.access.CacheAccess; 12 12 import org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskCacheAttributes; 13 import org.junit. Rule;14 import org.junit. Test;13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 16 … … 21 21 * Unit tests for class {@link JCSCacheManager}. 22 22 */ 23 publicclass JCSCacheManagerTest {23 class JCSCacheManagerTest { 24 24 25 25 /** 26 26 * Setup test. 27 27 */ 28 @R ule28 @RegisterExtension 29 29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 30 30 public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000); … … 35 35 */ 36 36 @Test 37 publicvoid testUtilityClass() throws ReflectiveOperationException {37 void testUtilityClass() throws ReflectiveOperationException { 38 38 UtilityClassTestUtil.assertUtilityClassWellDefined(JCSCacheManager.class); 39 39 } … … 44 44 */ 45 45 @Test 46 publicvoid testLoggingAdaptor12054() throws IOException {46 void testLoggingAdaptor12054() throws IOException { 47 47 JCSCacheManager.getCache("foobar", 1, 0, "foobar"); // cause logging adaptor to be initialized 48 48 Logger.getLogger("org.apache.commons.jcs3").warning("{switch:0}"); … … 50 50 51 51 @Test 52 publicvoid testUseBigDiskFile() throws IOException {52 void testUseBigDiskFile() throws IOException { 53 53 if (JCSCacheManager.USE_BLOCK_CACHE.get()) { 54 54 // test only when using block cache … … 65 65 66 66 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"); 69 70 } 70 71 }
Note:
See TracChangeset
for help on using the changeset viewer.