org.apache.commons.collections.bag
Class AbstractTestBag

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.collections.BulkTest
              extended by org.apache.commons.collections.AbstractTestObject
                  extended by org.apache.commons.collections.bag.AbstractTestBag
All Implemented Interfaces:
java.lang.Cloneable, junit.framework.Test
Direct Known Subclasses:
AbstractTestSortedBag

public abstract class AbstractTestBag
extends AbstractTestObject

Abstract test class for Bag methods and contracts.

To use, simply extend this class, and implement the makeBag() method.

If your bag fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your bag fails.


Field Summary
 
Fields inherited from class org.apache.commons.collections.AbstractTestObject
COLLECTIONS_MAJOR_VERSION
 
Constructor Summary
AbstractTestBag(java.lang.String testName)
          JUnit constructor.
 
Method Summary
abstract  Bag makeBag()
          Return a new, empty bag to used for testing.
 java.lang.Object makeObject()
          Implements the superclass method to return the Bag.
 void testBagAdd()
           
 void testBagEqualsSelf()
           
 void testContains()
           
 void testContainsAll()
           
 void testEmptyBagCompatibility()
          Compare the current serialized form of the Bag against the canonical version in CVS.
 void testEmptyBagSerialization()
           
 void testEquals()
           
 void testEqualsHashBag()
           
 void testFullBagCompatibility()
          Compare the current serialized form of the Bag against the canonical version in CVS.
 void testFullBagSerialization()
           
 void testHashCode()
           
 void testIterator()
           
 void testIteratorFail()
           
 void testIteratorFailDoubleRemove()
           
 void testIteratorFailNoMore()
           
 void testIteratorRemoveProtectsInvariants()
           
 void testRemove()
           
 void testRemoveAll()
           
 void testRetainAll()
           
 void testSize()
           
 void testToArray()
           
 void testToArrayPopulate()
           
 
Methods inherited from class org.apache.commons.collections.AbstractTestObject
getCanonicalEmptyCollectionName, getCanonicalFullCollectionName, getCompatibilityVersion, isEqualsCheckable, isTestSerialization, readExternalFormFromBytes, readExternalFormFromDisk, skipSerializedCanonicalTests, supportsEmptyCollections, supportsFullCollections, testCanonicalEmptyCollectionExists, testCanonicalFullCollectionExists, testEqualsNull, testObjectEqualsSelf, testObjectHashCodeEqualsContract, testObjectHashCodeEqualsSelfHashCode, testSerializeDeserializeThenCompare, testSimpleSerialization, writeExternalFormToBytes, writeExternalFormToDisk
 
Methods inherited from class org.apache.commons.collections.BulkTest
clone, ignoredTests, makeSuite, toString
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTestBag

public AbstractTestBag(java.lang.String testName)
JUnit constructor.

Parameters:
testName - the test class name
Method Detail

makeBag

public abstract Bag makeBag()
Return a new, empty bag to used for testing.

Returns:
the bag to be tested

makeObject

public java.lang.Object makeObject()
Implements the superclass method to return the Bag.

Specified by:
makeObject in class AbstractTestObject
Returns:
the bag to be tested

testBagAdd

public void testBagAdd()

testBagEqualsSelf

public void testBagEqualsSelf()

testRemove

public void testRemove()

testRemoveAll

public void testRemoveAll()

testContains

public void testContains()

testContainsAll

public void testContainsAll()

testSize

public void testSize()

testRetainAll

public void testRetainAll()

testIterator

public void testIterator()

testIteratorFail

public void testIteratorFail()

testIteratorFailNoMore

public void testIteratorFailNoMore()

testIteratorFailDoubleRemove

public void testIteratorFailDoubleRemove()

testIteratorRemoveProtectsInvariants

public void testIteratorRemoveProtectsInvariants()

testToArray

public void testToArray()

testToArrayPopulate

public void testToArrayPopulate()

testEquals

public void testEquals()

testEqualsHashBag

public void testEqualsHashBag()

testHashCode

public void testHashCode()

testEmptyBagSerialization

public void testEmptyBagSerialization()
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

testFullBagSerialization

public void testFullBagSerialization()
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

testEmptyBagCompatibility

public void testEmptyBagCompatibility()
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
Compare the current serialized form of the Bag against the canonical version in CVS.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

testFullBagCompatibility

public void testFullBagCompatibility()
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Compare the current serialized form of the Bag against the canonical version in CVS.

Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 2001-2010 Apache Software Foundation. All Rights Reserved.