亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产成人丝袜美腿| 国产精品另类一区| 久久久久久久久久看片| 国产日韩精品久久久| 亚洲日本在线观看| 日韩av在线免费观看不卡| 久久精品二区亚洲w码| 成人免费高清在线| 欧美丝袜丝nylons| 26uuu国产电影一区二区| 亚洲丝袜精品丝袜在线| 蜜臀av一区二区三区| 不卡区在线中文字幕| 欧美日本国产视频| 国产欧美日韩在线视频| 亚洲成av人片一区二区梦乃| 国产一区二区影院| 欧美性大战久久久| 国产精品视频你懂的| 午夜精品久久久久久久久| 国产传媒一区在线| 欧美一区二区免费视频| 日韩美女视频一区| 久久99日本精品| 91福利国产精品| 久久精品一区二区| 日韩国产高清影视| 91麻豆国产在线观看| 26uuu久久天堂性欧美| 亚洲aaa精品| 成人免费视频视频| 2022国产精品视频| 性做久久久久久久免费看| 风间由美性色一区二区三区| 5566中文字幕一区二区电影 | 色婷婷激情久久| 精品福利一区二区三区免费视频| 欧美天堂一区二区三区| 欧美激情一区二区三区蜜桃视频| 国产性做久久久久久| 视频一区视频二区在线观看| 成人免费视频播放| 26uuu国产电影一区二区| 手机精品视频在线观看| 色网综合在线观看| 国产精品国产三级国产普通话三级 | 国产午夜精品久久久久久免费视| 欧美高清在线一区| 韩国三级在线一区| 欧美一区二区三区视频免费播放| 精品久久免费看| 香蕉久久夜色精品国产使用方法 | 精品国产一区二区精华| 亚洲一区二区三区爽爽爽爽爽| 日韩成人精品在线| 欧美日韩一区视频| 中文字幕在线一区免费| 国产精品一二三| 欧美成人精品3d动漫h| 日韩av网站免费在线| 欧美色图激情小说| 亚洲最色的网站| 一本大道久久a久久精品综合| 91精品国产91热久久久做人人 | 国产suv精品一区二区三区| 精品日韩一区二区三区免费视频| 中文字幕免费观看一区| 精品亚洲成a人在线观看| 日韩免费高清视频| 日本不卡在线视频| 欧美一区二区三区免费观看视频| 国产午夜精品福利| 国产精品亚洲一区二区三区妖精| 色菇凉天天综合网| 亚洲综合清纯丝袜自拍| 色欧美乱欧美15图片| 曰韩精品一区二区| 一本久道中文字幕精品亚洲嫩| 日韩一区二区在线看片| 美国十次综合导航| 精品久久久影院| 国产美女一区二区三区| 久久久久久久国产精品影院| 国产成人一区二区精品非洲| 中文字幕免费观看一区| av在线一区二区| 亚洲一区二区在线免费观看视频| 成人一级黄色片| 中文字幕一区二区三区在线播放| 日精品一区二区| 日韩欧美黄色影院| 国产久卡久卡久卡久卡视频精品| 欧美三级日韩三级国产三级| 日韩电影在线一区二区三区| 日韩视频一区二区| 国产精品69毛片高清亚洲| 国产精品久久久久久久久图文区 | 日韩一级片网站| 国模少妇一区二区三区| 欧美激情综合五月色丁香| 成人aaaa免费全部观看| 亚洲综合激情小说| 日韩视频免费观看高清完整版在线观看 | 成人午夜在线播放| 亚洲日本一区二区| 欧美猛男超大videosgay| 久久99日本精品| 国产精品国产自产拍高清av王其| 国产一区二区日韩精品| 国产精品乱子久久久久| 91成人网在线| 久久国产福利国产秒拍| 中文字幕色av一区二区三区| 欧美曰成人黄网| 久久99国内精品| 日韩理论片在线| 91精品国产综合久久福利软件| 偷窥少妇高潮呻吟av久久免费| 色欲综合视频天天天| 日韩精品1区2区3区| 精品国产乱码久久久久久浪潮| 麻豆成人久久精品二区三区红 | 日韩成人精品视频| 国产精品午夜在线观看| 欧美网站一区二区| 国产福利不卡视频| 亚洲第一会所有码转帖| 国产日韩精品一区二区三区| 欧美精品丝袜中出| 成人av中文字幕| 日韩高清欧美激情| 中文字幕五月欧美| 精品国精品国产尤物美女| 色呦呦国产精品| 国产精品一二三区在线| 亚洲国产精品久久久男人的天堂| 欧美日韩夫妻久久| 成人av中文字幕| 精品一区二区影视| 亚洲国产成人av| 国产色一区二区| 欧美一区二区三区影视| 99视频有精品| 国产一本一道久久香蕉| 丝袜a∨在线一区二区三区不卡| 91麻豆精品国产自产在线| 99国产欧美另类久久久精品| 精品在线播放免费| 亚洲电影视频在线| 亚洲欧美自拍偷拍| 久久久久久久综合日本| 91精品国产黑色紧身裤美女| 99久久国产免费看| 岛国精品在线观看| 激情六月婷婷久久| 三级成人在线视频| 亚洲影视资源网| 国产精品福利av| 国产女人aaa级久久久级| 日韩精品中文字幕在线不卡尤物 | 337p粉嫩大胆色噜噜噜噜亚洲| 高清在线成人网| 精品一区二区三区影院在线午夜| 国产欧美精品一区二区色综合 | 国产精品久久久久久久久久久免费看 | 在线视频你懂得一区| 99精品热视频| 国产**成人网毛片九色| 九色综合国产一区二区三区| 日日夜夜一区二区| 香蕉影视欧美成人| 亚洲高清免费观看高清完整版在线观看| 日韩一区二区高清| 91精品国产麻豆| 91麻豆精品国产91久久久久| 欧洲精品一区二区三区在线观看| 另类小说色综合网站| 男男gaygay亚洲| 日本vs亚洲vs韩国一区三区| 日韩电影在线观看网站| 奇米色777欧美一区二区| 丝袜诱惑亚洲看片| 日韩电影在线一区二区三区| 五月婷婷激情综合| 天天色天天操综合| 秋霞午夜鲁丝一区二区老狼| 秋霞影院一区二区| 久久精品噜噜噜成人88aⅴ| 蜜臀av性久久久久蜜臀av麻豆| 亚洲人一二三区| 亚洲乱码国产乱码精品精的特点| 精品久久人人做人人爰| 久久久www成人免费毛片麻豆| 欧美亚洲高清一区二区三区不卡| 国产麻豆精品久久一二三| 国产精品中文有码| 东方aⅴ免费观看久久av| 成人精品视频一区二区三区尤物| 日本亚洲视频在线| 精品一区二区国语对白|