{
// test with null array
Object[] array = null;
ArrayEnumeration list = new ArrayEnumeration( array );
assertFalse( list.hasMoreElements() );
try
{
list.nextElement();
fail( "should never get here due to a NoSuchElementException" );
}
catch ( NoSuchElementException e )
{
}
// test with empty array
array = new Object[0];
list = new ArrayEnumeration( array );
assertFalse( list.hasMoreElements() );
assertFalse( list.hasMoreElements() );
try
{
list.nextElement();
fail( "should never get here due to a NoSuchElementException" );
}
catch ( NoSuchElementException e )
{
}
// test with one object
array = new Object[]
{ new Object() };
list = new ArrayEnumeration( array );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertFalse( list.hasMoreElements() );
try
{
list.nextElement();
fail( "should never get here due to a NoSuchElementException" );
}
catch ( NoSuchElementException e )
{
}
// test with two objects
array = new Object[]
{ new Object(), new Object() };
list = new ArrayEnumeration( array );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertFalse( list.hasMoreElements() );
try
{
list.nextElement();
fail( "should never get here due to a NoSuchElementException" );
}
catch ( NoSuchElementException e )
{
}
// test with three elements
array = new Object[]
{ new Object(), new Object(), new Object() };
list = new ArrayEnumeration( array );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertTrue( list.hasMoreElements() );
assertNotNull( list.nextElement() );
assertFalse( list.hasMoreElements() );
try
{
list.nextElement();
fail( "should never get here due to a NoSuchElementException" );
}
catch ( NoSuchElementException e )
{