⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globalsettingstest.java

📁 一个javabean的转换与copy非常的好用希望大家好好研究一下
💻 JAVA
字号:
/*
 * Copyright 2005-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sf.dozer.util.mapping.config;

import net.sf.dozer.util.mapping.DozerTestBase;
import net.sf.dozer.util.mapping.util.MapperConstants;

/**
 * @author tierney.matt
 */
public class GlobalSettingsTest extends DozerTestBase {
  
  public void testLoadDefaultPropFile_Default() {
    GlobalSettings globalSettings = GlobalSettings.createNew();
    assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid loaded by file name", MapperConstants.DEFAULT_CONFIG_FILE,
        globalSettings.getLoadedByFileName());
  }
  
  public void testLoadDefaultPropFile_NotFound() {
    String propFileName = String.valueOf(System.currentTimeMillis()); 
    System.setProperty(MapperConstants.CONFIG_FILE_SYS_PROP, propFileName);
    GlobalSettings globalSettings = GlobalSettings.createNew();    

    //assert all global settings equal the default values 
    assertNull("loaded by file name should be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid stats enabled value", MapperConstants.DEFAULT_STATISTICS_ENABLED,
        globalSettings.getSettings().isStatisticsEnabled());
    assertEquals("invalid converter cache max size value", 
        MapperConstants.DEFAULT_CONVERTER_BY_DEST_TYPE_CACHE_MAX_SIZE, 
        globalSettings.getSettings().getConverterByDestTypeCacheMaxSize());
    assertEquals("invalid super type cache max size value", 
        MapperConstants.DEFAULT_SUPER_TYPE_CHECK_CACHE_MAX_SIZE, 
        globalSettings.getSettings().getSuperTypesCacheMaxSize());
  }
  
  public void testLoadPropFile_SpecifiedViaSysProp() {
    String propFileName = "samplecustomdozer.properties"; 
    System.setProperty(MapperConstants.CONFIG_FILE_SYS_PROP, propFileName);
    
    GlobalSettings globalSettings = GlobalSettings.createNew();
    
    assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid load by file name", propFileName, globalSettings.getLoadedByFileName());
    assertEquals("invalid stats enabled value", true, globalSettings.getSettings().isStatisticsEnabled());
    assertEquals("invalid converter cache max size value", 25000, globalSettings.getSettings().getConverterByDestTypeCacheMaxSize());
    assertEquals("invalid super type cache max size value", 10000, globalSettings.getSettings().getSuperTypesCacheMaxSize());
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -