Save This Page
Home » commons-collections-3.2.1-src » org.apache.commons » collections » [javadoc | source]
org.apache.commons.collections
public class: BulkTest [javadoc | source]
java.lang.Object
   junit.framework.TestCase
      org.apache.commons.collections.BulkTest

All Implemented Interfaces:
    Cloneable

Direct Known Subclasses:
    TestIntIterator, TestSynchronizedSet, TestMap, TestSynchronizedList, TestMapValues, AbstractTestList, TestPredicatedSortedSet, TestTransformedSortedMap, TestLazyMap, AbstractTestSortedBag, TestMapValues, TestObjectArrayListIterator2, TestIteratorCharIterator, TestSortedSetSubSet, TestBoundedFifoBuffer2, TestByteCollectionCollection, TestUnmodifiableBidiMap, TestIterator, TestBag, TestTransformedBag, TestSingletonIterator, TestListIteratorFloatListIterator, AbstractTestIterator, TestBufferUtils, TestUnmodifiableIterator, TestCollectionShortCollection, TestStaticBucketMap, TestDoubleIteratorIterator, TestIteratorFloatIterator, TestSingletonIterator2, TestListView, TestCaseInsensitiveMap, TestListOrderedMap2, TestSingletonListIterator, TestHashBag, TestListUtils, TestHashBag, TestUnmodifiableSet, TestUnmodifiableBuffer, TestFastArrayList, TestBoundedFifoBuffer, TestShortCollectionCollection, TestCompositeSet, TestSynchronizedBuffer, TestFastArrayList1, TestListOrderedSet, TestComparableComparator, TestFastHashMap, TestHeadMap, TestCharCollectionCollection, AbstractTestBag, TestIteratorByteIterator, TestBlockingBuffer, TestSubMap, TestMapBackedSet, TestLinkedList, TestBooleanComparator, TestBeanMap, TestShortListIteratorListIterator, TestUnmodifiableSortedSet, TestUniqueFilterIterator, AbstractTestOrderedMapIterator, TestShortIteratorIterator, TestPredicatedSortedBag, TestBoundedFifoBuffer, TestTransformedSet, TestTypedSortedSet, TestSynchronizedSortedSet, TestHashedMap, TestUnmodifiableMap, TestFloatListIterator, TestUnmodifiableMapIterator, InnerTestMapIterator, TestCollectionByteCollection, TestListIteratorShortListIterator, TestArrayIterator, TestArrayListIterator, AbstractTestOrderedMap, TestTransformedList, TestUnmodifiableOrderedMapIterator, TestByteIteratorIterator, BulkTestSubList, TestReferenceMap, TestIntListIteratorListIterator, AbstractTestCollection, TestEnumerationUtils, TestTransformedSortedBag, TestListIteratorDoubleListIterator, TestCharListIterator, TestListIteratorWrapper, TestTransformedMap, TestPredicatedSortedMap, TestCharListIteratorListIterator, AbstractTestMap, TestFloatListIteratorListIterator, AbstractTestMapIterator, TestSingletonMap, TestIdentityMap, TestListView, TestCompositeMap, TestAbstractLinkedList, TestReferenceMap, AbstractTestIterableMap, TestUnboundedFifoBuffer, TestSynchronizedCollection, TestLongIterator, TestSetUtils, TestTypedSet, TestFixedSizeList, TestMapUtils, TestPredicatedList, TestTreeBidiMap, TestCollection, TestArrayStack, TestPriorityBuffer, TestIntListIterator, TestLRUMap, TestMapEntrySet, TestBidiOrderedMapIterator, TestIntIteratorIterator, TestCollectionIntCollection, TestTypedBag, TestFlatMapIterator, TestShortListIterator, TestPredicatedBuffer, TestUnmodifiableSortedBidiMap, TestDoubleListIterator, TestList, TestUnmodifiableCollection, TestSequencedHashMap, TestComparator, TestListOrderedMap, TestCursorableLinkedList, TestCircularFifoBuffer, TestFixedSizeMap, TestMapEntrySet, TestInverseBidiMap, TestBagUtils, TestCursorableLinkedList, AbstractTestSortedSet, AbstractTestSortedBidiMap, TestListOrderedSet2, TestCollectionCharCollection, TestTypedCollection, TestDoubleCollectionCollection, AbstractTestListIterator, TestIteratorIntIterator, TestBoundedFifoBuffer2, TestMultiHashMap, TestCollatingIterator, TestDualTreeBidiMap, TestFlat3Map, TestObjectArrayIterator, TestNullComparator1, TestCharIteratorIterator, TestComparatorChain, TestUnboundedFifoBuffer, TestShortIterator, TestViewMap, TestListIteratorCharListIterator, TestTreeBag, TestPredicatedMap, TestDualHashBidiMap, TestObjectArrayListIterator, TestDoubleIterator, TestFastHashMap1, TestFloatCollectionCollection, TestSetUniqueList, TestSet, TestIteratorChain, TestAbstractOrderedBidiMapDecorator, TestLRUMap, TestIntCollectionCollection, TestBidiMapIterator, AbstractTestSortedMap, TestNodeCachingLinkedList, AbstractTestSet, TestUnmodifiableOrderedMap, TestLongIteratorIterator, TestNullComparator, TestIteratorUtils, TestCollectionLongCollection, TestCharIterator, TestFastTreeMap, TestMultiKeyMap, TestFastTreeMap1, TestPredicatedBag, TestUnmodifiableList, AbstractTestObject, TestReaderCharIterator, TestLongCollectionCollection, TestLinkedMap, TestBinaryHeap, TestPredicatedCollection, TestCollectionFloatCollection, TestFixedSizeSortedMap, TestUnmodifiableSortedMap, TestByteIterator, TestFilterIterator, TestMapKeySet, TestInputStreamByteIterator, TestNullComparator2, TestArrayList, TestStaticBucketMap, TestArrayListIterator2, TestTypedSortedBag, TestListIteratorIntListIterator, TestListIteratorByteListIterator, TestFloatIteratorIterator, BulkTestSubList, TestPredicatedSet, TestLongListIterator, TestTreeMap, TestFloatIterator, TestListIterator, TestTypedList, TestUnmodifiableListIterator, TestListIteratorLongListIterator, TestDualTreeBidiMap2, TestIteratorShortIterator, TestTransformedSortedSet, TestIteratorLongIterator, TestMapBackedSet2, TestListView, TestReferenceIdentityMap, TestMapKeySet, TestReverseComparator, TestObject, InnerTestOrderedMapIterator, TestIteratorDoubleIterator, TestLongListIteratorListIterator, TestArrayIterator2, TestTransformedCollection, TestTailMap, TestLazySortedMap, TestCollectionDoubleCollection, TestDoubleListIteratorListIterator, AbstractTestOrderedBidiMap, AbstractTestBidiMap, TestTreeBag, TestProxyMap, AbstractTestComparator, TestByteListIteratorListIterator, TestObjectGraphIterator, TestPredicatedCollection, TestDoubleOrderedMap, TestByteListIterator, TestCompositeCollection, TestUnmodifiableOrderedBidiMap, TestTreeList

A TestCase that can define both simple and bulk test methods.

A simple test method is the type of test traditionally supplied by by TestCase . To define a simple test, create a public no-argument method whose name starts with "test". You can specify the the name of simple test in the constructor of BulkTest; a subsequent call to TestCase#run will run that simple test.

A bulk test method, on the other hand, returns a new instance of BulkTest, which can itself define new simple and bulk test methods. By using the #makeSuite method, you can automatically create a hierarchal suite of tests and child bulk tests.

For instance, consider the following two classes:

public class TestSet extends BulkTest {

private Set set;

public TestSet(Set set) {
this.set = set;
}

public void testContains() {
boolean r = set.contains(set.iterator().next()));
assertTrue("Set should contain first element, r);
}

public void testClear() {
set.clear();
assertTrue("Set should be empty after clear", set.isEmpty());
}
}


public class TestHashMap extends BulkTest {

private Map makeFullMap() {
HashMap result = new HashMap();
result.put("1", "One");
result.put("2", "Two");
return result;
}

public void testClear() {
Map map = makeFullMap();
map.clear();
assertTrue("Map empty after clear", map.isEmpty());
}

public BulkTest bulkTestKeySet() {
return new TestSet(makeFullMap().keySet());
}

public BulkTest bulkTestEntrySet() {
return new TestSet(makeFullMap().entrySet());
}
}
In the above examples, TestSet defines two simple test methods and no bulk test methods; TestHashMap defines one simple test method and two bulk test methods. When makeSuite(TestHashMap.class).run is executed, five simple test methods will be run, in this order:

  1. TestHashMap.testClear()
  2. TestHashMap.bulkTestKeySet().testContains();
  3. TestHashMap.bulkTestKeySet().testClear();
  4. TestHashMap.bulkTestEntrySet().testContains();
  5. TestHashMap.bulkTestEntrySet().testClear();
In the graphical junit test runners, the tests would be displayed in the following tree:

A subclass can override a superclass's bulk test by returning null from the bulk test method. If you only want to override specific simple tests within a bulk test, use the #ignoredSimpleTests method.

Note that if you want to use the bulk test methods, you must define your suite() method to use #makeSuite . The ordinary TestSuite constructor doesn't know how to interpret bulk test methods.

Field Summary
 String verboseName    The full name of this bulk test instance. This is the full name that is compared to #ignoredSimpleTests to see if this test should be ignored. It's also displayed in the text runner to ease debugging. 
Constructor:
 public BulkTest(String name) 
    Constructs a new BulkTest instance that will run the specified simple test.
    Parameters:
    name - the name of the simple test method to run
Method from org.apache.commons.collections.BulkTest Summary:
clone,   ignoredSimpleTests,   makeSuite,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.collections.BulkTest Detail:
 public Object clone() 
    Creates a clone of this BulkTest.

 public String[] ignoredSimpleTests() 
    Returns an array of simple test names to ignore.

    If a simple test that's defined by this BulkTest or by one of its bulk test methods has a name that's in the returned array, then that simple test will not be executed.

    A simple test's name is formed by taking the class name of the root BulkTest, eliminating the package name, then appending the names of any bulk test methods that were invoked to get to the simple test, and then appending the simple test method name. The method names are delimited by periods:

    TestHashMap.bulkTestEntrySet.testClear
    
    is the name of one of the simple tests defined in the sample classes described above. If the sample TestHashMap class included this method:
    public String[] ignoredSimpleTests() {
    return new String[] { "TestHashMap.bulkTestEntrySet.testClear" };
    }
    
    then the entry set's clear method wouldn't be tested, but the key set's clear method would.
 public static TestSuite makeSuite(Class c) 
    Returns a TestSuite for testing all of the simple tests and all the bulk tests defined by the given class.

    The class is examined for simple and bulk test methods; any child bulk tests are also examined recursively; and the results are stored in a hierarchal TestSuite .

    The given class must be a subclass of BulkTest and must not be abstract.

 public String toString() 
    Returns the display name of this BulkTest.