亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testcache.java

?? oscache-2.4.1-full
?? JAVA
字號:
/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.oscache.base;

import java.util.Properties;

import com.opensymphony.oscache.general.GeneralCacheAdministrator;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Test the public methods of the Cache class
 *
 * $Id: TestCache.java 385 2006-10-07 06:57:10Z larst $
 * @version        $Revision: 385 $
 * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
 */
public class TestCache extends TestCase {
    // Static variables required thru all the tests
    private static Cache map = null;
    private final String CONTENT = "Content for the cache test";

    // Constants needed thru all the tests
    private final String ENTRY_KEY = "Test cache key";
    private final int NO_REFRESH_NEEDED = CacheEntry.INDEFINITE_EXPIRY;
    private final int REFRESH_NEEDED = 0;

    /**
     * Class constructor.
     * <p>
     * @param str The test name (required by JUnit)
     */
    public TestCache(String str) {
        super(str);
    }

    /**
     * This method is invoked before each testXXXX methods of the
     * class. It set ups the variables required for each tests.
     */
    public void setUp() {
        // At first invocation, create a new Cache
        if (map == null) {
            GeneralCacheAdministrator admin = new GeneralCacheAdministrator();
            map = admin.getCache();
            assertNotNull(map);
        }
    }

    /**
     * This methods returns the name of this test class to JUnit
     * <p>
     * @return The name of this class
     */
    public static Test suite() {
        return new TestSuite(TestCache.class);
    }

    /**
     * Verify that items may still be flushed by key pattern
     */
    public void testFlushPattern() {
        // Try to flush with a bad pattern and ensure that our data is still there
        map.putInCache(ENTRY_KEY, CONTENT);
        map.flushPattern(ENTRY_KEY + "do not flush");
        getBackContent(map, CONTENT, NO_REFRESH_NEEDED, false);

        // Flush our map for real
        map.flushPattern(ENTRY_KEY.substring(1, 2));
        getBackContent(map, CONTENT, NO_REFRESH_NEEDED, true);

        // Check invalid values
        map.flushPattern("");
        map.flushPattern(null);
    }

    /**
     * Tests that with a very large amount of keys that added and trigger cache overflows, there is no memory leak
     * @throws Exception
     */
    public void testBug174CacheOverflow() throws Exception {
        
        Properties p = new Properties();
		p.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY, "com.opensymphony.oscache.base.algorithm.LRUCache");
		p.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, "100");
		GeneralCacheAdministrator admin = new GeneralCacheAdministrator(p);
        
        int cacheCapacity = 100;
		int maxAddedCacheEntries = cacheCapacity*10;
        String baseCacheKey= "baseKey";
        String cacheValue ="same_value";

		admin.setCacheCapacity(cacheCapacity);
    	
        Cache cache = admin.getCache();

        //Add lots of different keys to trigger cache overflow
		for (int keyIndex=0; keyIndex<maxAddedCacheEntries; keyIndex++) {
			String key = baseCacheKey + keyIndex;
			admin.putInCache(key, cacheValue);
		}
        
		Assert.assertEquals("expected cache to be at its full capacity", cacheCapacity , cache.getSize());
		Assert.assertTrue("expected cache overflows to have cleaned UpdateState instances. got [" + cache.getNbUpdateState() + "] updates while max is [" + cacheCapacity + "]", cache.getNbUpdateState() <= cacheCapacity);
    }

    /**
     * Tests that with a very large amount of keys that added and trigger cache overflows, there is no memory leak
     * @throws Exception
     */
    public void testBug174CacheOverflowAndUpdate() throws Exception {
    	Properties p = new Properties();
		p.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY, "com.opensymphony.oscache.base.algorithm.LRUCache");
		p.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, "100");
		GeneralCacheAdministrator admin = new GeneralCacheAdministrator(p);
        
        int cacheCapacity = 100;
		int maxAddedCacheEntries = cacheCapacity*10;
        String baseCacheKey= "baseKey";
        String cacheValue ="same_value";

		admin.setCacheCapacity(cacheCapacity);
    	
        Cache cache = admin.getCache();

        
        //Add lots of different keys to trigger cache overflow, mixed with updates
		//FIXME: we may need different threads to enter branches recovering from current update.  
		for (int keyIndex=0; keyIndex<maxAddedCacheEntries; keyIndex++) {
			String key = baseCacheKey + keyIndex;
			admin.putInCache(key, cacheValue);
			
			try {
				admin.getFromCache(key, 0);
				fail("expected element [" + key + "] not to be present");
			} catch (NeedsRefreshException e) {
				admin.putInCache(key, cacheValue);
			}
		}
        
		Assert.assertEquals("expected cache to be at its full capacity", cacheCapacity , cache.getSize());
		Assert.assertTrue("expected cache overflows to have cleaned UpdateState instances. Nb states is:" + cache.getNbUpdateState() + " expected max="+ cacheCapacity, cache.getNbUpdateState() <= cacheCapacity);
    }

    
    /**
     * Tests that with a very large amount of keys accessed and cancelled, there is no memory leak
     * @throws Exception
     */
    public void testBug174CacheMissesNonBlocking() throws Exception {
    	testBug174CacheMisses(false);
    }
    
    /**
     * Tests that with a very large amount of keys accessed and cancelled, there is no memory leak
     * @throws Exception
     */
    public void testBug174CacheMissesBlocking() throws Exception {
    	testBug174CacheMisses(true);
    }

    /**
     * Tests that with a very large amount of keys accessed and cancelled, there is no memory leak
     * @throws Exception
     */
    public void testBug174CacheMisses(boolean block) throws Exception {
    	Properties p = new Properties();
		p.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY, "com.opensymphony.oscache.base.algorithm.LRUCache");
		p.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, "100");
		if (block) {
			p.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY, "true");
		}
		GeneralCacheAdministrator admin = new GeneralCacheAdministrator(p);
        
        int cacheCapacity = 100;
		int maxAddedCacheEntries = cacheCapacity*10;
        String baseCacheKey= "baseKey";
        //String cacheValue ="same_value";
        
		admin.setCacheCapacity(cacheCapacity);
    	
        Cache cache = admin.getCache();

        //Access lots of different keys to trigger cache overflow
		for (int keyIndex=0; keyIndex<maxAddedCacheEntries; keyIndex++) {
			String key = baseCacheKey + keyIndex;
			try {
				admin.getFromCache(key);
				fail("expected element [" + key + "] not to be present");
			} catch (NeedsRefreshException e) {
				admin.cancelUpdate(key);
			}
		}
        
		Assert.assertTrue("expected cache accesses to not leak past cache capacity. Nb states is:" + cache.getNbUpdateState() + " expected max="+ cacheCapacity, cache.getNbUpdateState() < cacheCapacity);
    }
    
    /**
     * Verify that we can put item in the cache and that they are correctly retrieved
     */
    public void testPutGetFromCache() {
        // We put content in the cache and get it back with and without refresh
        map.putInCache(ENTRY_KEY, CONTENT);
        getBackContent(map, CONTENT, NO_REFRESH_NEEDED, false);
        getBackContent(map, CONTENT, REFRESH_NEEDED, true);

        // Test with invalid values

        /** TODO Verify this logic */
        try {
            assertNull(map.getFromCache("", NO_REFRESH_NEEDED));
        } catch (NeedsRefreshException nre) {
            map.cancelUpdate("");
        } catch (Exception e) {
        }

        try {
            assertNull(map.getFromCache(null, NO_REFRESH_NEEDED));
        } catch (NeedsRefreshException nre) {
            map.cancelUpdate(null);
        } catch (Exception e) {
        }
    }

    /**
     * Verify that we can put item in the cache and that they are correctly retrieved
     */
    public void testPutGetFromCacheWithPolicy() {
        // We put content in the cache and get it back
        map.putInCache(ENTRY_KEY + "policy", CONTENT, new DummyAlwayRefreshEntryPolicy());

        // Should get a refresh
        try {
            map.getFromCache(ENTRY_KEY + "policy", -1);
            fail("Should have got a refresh.");
        } catch (NeedsRefreshException nre) {
            map.cancelUpdate(ENTRY_KEY + "policy");
        }
    }

    protected void tearDown() throws Exception {
        if (map != null) {
            map.clear();
        }
    }

    /**
     * Retrieve the content in the cache
     * <p>
     * @param map       The Cache in which the data is stored
     * @param content   The content expected to be retrieved
     * @param refresh   Time interval to determine if the cache object needs refresh
     * @param exceptionExpected Specify if a NeedsRefreshException is expected
     */
    private void getBackContent(Cache map, Object content, int refresh, boolean exceptionExpected) {
        try {
            assertEquals(content, map.getFromCache(ENTRY_KEY, refresh));

            if (exceptionExpected) {
                fail("NeedsRefreshException should have been thrown!");
            }
        } catch (NeedsRefreshException nre) {
            map.cancelUpdate(ENTRY_KEY);

            if (!exceptionExpected) {
                fail("NeedsRefreshException shouldn't have been thrown!");
            }
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久小美女| 不卡电影免费在线播放一区| 91麻豆精品国产综合久久久久久| 一区二区三区欧美在线观看| 欧美日韩一区二区三区在线看 | 精品国产亚洲在线| 国内精品视频一区二区三区八戒| 欧美韩国日本不卡| 99精品在线观看视频| 亚洲综合视频在线| 欧美理论在线播放| 国内精品视频666| 亚洲日本电影在线| 欧美日韩在线一区二区| 97精品国产97久久久久久久久久久久| 国产日本欧美一区二区| 一本大道久久a久久精二百| 一区二区三区在线免费| 日韩精品一区二区三区在线播放| 国产精品亚洲午夜一区二区三区| 中文字幕一区二区三区乱码在线| 欧美亚洲国产bt| 九色porny丨国产精品| 国产精品不卡一区| 欧美一区二区精美| 成人免费高清在线| 日韩影院免费视频| 国产亲近乱来精品视频| 欧美视频一二三区| 国产99久久久精品| 青草国产精品久久久久久| 国产精品污网站| 9191久久久久久久久久久| 高清beeg欧美| 天天操天天色综合| 国产精品理论片在线观看| 51久久夜色精品国产麻豆| 国产精品一二一区| 午夜一区二区三区视频| 国产亚洲人成网站| 欧美一级免费大片| 91色九色蝌蚪| 国产精品一二三四五| 亚洲国产精品久久久男人的天堂 | 国产一区二区免费看| 亚洲日本在线看| 久久亚洲精精品中文字幕早川悠里 | 国模少妇一区二区三区| 夜色激情一区二区| 国产精品欧美久久久久无广告| 欧美精品123区| 91在线播放网址| 国产美女娇喘av呻吟久久| 香港成人在线视频| 亚洲欧美日韩小说| 中文字幕亚洲在| 久久久久国产一区二区三区四区| 欧美疯狂做受xxxx富婆| 在线观看91精品国产入口| 成人av电影在线观看| 国产福利一区二区三区视频| 麻豆91精品视频| 日韩精品电影在线| 亚洲图片欧美视频| 一区二区三区欧美日韩| 成人欧美一区二区三区小说| 国产拍揄自揄精品视频麻豆| 欧美精品一区二区三区在线| 337p亚洲精品色噜噜噜| 欧美日韩中文字幕一区| 色婷婷综合在线| 99国产精品久| www.欧美日韩国产在线| 国产成人午夜精品影院观看视频| 美女视频免费一区| 美女视频一区在线观看| 男人的天堂久久精品| 日本伊人午夜精品| 日本伊人色综合网| 青青草成人在线观看| 日韩国产一区二| 日韩精彩视频在线观看| 日本最新不卡在线| 久久精品久久综合| 精品无码三级在线观看视频| 国内成人自拍视频| 国产精品911| 99re视频精品| 欧美日韩一区二区三区不卡| 欧美撒尿777hd撒尿| 欧美日韩午夜影院| 日韩一区二区三免费高清| 日韩欧美不卡在线观看视频| 精品国产免费人成在线观看| 中文字幕欧美激情| 夜夜爽夜夜爽精品视频| 天堂影院一区二区| 久久99精品久久久久| 粉嫩一区二区三区性色av| 91麻豆福利精品推荐| 欧美日韩不卡一区| 久久久久久久综合| 亚洲免费av观看| 首页综合国产亚洲丝袜| 国模无码大尺度一区二区三区| 成人免费毛片app| 欧美午夜一区二区三区免费大片| 日韩精品在线一区二区| 国产精品乱码一区二三区小蝌蚪| 亚洲精品水蜜桃| 免费欧美在线视频| 国产suv精品一区二区6| 日本乱人伦aⅴ精品| 69成人精品免费视频| 久久久久久99久久久精品网站| 亚洲少妇最新在线视频| 免费观看久久久4p| a4yy欧美一区二区三区| 欧美日韩午夜影院| 欧美国产1区2区| 五月婷婷久久丁香| 成人一区二区视频| 欧美巨大另类极品videosbest | 日本韩国一区二区| 精品欧美久久久| 依依成人综合视频| 国产毛片精品视频| 欧美精品日日鲁夜夜添| 国产精品久久久久影院色老大| 亚洲第一福利视频在线| 成人激情动漫在线观看| 日韩精品一区在线| 亚洲综合丁香婷婷六月香| 国产精品自拍一区| 91精品国产麻豆国产自产在线| 国产精品伦一区| 韩国精品主播一区二区在线观看| 在线观看一区二区视频| 日本一区二区综合亚洲| 另类专区欧美蜜桃臀第一页| 色中色一区二区| 中文字幕高清一区| 欧美一区二区三区日韩| 亚洲激情第一区| av一本久道久久综合久久鬼色| 欧美岛国在线观看| 亚洲成a人v欧美综合天堂下载| 成+人+亚洲+综合天堂| 欧美精品一区二| 裸体健美xxxx欧美裸体表演| 欧美电影影音先锋| 亚洲高清视频在线| 色视频成人在线观看免| 日韩伦理免费电影| 成人高清视频在线观看| 久久久久国产精品麻豆ai换脸| 老司机午夜精品99久久| 欧美一区二区三区的| 五月天久久比比资源色| 欧美中文字幕一区二区三区亚洲 | 亚洲黄一区二区三区| 粉嫩13p一区二区三区| 久久婷婷国产综合精品青草 | 一区二区三区精品久久久| 国产福利精品一区二区| 久久综合九色综合97婷婷| 久久精品99久久久| 精品美女在线播放| 久久se精品一区二区| 精品精品国产高清a毛片牛牛| 久久www免费人成看片高清| 精品国产电影一区二区| 精品一区二区三区免费视频| 精品成人一区二区三区四区| 精品一区在线看| 久久久久久**毛片大全| 成人午夜av电影| 亚洲色大成网站www久久九九| 99视频国产精品| 亚洲一区二区av电影| 欧美日韩国产a| 久久精品国产久精国产爱| 欧美mv和日韩mv的网站| 国产成人av电影免费在线观看| 国产精品久久久久久久浪潮网站 | 欧美激情一区二区| av在线不卡免费看| 一区二区成人在线| 欧美一区二区三区色| 国产一区二区三区免费播放 | 色噜噜久久综合| 亚洲第一狼人社区| ww久久中文字幕| 99精品视频在线观看| 亚洲3atv精品一区二区三区| 精品欧美一区二区久久| av毛片久久久久**hd| 午夜精品久久久久久久久久| 欧美成人一区二区三区| 成人的网站免费观看|