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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? testblockingbuffer.java

?? iBATIS似乎已遠離眾說紛紜的OR框架之列
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You 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 org.apache.commons.collections.buffer;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.AbstractTestObject;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferUnderflowException;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

/**
 * Extension of {@link AbstractTestObject} for exercising the {@link BlockingBuffer} implementation.
 *
 * @author Janek Bogucki
 * @author Phil Steitz
 * @version $Revision: 646780 $
 * @since Commons Collections 3.0
 */
public class TestBlockingBuffer extends AbstractTestObject {

    public TestBlockingBuffer( String testName ) {
        super( testName );
    }

    public static Test suite() {
        return new TestSuite( TestBlockingBuffer.class );
    }

    public static void main( String args[] ) {
        String[] testCaseName = {TestBlockingBuffer.class.getName()};
        junit.textui.TestRunner.main( testCaseName );
    }

    public Object makeObject() {
        return BlockingBuffer.decorate( new MyBuffer() );
    }

    public boolean isEqualsCheckable() {
        return false;
    }

    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#add(Object)}.
     */
    public void testGetWithAdd() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();
        new DelayedAdd( blockingBuffer, obj ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.get() );
    }

    public void testGetWithAddTimeout() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 500 );
        Object obj = new Object();
        new DelayedAdd( blockingBuffer, obj, 100 ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.get() );
    }

    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}.
     */
    public void testGetWithAddAll() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();
        new DelayedAddAll( blockingBuffer, obj ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.get() );
    }

    public void testGetWithAddAllTimeout() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 500 );
        Object obj = new Object();
        new DelayedAddAll( blockingBuffer, obj, 100 ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.get() );
    }

    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#add(Object)}.
     */
    public void testRemoveWithAdd() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();
        new DelayedAdd( blockingBuffer, obj ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.remove() );
    }

    public void testRemoveWithAddTimeout() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 100 );
        Object obj = new Object();
        new DelayedAdd( blockingBuffer, obj, 500 ).start();
        try {
            blockingBuffer.remove();
        }
        catch( BufferUnderflowException e ) {
        }
    }
    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)}.
     */
    public void testRemoveWithAddAll() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();
        new DelayedAddAll( blockingBuffer, obj ).start();

        // verify does not throw BufferUnderflowException; should block until other thread has added to the buffer .
        assertSame( obj, blockingBuffer.remove() );
    }

    public void testRemoveWithAddAllTimeout() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer(), 100 );
        Object obj = new Object();
        new DelayedAddAll( blockingBuffer, obj, 500 ).start();
        try {
            blockingBuffer.remove();
        }
        catch( BufferUnderflowException e ) {
        }
    }
    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#add(Object)} using multiple read
     * threads.
     * <p/>
     * Two read threads should block on an empty buffer until one object is added then both threads should complete.
     */
    public void testBlockedGetWithAdd() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();

        // run methods will get and compare -- must wait for add
        Thread thread1 = new ReadThread( blockingBuffer, obj );
        Thread thread2 = new ReadThread( blockingBuffer, obj );
        thread1.start();
        thread2.start();

        // give hungry read threads ample time to hang
        delay();

        // notifyAll should allow both read threads to complete
        blockingBuffer.add( obj );

        // allow notified threads to complete 
        delay();

        // There should not be any threads waiting.
        if( thread1.isAlive() || thread2.isAlive() ) {
            fail( "Live thread(s) when both should be dead." );
        }
    }

    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#get()} in combination with {@link BlockingBuffer#addAll(java.util.Collection)} using
     * multiple read threads.
     * <p/>
     * Two read threads should block on an empty buffer until a singleton is added then both threads should complete.
     */
    public void testBlockedGetWithAddAll() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();

        // run methods will get and compare -- must wait for addAll
        Thread thread1 = new ReadThread( blockingBuffer, obj );
        Thread thread2 = new ReadThread( blockingBuffer, obj );
        thread1.start();
        thread2.start();

        // give hungry read threads ample time to hang
        delay();

        // notifyAll should allow both read threads to complete
        blockingBuffer.addAll( Collections.singleton( obj ) );

        // allow notified threads to complete 
        delay();

        // There should not be any threads waiting.
        if( thread1.isAlive() || thread2.isAlive() ) {
            fail( "Live thread(s) when both should be dead." );
        }
    }

    //-----------------------------------------------------------------------

    /**
     * Tests interrupted {@link BlockingBuffer#get()}.
     */
    public void testInterruptedGet() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();

        // spawn a read thread to wait on the empty buffer
        ArrayList exceptionList = new ArrayList();
        Thread thread = new ReadThread( blockingBuffer, obj, exceptionList );
        thread.start();

        // Interrupting the thread should cause it to throw BufferUnderflowException
        thread.interrupt();

        // Chill, so thread can throw and add message to exceptionList
        delay();
        assertTrue( "Thread interrupt should have led to underflow",
                    exceptionList.contains( "BufferUnderFlow" ) );
        if( thread.isAlive() ) {
            fail( "Read thread has hung." );
        }

    }

    //-----------------------------------------------------------------------

    /**
     * Tests {@link BlockingBuffer#remove()} in combination with {@link BlockingBuffer#add(Object)} using multiple read
     * threads.
     * <p/>
     * Two read threads should block on an empty buffer until one object is added then one thread should complete. The
     * remaining thread should complete after the addition of a second object.
     */
    public void testBlockedRemoveWithAdd() {
        Buffer blockingBuffer = BlockingBuffer.decorate( new MyBuffer() );
        Object obj = new Object();

        // run methods will remove and compare -- must wait for add
        Thread thread1 = new ReadThread( blockingBuffer, obj, null, "remove" );
        Thread thread2 = new ReadThread( blockingBuffer, obj, null, "remove" );
        thread1.start();
        thread2.start();

        // give hungry read threads ample time to hang
        delay();
        blockingBuffer.add( obj );

        // allow notified threads to complete 
        delay();

        // There should be one thread waiting.
        assertTrue( "There is one thread waiting", thread1.isAlive() ^ thread2.isAlive() );
        blockingBuffer.add( obj );

        // allow notified thread to complete 
        delay();

        // There should not be any threads waiting.
        if( thread1.isAlive() || thread2.isAlive() ) {
            fail( "Live thread(s) when both should be dead." );
        }
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产wwwww| 亚洲精品久久嫩草网站秘色| 欧美激情综合网| 国产精品久久三| 亚洲激情图片小说视频| 午夜亚洲国产au精品一区二区| 免费成人在线影院| 国产成人在线免费观看| 一本色道**综合亚洲精品蜜桃冫 | 久久久亚洲综合| 国产精品久久免费看| 午夜精品一区在线观看| 久久91精品久久久久久秒播 | 国产精品自产自拍| 91在线观看一区二区| 欧美精品xxxxbbbb| 国产欧美日韩在线观看| 亚洲一二三四在线| 国产精品综合视频| 欧美日韩一卡二卡| 久久理论电影网| 亚洲一区二区欧美日韩| 国产综合久久久久影院| 在线免费观看成人短视频| 欧美v亚洲v综合ⅴ国产v| 亚洲人成人一区二区在线观看| 蜜臀av一区二区在线免费观看| 国产成人精品免费看| 欧美日韩国产电影| 中文字幕在线不卡国产视频| 日韩在线一区二区三区| av成人免费在线| 精品国产露脸精彩对白| 亚洲高清视频在线| 丁香网亚洲国际| 日韩一区二区中文字幕| 一区二区三区在线免费观看 | 久久人人爽爽爽人久久久| 一区二区三区资源| 国产成人亚洲综合a∨猫咪| 欧美日韩精品三区| 亚洲欧洲无码一区二区三区| 久久99精品久久久久久国产越南| 日本道精品一区二区三区| 国产亚洲欧美一区在线观看| 日韩电影在线观看电影| 91色九色蝌蚪| 欧美激情一区不卡| 久久99精品久久久久婷婷| 欧美日韩午夜在线视频| 亚洲欧美中日韩| 国产黄色成人av| 精品免费国产一区二区三区四区| 日一区二区三区| 在线视频中文字幕一区二区| 国产精品进线69影院| 国产高清视频一区| 精品剧情v国产在线观看在线| 日韩高清在线一区| 欧美日韩在线亚洲一区蜜芽| 亚洲精品网站在线观看| www.视频一区| 国产精品欧美一区喷水| 国产iv一区二区三区| 久久久久88色偷偷免费| 韩国成人在线视频| 精品国产乱码久久久久久浪潮 | 欧洲日韩一区二区三区| 国产精品久久影院| 国产黄色91视频| 国产亚洲婷婷免费| 国产91丝袜在线播放0| 久久噜噜亚洲综合| 国产成人亚洲精品狼色在线| 国产欧美日韩激情| 国产91高潮流白浆在线麻豆 | 久久97超碰国产精品超碰| 欧美一区二区三区在线| 日韩国产欧美在线播放| 欧美丰满美乳xxx高潮www| 丝袜美腿一区二区三区| 欧美福利电影网| 裸体一区二区三区| 精品国产一区久久| 国产精品一二三| 欧美国产激情二区三区| 成人丝袜高跟foot| 亚洲丝袜另类动漫二区| 日本道色综合久久| 亚洲超碰精品一区二区| 欧美一三区三区四区免费在线看| 男女男精品网站| 久久伊人蜜桃av一区二区| 国产成人精品亚洲777人妖| 中文无字幕一区二区三区| 9色porny自拍视频一区二区| 一区二区三区在线观看国产| 欧美日韩一区久久| 久久99国产精品免费网站| 国产日产欧美一区二区三区| 99精品久久只有精品| 亚洲成在线观看| 欧美大片一区二区三区| 国产成人精品免费一区二区| 亚洲免费在线观看| 91精品欧美综合在线观看最新 | 日韩三级在线免费观看| 国产在线视视频有精品| 国产精品乱码一区二区三区软件| 一本一道波多野结衣一区二区| 午夜a成v人精品| 久久久电影一区二区三区| 91影视在线播放| 美女视频一区二区三区| 国产精品久久久久久妇女6080| 欧美午夜一区二区| 激情久久五月天| 亚洲人成小说网站色在线| 91精品久久久久久蜜臀| 成人教育av在线| 五月天激情综合| 国产区在线观看成人精品| 欧美在线观看视频一区二区三区| 久久se这里有精品| 亚洲人成7777| 日韩美女视频在线| 91丝袜美腿高跟国产极品老师| 全国精品久久少妇| 一区二区中文视频| 欧美成人一区二区| 一本大道综合伊人精品热热| 久久99国产乱子伦精品免费| 悠悠色在线精品| 久久久久久97三级| 欧美日韩午夜精品| 99久久国产免费看| 精品一区二区三区久久久| 一区二区三区波多野结衣在线观看| 精品成a人在线观看| 欧美性一二三区| 粉嫩13p一区二区三区| 日韩精品一卡二卡三卡四卡无卡| 国产精品美女视频| 欧美成人精品1314www| 欧洲一区在线电影| 成人免费视频一区| 久久精品久久99精品久久| 一区二区三区在线影院| 国产欧美一区二区精品仙草咪| 8x福利精品第一导航| 一本久久精品一区二区| 国产成人av电影在线| 美女视频黄 久久| 亚洲高清三级视频| 亚洲三级在线播放| 欧美国产亚洲另类动漫| 日韩欧美久久久| 欧美日韩一级黄| 色综合av在线| 成人高清av在线| 国产精品 欧美精品| 日本欧美在线观看| 亚洲成在线观看| 亚洲最色的网站| 亚洲欧美一区二区三区国产精品| 国产欧美精品在线观看| 精品国产91九色蝌蚪| 欧美一卡2卡三卡4卡5免费| 欧美视频一区在线观看| 色综合av在线| 色视频一区二区| 99精品桃花视频在线观看| 成人午夜大片免费观看| 粉嫩aⅴ一区二区三区四区五区| 国产精品1区二区.| 国产乱子伦视频一区二区三区| 麻豆精品一区二区| 欧美aaaaa成人免费观看视频| 日av在线不卡| 麻豆精品一二三| 精品在线亚洲视频| 青青草原综合久久大伊人精品优势| 亚洲国产成人porn| 亚洲成人你懂的| 五月天网站亚洲| 偷窥少妇高潮呻吟av久久免费| 亚洲成年人影院| 午夜日韩在线观看| 丝袜诱惑制服诱惑色一区在线观看| 午夜视频一区二区| 蜜桃一区二区三区在线| 美女一区二区三区| 紧缚捆绑精品一区二区| 国产美女精品在线| 国产美女久久久久| 成人国产精品免费观看动漫| av不卡在线播放| 色婷婷亚洲婷婷| 欧美日韩黄色影视| 欧美一级夜夜爽|