Class AbstractTestBag

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
All Implemented Interfaces:
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.

  • Constructor Details

    • AbstractTestBag

      public AbstractTestBag(String testName)
      JUnit constructor.
      Parameters:
      testName - the test class name
  • Method Details

    • makeBag

      public abstract org.apache.commons.collections.Bag makeBag()
      Return a new, empty bag to used for testing.
      Returns:
      the bag to be tested
    • makeObject

      public 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 IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • testFullBagSerialization

      public void testFullBagSerialization() throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • testEmptyBagCompatibility

      public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException
      Compare the current serialized form of the Bag against the canonical version in CVS.
      Throws:
      IOException
      ClassNotFoundException
    • testFullBagCompatibility

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