1 16 package net.sf.dozer.util.mapping.config; 17 18 import net.sf.dozer.util.mapping.DozerTestBase; 19 import net.sf.dozer.util.mapping.util.MapperConstants; 20 21 24 public class GlobalSettingsTest extends DozerTestBase { 25 26 public void testLoadDefaultPropFile_Default() { 27 GlobalSettings globalSettings = GlobalSettings.createNew(); 28 assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName()); 29 assertEquals("invalid loaded by file name", MapperConstants.DEFAULT_CONFIG_FILE, 30 globalSettings.getLoadedByFileName()); 31 } 32 33 public void testLoadDefaultPropFile_NotFound() { 34 String propFileName = String.valueOf(System.currentTimeMillis()); 35 System.setProperty(MapperConstants.CONFIG_FILE_SYS_PROP, propFileName); 36 GlobalSettings globalSettings = GlobalSettings.createNew(); 37 38 assertNull("loaded by file name should be null", globalSettings.getLoadedByFileName()); 40 assertEquals("invalid stats enabled value", MapperConstants.DEFAULT_STATISTICS_ENABLED, 41 globalSettings.getSettings().isStatisticsEnabled()); 42 assertEquals("invalid converter cache max size value", 43 MapperConstants.DEFAULT_CONVERTER_BY_DEST_TYPE_CACHE_MAX_SIZE, 44 globalSettings.getSettings().getConverterByDestTypeCacheMaxSize()); 45 assertEquals("invalid super type cache max size value", 46 MapperConstants.DEFAULT_SUPER_TYPE_CHECK_CACHE_MAX_SIZE, 47 globalSettings.getSettings().getSuperTypesCacheMaxSize()); 48 } 49 50 public void testLoadPropFile_SpecifiedViaSysProp() { 51 String propFileName = "samplecustomdozer.properties"; 52 System.setProperty(MapperConstants.CONFIG_FILE_SYS_PROP, propFileName); 53 54 GlobalSettings globalSettings = GlobalSettings.createNew(); 55 56 assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName()); 57 assertEquals("invalid load by file name", propFileName, globalSettings.getLoadedByFileName()); 58 assertEquals("invalid stats enabled value", true, globalSettings.getSettings().isStatisticsEnabled()); 59 assertEquals("invalid converter cache max size value", 25000, globalSettings.getSettings().getConverterByDestTypeCacheMaxSize()); 60 assertEquals("invalid super type cache max size value", 10000, globalSettings.getSettings().getSuperTypesCacheMaxSize()); 61 } 62 } 63 | Popular Tags |