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

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

?? testcollection.java

?? iBATIS似乎已遠離眾說紛紜的OR框架之列
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/*
 * Copyright 1999-2004 The Apache Software Foundation
 *
 * 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 org.apache.commons.collections;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;


/**
 * Tests base {@link java.util.Collection} methods and contracts.
 * <p>
 * You should create a concrete subclass of this class to test any custom
 * {@link Collection} implementation.  At minimum, you'll have to 
 * implement the {@link #makeCollection()} method.  You might want to 
 * override some of the additional protected methods as well:<P>
 *
 * <B>Element Population Methods</B><P>
 * 
 * Override these if your collection restricts what kind of elements are
 * allowed (for instance, if <Code>null</Code> is not permitted):
 * <UL>
 * <Li>{@link #getFullElements()}
 * <Li>{@link #getOtherElements()}
 * </UL>
 *
 * <B>Supported Operation Methods</B><P>
 *
 * Override these if your collection doesn't support certain operations:
 * <UL>
 * <LI>{@link #isAddSuppoted()}
 * <LI>{@link #isRemoveSupported()}
 * <li>{@link #areEqualElementsDistinguishable()}
 * </UL>
 *
 * <B>Fixture Methods</B><P>
 *
 * Fixtures are used to verify that the the operation results in correct state
 * for the collection.  Basically, the operation is performed against your
 * collection implementation, and an identical operation is performed against a
 * <I>confirmed</I> collection implementation.  A confirmed collection
 * implementation is something like <Code>java.util.ArrayList</Code>, which is
 * known to conform exactly to its collection interface's contract.  After the
 * operation takes place on both your collection implementation and the
 * confirmed collection implementation, the two collections are compared to see
 * if their state is identical.  The comparison is usually much more involved
 * than a simple <Code>equals</Code> test.  This verification is used to ensure
 * proper modifications are made along with ensuring that the collection does
 * not change when read-only modifications are made.<P>
 *
 * The {@link #collection} field holds an instance of your collection
 * implementation; the {@link #confirmed} field holds an instance of the
 * confirmed collection implementation.  The {@link #resetEmpty()} and 
 * {@link #resetFull()} methods set these fields to empty or full collections,
 * so that tests can proceed from a known state.<P>
 *
 * After a modification operation to both {@link #collection} and
 * {@link #confirmed}, the {@link #verify()} method is invoked to compare
 * the results.  You may want to override {@link #verify()} to perform
 * additional verifications.  For instance, when testing the collection
 * views of a map, {@link TestMap} would override {@link #verify()} to make
 * sure the map is changed after the collection view is changed.
 *
 * If you're extending this class directly, you will have to provide 
 * implementations for the following:
 * <UL>
 * <LI>{@link #makeConfirmedCollection()}
 * <LI>{@link #makeConfirmedFullCollection()}
 * </UL>
 *
 * Those methods should provide a confirmed collection implementation 
 * that's compatible with your collection implementation.<P>
 *
 * If you're extending {@link TestList}, {@link TestSet},
 * or {@link TestBag}, you probably don't have to worry about the
 * above methods, because those three classes already override the methods
 * to provide standard JDK confirmed collections.<P>
 *
 * <B>Other notes</B><P>
 *
 * If your {@link Collection} fails one of these tests by design,
 * you may still use this base set of cases.  Simply override the
 * test case (method) your {@link Collection} fails.  For instance, the
 * {@link #testIteratorFailFast()} method is provided since most collections
 * have fail-fast iterators; however, that's not strictly required by the
 * collection contract, so you may want to override that method to do 
 * nothing.<P>
 *
 * @author Rodney Waldhoff
 * @author Paul Jack
 * @author <a href="mailto:mas@apache.org">Michael A. Smith</a>
 * @version $Id: TestCollection.java,v 1.9.2.1 2004/05/22 12:14:05 scolebourne Exp $
 */
public abstract class TestCollection extends TestObject {

    //
    // NOTE: 
    //
    // Collection doesn't define any semantics for equals, and recommends you
    // use reference-based default behavior of Object.equals.  (And a test for
    // that already exists in TestObject).  Tests for equality of lists, sets
    // and bags will have to be written in test subclasses.  Thus, there is no
    // tests on Collection.equals nor any for Collection.hashCode.
    //


    // These fields are used by reset() and verify(), and any test
    // method that tests a modification.

    /** 
     *  A collection instance that will be used for testing.
     */
    protected Collection collection;

    /** 
     *  Confirmed collection.  This is an instance of a collection that is
     *  confirmed to conform exactly to the java.util.Collection contract.
     *  Modification operations are tested by performing a mod on your 
     *  collection, performing the exact same mod on an equivalent confirmed
     *  collection, and then calling verify() to make sure your collection
     *  still matches the confirmed collection.
     */
    protected Collection confirmed;


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


    /**
     *  Resets the {@link #collection} and {@link #confirmed} fields to empty
     *  collections.  Invoke this method before performing a modification
     *  test.
     */
    protected void resetEmpty() {
        this.collection = makeCollection();
        this.confirmed = makeConfirmedCollection();
    }


    /**
     *  Resets the {@link #collection} and {@link #confirmed} fields to full
     *  collections.  Invoke this method before performing a modification
     *  test.
     */
    protected void resetFull() {
        this.collection = makeFullCollection();
        this.confirmed = makeConfirmedFullCollection();
    }

    /**
     *  Specifies whether equal elements in the collection are, in fact,
     *  distinguishable with information not readily available.  That is, if a
     *  particular value is to be removed from the collection, then there is
     *  one and only one value that can be removed, even if there are other
     *  elements which are equal to it.  
     *
     *  <P>In most collection cases, elements are not distinguishable (equal is
     *  equal), thus this method defaults to return false.  In some cases,
     *  however, they are.  For example, the collection returned from the map's
     *  values() collection view are backed by the map, so while there may be
     *  two values that are equal, their associated keys are not.  Since the
     *  keys are distinguishable, the values are.
     *
     *  <P>This flag is used to skip some verifications for iterator.remove()
     *  where it is impossible to perform an equivalent modification on the
     *  confirmed collection because it is not possible to determine which
     *  value in the confirmed collection to actually remove.  Tests that
     *  override the default (i.e. where equal elements are distinguishable),
     *  should provide additional tests on iterator.remove() to make sure the
     *  proper elements are removed when remove() is called on the iterator.
     **/
    protected boolean areEqualElementsDistinguishable() {
        return false;
    }

    /**
     *  Verifies that {@link #collection} and {@link #confirmed} have 
     *  identical state.
     */
    protected void verify() {
        int confirmedSize = confirmed.size();
        assertEquals("Collection size should match confirmed collection's",
                     confirmedSize, collection.size());
        assertEquals("Collection isEmpty() result should match confirmed " +
                     " collection's", 
                     confirmed.isEmpty(), collection.isEmpty());

        // verify the collections are the same by attempting to match each
        // object in the collection and confirmed collection.  To account for
        // duplicates and differing orders, each confirmed element is copied
        // into an array and a flag is maintained for each element to determine
        // whether it has been matched once and only once.  If all elements in
        // the confirmed collection are matched once and only once and there
        // aren't any elements left to be matched in the collection,
        // verification is a success.

        // copy each collection value into an array
        Object[] confirmedValues = new Object[confirmedSize];

        Iterator iter;

        iter = confirmed.iterator(); 
        int pos = 0;
        while(iter.hasNext()) {
            confirmedValues[pos++] = iter.next();
        }

        // allocate an array of boolean flags for tracking values that have
        // been matched once and only once.
        boolean[] matched = new boolean[confirmedSize];
        
        // now iterate through the values of the collection and try to match
        // the value with one in the confirmed array.
        iter = collection.iterator();
        while(iter.hasNext()) {
            Object o = iter.next();
            boolean match = false;
            for(int i = 0; i < confirmedSize; i++) {
                if(matched[i]) {
                    // skip values already matched
                    continue;
                }
                if(o == confirmedValues[i] ||
                   (o != null && o.equals(confirmedValues[i]))) {
                    // values matched
                    matched[i] = true;
                    match = true;
                    break;
                }
            }
            // no match found!
            if(!match) {
                fail("Collection should not contain a value that the " +
                     "confirmed collection does not have.");
            }
        }
        
        // make sure there aren't any unmatched values
        for(int i = 0; i < confirmedSize; i++) {
            if(!matched[i]) {
                // the collection didn't match all the confirmed values
                fail("Collection should contain all values that are in the " +
                     "confirmed collection");
            }
        }
    }
    
    
    /**
     *  Returns a confirmed empty collection.
     *  For instance, an {@link java.util.ArrayList} for lists or a
     *  {@link java.util.HashSet} for sets.
     *
     *  @return a confirmed empty collection
     */
    protected abstract Collection makeConfirmedCollection();



    /**
     *  Returns a confirmed full collection.
     *  For instance, an {@link java.util.ArrayList} for lists or a
     *  {@link java.util.HashSet} for sets.  The returned collection
     *  should contain the elements returned by {@link #getFullElements()}.
     *
     *  @return a confirmed full collection
     */
    protected abstract Collection makeConfirmedFullCollection();


    /**
     *  Returns true if the collections produced by 
     *  {@link #makeCollection()} and {@link #makeFullCollection()}
     *  support the <Code>add</Code> and <Code>addAll</Code>
     *  operations.<P>
     *  Default implementation returns true.  Override if your collection
     *  class does not support add or addAll.
     */
    protected boolean isAddSupported() {
        return true;
    }


    /**
     *  Returns true if the collections produced by 
     *  {@link #makeCollection()} and {@link #makeFullCollection()}
     *  support the <Code>remove</Code>, <Code>removeAll</Code>,
     *  <Code>retainAll</Code>, <Code>clear</Code> and
     *  <Code>iterator().remove()</Code> methods.
     *  Default implementation returns true.  Override if your collection
     *  class does not support removal operations.
     */
    protected boolean isRemoveSupported() {
        return true;
    }


    /**
     *  Returns an array of objects that are contained in a collection
     *  produced by {@link #makeFullCollection()}.  Every element in the
     *  returned array <I>must</I> be an element in a full collection.<P>
     *  The default implementation returns a heterogenous array of 
     *  objects with some duplicates and with the null element.  
     *  Override if you require specific testing elements.  Note that if you
     *  override {@link #makeFullCollection()}, you <I>must</I> override
     *  this method to reflect the contents of a full collection.
     */
    protected Object[] getFullElements() {
        ArrayList list = new ArrayList();
        list.addAll(Arrays.asList(getFullNonNullElements()));
        list.add(4, null);
        return list.toArray();
    }


    /**
     *  Returns an array of elements that are <I>not</I> contained in a
     *  full collection.  Every element in the returned array must 
     *  not exist in a collection returned by {@link #makeFullCollection()}.
     *  The default implementation returns a heterogenous array of elements
     *  without null.  Note that some of the tests add these elements
     *  to an empty or full collection, so if your collection restricts
     *  certain kinds of elements, you should override this method.
     */
    protected Object[] getOtherElements() {
        return getOtherNonNullElements();
    }
    

    /**
     * Return a new, empty {@link Collection} to be used for testing.
     */
    protected abstract Collection makeCollection();


    /**
     *  Returns a full collection to be used for testing.  The collection
     *  returned by this method should contain every element returned by
     *  {@link #getFullElements()}.  The default implementation, in fact,
     *  simply invokes <Code>addAll</Code> on an empty collection with
     *  the results of {@link #getFullElements()}.  Override this default
     *  if your collection doesn't support addAll.
     */
    protected Collection makeFullCollection() {
        Collection c = makeCollection();
        c.addAll(Arrays.asList(getFullElements()));
        return c;
    }


    /**
     *  Returns an empty collection for Object tests.
     */
    public Object makeObject() {
        return makeCollection();
    }


    /**
     *  Tests {@link Collection#add(Object)}.
     */
    public void testCollectionAdd() {
        if (!isAddSupported()) return;
        
        Object[] elements = getFullElements();
        for (int i = 0; i < elements.length; i++) {
            resetEmpty();
            boolean r = collection.add(elements[i]);
            confirmed.add(elements[i]);
            verify();
            assertTrue("Empty collection changed after add", r);
            assertTrue("Collection size is 1 after first add", 
                       collection.size() == 1);
        }
        
        resetEmpty();
        int size = 0;
        for (int i = 0; i < elements.length; i++) {
            boolean r = collection.add(elements[i]);
            confirmed.add(elements[i]);
            verify();
            if (r) size++;
            assertEquals("Collection size should grow after add", 
                         size, collection.size());
            assertTrue("Collection should contain added element",
                       collection.contains(elements[i]));
        }
    }
    
    
    /**
     *  Tests {@link Collection#addAll(Collection)}.
     */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
884aa四虎影成人精品一区| 中文字幕五月欧美| 国产偷v国产偷v亚洲高清| 综合婷婷亚洲小说| 亚洲18影院在线观看| 国产福利一区二区| 欧美日韩在线不卡| 久久久精品国产免大香伊| 亚洲高清在线精品| 福利视频网站一区二区三区| 欧美日韩精品欧美日韩精品| 日本一区二区三区四区| 免费成人你懂的| 91久久精品网| 国产精品视频观看| 久久99国内精品| 欧美在线观看视频在线| 国产偷国产偷亚洲高清人白洁| 日韩精品一卡二卡三卡四卡无卡| 波多野结衣视频一区| 欧美不卡一二三| 视频一区二区三区在线| 色欧美88888久久久久久影院| 久久久亚洲综合| 久久99精品国产麻豆婷婷| 91精品久久久久久久久99蜜臂| 亚洲女女做受ⅹxx高潮| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 不卡的av中国片| 久久综合狠狠综合| 久久99蜜桃精品| 欧美一区二区三区人| 婷婷综合另类小说色区| 欧洲av在线精品| 一区二区三区影院| 色婷婷av一区二区三区软件| 国产精品电影一区二区| av电影在线观看不卡| 国产精品久久久久影院| 波多野洁衣一区| 国产精品不卡一区| 97国产一区二区| 亚洲精品高清在线观看| 色偷偷成人一区二区三区91| 亚洲精品视频免费看| 色综合色综合色综合色综合色综合| 国产精品国产三级国产aⅴ原创 | 国内外成人在线| 久久综合丝袜日本网| 国产一区不卡视频| 国产欧美精品一区二区三区四区| 国产精品一区二区久久精品爱涩| 中文字幕av一区二区三区高 | 国产成人在线色| 国产亚洲欧美在线| 99精品偷自拍| 亚洲乱码中文字幕| 欧美女孩性生活视频| 人人精品人人爱| 久久久久久久久久美女| av资源站一区| 亚洲成人av中文| 日韩一区二区在线观看视频播放| 久久99国产精品麻豆| 国产欧美一区二区三区沐欲| 91亚洲大成网污www| 亚洲成精国产精品女| 欧美mv日韩mv国产网站| 不卡大黄网站免费看| 亚洲成人久久影院| 精品国产91亚洲一区二区三区婷婷| 国产a级毛片一区| 一区二区激情视频| 精品国产免费一区二区三区四区| 成人免费高清在线| 亚洲国产精品久久人人爱蜜臀| 日韩欧美三级在线| 波多野结衣的一区二区三区| 日韩精品成人一区二区在线| 国产精品毛片大码女人 | 国产成人精品免费| 亚洲一区二区三区视频在线播放| 精品免费视频一区二区| 91片黄在线观看| 韩国午夜理伦三级不卡影院| 一区二区三区欧美视频| 亚洲精品一区二区三区在线观看| 一本久久a久久精品亚洲| 久久精品72免费观看| 一区二区三区久久| 日本一区免费视频| 日韩一区二区三区视频| 色综合久久综合中文综合网| 国产毛片精品一区| 午夜精品久久久久久久久| 国产精品无码永久免费888| 337p亚洲精品色噜噜噜| 91啪亚洲精品| 成熟亚洲日本毛茸茸凸凹| 日本va欧美va欧美va精品| 亚洲综合一区二区三区| 一区二区中文字幕在线| xvideos.蜜桃一区二区| 欧美一卡2卡3卡4卡| 欧美三区在线观看| 91麻豆免费观看| 成人app下载| 粉嫩一区二区三区性色av| 久久国产成人午夜av影院| 日韩精品午夜视频| 亚洲第一二三四区| 亚洲欧美韩国综合色| 国产精品毛片无遮挡高清| 久久久99久久精品欧美| 精品人在线二区三区| 在线成人免费视频| 欧美日韩一区二区三区不卡| 日本电影亚洲天堂一区| 一本色道a无线码一区v| 色综合天天视频在线观看| jlzzjlzz亚洲女人18| 成人爱爱电影网址| va亚洲va日韩不卡在线观看| 成人激情小说乱人伦| av在线播放成人| 不卡大黄网站免费看| 91在线观看污| 色哟哟欧美精品| 欧美午夜精品免费| 欧美日韩高清一区二区三区| 4438x亚洲最大成人网| 91麻豆精品国产91久久久 | 日韩影视精彩在线| 日本 国产 欧美色综合| 韩国v欧美v日本v亚洲v| 岛国av在线一区| 99精品视频在线观看| 欧美午夜在线一二页| 日韩一区二区三免费高清| 日韩午夜在线影院| 久久综合狠狠综合久久综合88| 中文字幕第一区综合| 亚洲欧美日韩国产成人精品影院| 亚洲免费电影在线| 日韩中文字幕亚洲一区二区va在线 | 欧美日韩精品一区二区天天拍小说 | 亚洲精品大片www| 天涯成人国产亚洲精品一区av| 日本在线不卡一区| 久久99久久99| www.爱久久.com| 欧美精品久久久久久久多人混战 | 日韩欧美在线一区二区三区| 国产午夜精品美女毛片视频| 中文字幕中文在线不卡住| 一区二区三区四区视频精品免费 | 高清av一区二区| 欧美伊人久久久久久久久影院 | 欧美成人福利视频| 国产精品福利影院| 午夜伊人狠狠久久| 国产激情一区二区三区四区 | 日韩精品一区二区三区老鸭窝 | 国产aⅴ综合色| 色素色在线综合| 欧美不卡一区二区三区| 中文字幕中文字幕一区| 美女视频网站久久| 91麻豆蜜桃一区二区三区| 日韩一级片在线播放| 亚洲男人的天堂在线观看| 国产在线日韩欧美| 欧美酷刑日本凌虐凌虐| 国产精品久久久久久久裸模| 青青草成人在线观看| 日韩欧美一二区| 亚洲影视资源网| 国产成人在线视频免费播放| 欧美一级生活片| 亚洲激情在线激情| 成人黄色av网站在线| 精品国产亚洲在线| 日本在线不卡视频一二三区| 91黄色在线观看| 中文字幕亚洲一区二区va在线| 国内精品视频一区二区三区八戒 | 亚洲欧美日韩在线播放| 国产一区二区三区四区五区入口| 欧洲色大大久久| 日韩毛片精品高清免费| 国产成人夜色高潮福利影视| 欧美变态凌虐bdsm| 日本欧洲一区二区| 欧美日韩国产高清一区| 亚洲精品福利视频网站| 色综合久久久久久久久| 国产精品色在线| 成人一区二区三区中文字幕| 久久精品日产第一区二区三区高清版| 丝袜亚洲另类欧美综合|