Package org.apache.directory.api.util

Examples of org.apache.directory.api.util.ArrayEnumeration


    {
        // 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 )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.api.util.ArrayEnumeration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.