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

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

?? testconcurrency.java

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

import com.opensymphony.oscache.general.GeneralCacheAdministrator;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.BitSet;
import java.util.Properties;

/**
 * Test the Cache class for any concurrency problems
 *
 * $Id: TestConcurrency.java 404 2007-02-24 10:21:00Z larst $
 * @version        $Revision: 404 $
 * @author <a href="mailto:chris@chris.com">Chris Miller</a>
 */
public class TestConcurrency extends TestCase {
    private static transient final Log log = LogFactory.getLog(GeneralCacheAdministrator.class); //TestConcurrency.class

    // Static variables required thru all the tests
    private static GeneralCacheAdministrator admin = null;

    // Constants needed in the tests
    private final String KEY = "key";
    private final String VALUE = "This is some content";
    private final int ITERATION_COUNT = 5; //500;
    private final int THREAD_COUNT = 6; //600;
    private final int UNIQUE_KEYS = 1013;

    /**
     * Class constructor.
     * <p>
     * @param str The test name (required by JUnit)
     */
    public TestConcurrency(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 (admin == null) {
            Properties config = new Properties();
            config.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, "70");
            config.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY, "false");
            admin = new GeneralCacheAdministrator();
            assertNotNull(admin);
        }
    }

    /**
     * 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(TestConcurrency.class);
    }

    /**
     * Check that the cache handles simultaneous attempts to access a
     * new cache entry correctly
     */
    public void testNewEntry() {
        String key = "new";

        try {
            admin.getFromCache(key, -1);
            fail("NeedsRefreshException should have been thrown");
        } catch (NeedsRefreshException nre) {
            // Fire off another couple of threads to get the same cache entry
            GetEntry getEntry = new GetEntry(key, VALUE, -1, false);
            Thread thread = new Thread(getEntry);
            thread.start();
            getEntry = new GetEntry(key, VALUE, -1, false);
            thread = new Thread(getEntry);
            thread.start();

            // OK, those threads should now be blocked waiting for the new cache
            // entry to appear. Sleep for a bit to simulate the time taken to
            // build the cache entry
            try {
                Thread.sleep(500);
            } catch (InterruptedException ie) {
            }

            // Putting the entry in the cache should unblock the previous threads
            admin.putInCache(key, VALUE);
        }
    }

    /**
     * Check that the cache handles simultaneous attempts to access a
     * new cache entry correctly
     */
    public void testNewEntryCancel() {
        String key = "newCancel";
        String NEW_VALUE = VALUE + "...";

        try {
            admin.getFromCache(key, -1);
            fail("NeedsRefreshException should have been thrown");
        } catch (NeedsRefreshException nre) {
            // Fire off another thread to get the same cache entry
            GetEntry getEntry = new GetEntry(key, NEW_VALUE, -1, true);
            Thread thread = new Thread(getEntry);
            thread.start();

            // The above thread will be blocked waiting for the new content
            try {
                Thread.sleep(500);
            } catch (InterruptedException ie) {
            }

            // Now cancel the update (eg because an exception occurred while building the content).
            // This will unblock the other thread and it will receive a NeedsRefreshException.
            admin.cancelUpdate(key);

            // Wait a bit for the other thread to update the cache
            try {
                Thread.sleep(500);
            } catch (InterruptedException ie) {
            }

            try {
                Object newValue = admin.getFromCache(key, -1);
                assertEquals(NEW_VALUE, newValue);
            } catch (NeedsRefreshException e) {
                admin.cancelUpdate(key);
                fail("A NeedsRefreshException should not have been thrown");
            }
        }
    }

    /**
     * Verify that we can concurrently access the cache without problems
     */
    public void testPut() {
        Thread[] thread = new Thread[THREAD_COUNT];

        for (int idx = 0; idx < THREAD_COUNT; idx++) {
            OSGeneralTest runner = new OSGeneralTest();
            thread[idx] = new Thread(runner);
            thread[idx].start();
        }

        boolean stillAlive;

        do {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // do nothing
            }

            stillAlive = false;

            int i = 0;

            while ((i < thread.length) && !stillAlive) {
                stillAlive |= thread[i++].isAlive();
            }
        } while (stillAlive);
    }

    /**
     * Check that the cache handles simultaneous attempts to access a
     * stale cache entry correctly
     */
    public void testStaleEntry() {
        String key = "stale";
        assertFalse("The cache should not be in blocking mode for this test.", admin.isBlocking());

        admin.putInCache(key, VALUE);

        try {
            // This should throw a NeedsRefreshException since the refresh
            // period is 0
            admin.getFromCache(key, 0);
            fail("NeedsRefreshException should have been thrown");
        } catch (NeedsRefreshException nre) {
            // Fire off another thread to get the same cache entry.
            // Since blocking mode is currently disabled we should
            // immediately get back the stale entry
            GetEntry getEntry = new GetEntry(key, VALUE, 0, false);
            Thread thread = new Thread(getEntry);
            thread.start();

            // Sleep for a bit to simulate the time taken to build the cache entry
            try {
                Thread.sleep(200);
            } catch (InterruptedException ie) {
            }

            // Putting the entry in the cache should mean that threads now retrieve
            // the updated entry
            String newValue = "New value";
            admin.putInCache(key, newValue);

            getEntry = new GetEntry(key, newValue, -1, false);
            thread = new Thread(getEntry);
            thread.start();

            try {
                Object fromCache = admin.getFromCache(key, -1);
                assertEquals(newValue, fromCache);
            } catch (NeedsRefreshException e) {
                admin.cancelUpdate(key);
                fail("Should not have received a NeedsRefreshException");
            }

            // Give the GetEntry thread a chance to finish
            try {
                Thread.sleep(200);
            } catch (InterruptedException ie) {
            }
        }
    }

    /**
     * A test for the updating of a stale entry when CACHE.BLOCKING = TRUE
     */
    public void testStaleEntryBlocking() {
        // A test for the case where oscache.blocking = true
        admin.destroy();

        Properties p = new Properties();
        p.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY, "true");
        admin = new GeneralCacheAdministrator(p);

        assertTrue("The cache should be in blocking mode for this test.", admin.isBlocking());

        // Use a unique key in case these test entries are being persisted

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成a人片在线不卡一二三区| 国产成人免费视频网站| 在线视频你懂得一区| 日韩毛片一二三区| 欧美性三三影院| 天天av天天翘天天综合网| 欧美日韩国产首页在线观看| 奇米在线7777在线精品 | 亚洲欧美日韩在线| 99国产精品久久久久久久久久久| 亚洲人一二三区| 欧美久久久久久蜜桃| 美女爽到高潮91| 欧美激情一区二区三区在线| 91福利在线免费观看| 亚洲成人av一区二区三区| 欧美大片一区二区三区| 国产福利一区二区三区视频在线| **欧美大码日韩| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲一区二区三区中文字幕在线| 欧美久久久久久久久| 国产美女娇喘av呻吟久久| 国产精品久久毛片av大全日韩| 欧美性感一区二区三区| 精品一区二区日韩| 中文字幕在线观看一区| 7777精品久久久大香线蕉| 国产精品一区二区x88av| 亚洲精品亚洲人成人网| 制服丝袜亚洲精品中文字幕| 国产99一区视频免费| 午夜天堂影视香蕉久久| 国产色产综合色产在线视频| 欧美日韩精品三区| 丁香网亚洲国际| 日韩专区一卡二卡| 综合色中文字幕| 精品国产污污免费网站入口| 日本高清免费不卡视频| 国产成人午夜99999| 亚洲国产wwwccc36天堂| 国产精品私人自拍| 日韩写真欧美这视频| 色婷婷亚洲综合| 国产精品一二三区| 免费看精品久久片| 午夜私人影院久久久久| 亚洲私人黄色宅男| 久久无码av三级| 欧美一区二区三区成人| 色拍拍在线精品视频8848| 高清不卡在线观看av| 九九九久久久精品| 天天影视色香欲综合网老头| 一卡二卡三卡日韩欧美| 中文字幕一区二区三| 久久亚洲一区二区三区四区| 日韩久久久久久| 91麻豆精品国产91久久久更新时间| 99精品久久免费看蜜臀剧情介绍| 国产呦精品一区二区三区网站| 青青草原综合久久大伊人精品 | 成人在线综合网| 久久国产精品一区二区| 日韩二区三区四区| 天天色天天爱天天射综合| 亚洲va欧美va人人爽午夜| 一二三区精品视频| 亚洲免费观看在线视频| 中文字幕av一区二区三区| 国产午夜精品久久| 国产日韩成人精品| 国产欧美在线观看一区| 久久人人超碰精品| 国产亚洲女人久久久久毛片| 国产亚洲精品7777| 国产精品污www在线观看| 中文字幕欧美三区| 国产精品丝袜91| 亚洲私人影院在线观看| 夜夜嗨av一区二区三区网页| 樱花影视一区二区| 亚洲动漫第一页| 天堂精品中文字幕在线| 久久国产尿小便嘘嘘尿| 国产高清一区日本| 成人av在线观| 欧美主播一区二区三区美女| 欧美日本一区二区在线观看| 91精品国产欧美一区二区| 欧美成人精品福利| 国产免费成人在线视频| 国产精品成人免费| 一区二区三区视频在线观看| 亚洲国产婷婷综合在线精品| 日韩精品1区2区3区| 精品一区二区在线看| 国产91综合网| 一本色道久久综合狠狠躁的推荐| 欧美视频一区二区三区在线观看 | 99久久综合狠狠综合久久| 99久久久无码国产精品| 在线观看网站黄不卡| 在线播放视频一区| 国产亚洲欧美激情| 亚洲一级二级三级| 精品一区二区三区视频| 成人在线综合网| 欧美精品一二三| 久久精品人人做人人综合 | 日韩一区二区在线看| 久久婷婷综合激情| 亚洲伊人伊色伊影伊综合网| 久久精品久久精品| 色综合激情五月| 欧美不卡一区二区| 亚洲激情一二三区| 美女mm1313爽爽久久久蜜臀| 99久久精品国产导航| 欧美电影一区二区三区| 中国色在线观看另类| 视频一区在线播放| 国产999精品久久久久久| 91 com成人网| 最新日韩av在线| 久久超碰97中文字幕| 在线观看亚洲精品视频| 久久免费国产精品| 日韩精品一级中文字幕精品视频免费观看| 国产精品亚洲综合一区在线观看| 在线影视一区二区三区| 久久久久久久久久久久久女国产乱| 亚洲乱码中文字幕综合| 国产精品一区在线观看你懂的| 欧美日韩另类国产亚洲欧美一级| 国产精品理伦片| 国产精品系列在线播放| 91精品欧美综合在线观看最新 | 国产午夜亚洲精品午夜鲁丝片| 亚洲午夜av在线| 99久久精品国产精品久久| 久久久精品国产免大香伊| 日韩**一区毛片| 欧美日韩国产高清一区二区三区| 亚洲日韩欧美一区二区在线| 风间由美一区二区av101 | 日本欧美一区二区在线观看| 91国产丝袜在线播放| 国产精品美女一区二区在线观看| 精品一区二区三区久久久| 欧美一区二区三区精品| 午夜精品福利一区二区蜜股av | 日韩电影在线观看网站| 欧美日韩综合在线| 亚洲综合丁香婷婷六月香| 色综合久久中文字幕| 中文字幕欧美一区| eeuss鲁片一区二区三区 | 欧美亚洲自拍偷拍| 99国产精品久久久久| 精品国产免费一区二区三区四区| 偷拍一区二区三区| 色哟哟一区二区| 亚洲免费观看高清| 国产一区二区在线影院| 欧美一区二区观看视频| 日韩精品一级二级| 欧美性xxxxxxxx| 亚洲国产精品一区二区www| 国产精品资源在线看| 黑人巨大精品欧美黑白配亚洲| 日本不卡一区二区三区 | 色一情一乱一乱一91av| 久久91精品久久久久久秒播| 一区二区三区成人| 久久精品水蜜桃av综合天堂| 狠狠色狠狠色合久久伊人| 亚洲桃色在线一区| 日韩精品一区二区三区三区免费| 一区二区三区在线播| 精品视频1区2区| 亚洲韩国精品一区| 制服丝袜中文字幕一区| 久久精品国产在热久久| 欧美一级高清大全免费观看| 韩国毛片一区二区三区| 久久视频一区二区| 激情综合色丁香一区二区| 欧美videos中文字幕| 激情综合网av| 亚洲精品在线免费播放| 激情综合色丁香一区二区| 久久久蜜臀国产一区二区| 国产一区二区看久久| 欧美国产成人精品| 91在线码无精品| 麻豆精品久久久| 久久午夜羞羞影院免费观看| 91美女在线看|