Package org.apache.avalon.fortress.util

Examples of org.apache.avalon.fortress.util.CompositeException


        m_exceptions[1] = new RuntimeException( "Test2" );
    }

    public void testRegularCreation()
    {
        CompositeException exc = new CompositeException( m_exceptions );
        assertNotNull( exc );
        assertNotNull( exc.getMessage() );
        assertTrue( null == exc.getCause() );
        assertNotNull( exc.getExceptions() );

        final StringBuffer msg = new StringBuffer();
        for ( int i = 0; i < m_exceptions.length; i++ )
        {
            if ( i > 0 ) msg.append( '\n' );
            msg.append( m_exceptions[i].getMessage() );
        }
        final String message = msg.toString();

        assertEquals( message, exc.getMessage() );

        Exception[] exceptions = exc.getExceptions();
        assertEquals( m_exceptions.length, exceptions.length );

        for ( int i = 0; i < exceptions.length; i++ )
        {
            assertEquals( m_exceptions[i], exceptions[i] );
View Full Code Here


    }

    public void testNestedCreation()
    {
        final String message = "Message";
        CompositeException exc = new CompositeException( m_exceptions, message );
        assertNotNull( exc );
        assertNotNull( exc.getMessage() );
        assertTrue( null == exc.getCause() );
        assertNotNull( exc.getExceptions() );

        assertEquals( message, exc.getMessage() );

        Exception[] exceptions = exc.getExceptions();
        assertEquals( m_exceptions.length, exceptions.length );

        for ( int i = 0; i < exceptions.length; i++ )
        {
            assertEquals( m_exceptions[i], exceptions[i] );
View Full Code Here

    public void testIllegalArgument()
    {
        try
        {
            new CompositeException( null );
            fail( "Did not throw an IllegalArgumentException" );
        }
        catch ( IllegalArgumentException iae )
        {
            // SUCCESS!!
        }
        catch ( Exception e )
        {
            fail( "Threw the wrong exception: " + e.getClass().getName() );
        }

        try
        {
            new CompositeException( new Exception[]{} );
            fail( "Did not throw an IllegalArgumentException" );
        }
        catch ( IllegalArgumentException iae )
        {
            // SUCCESS!!
View Full Code Here

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

        m_exceptions[1] = new RuntimeException( "Test2" );
    }

    public void testRegularCreation()
    {
        CompositeException exc = new CompositeException( m_exceptions );
        assertNotNull( exc );
        assertNotNull( exc.getMessage() );
        assertTrue( null == exc.getCause() );
        assertNotNull( exc.getExceptions() );

        final StringBuffer msg = new StringBuffer();
        for ( int i = 0; i < m_exceptions.length; i++ )
        {
            if ( i > 0 ) msg.append( '\n' );
            msg.append( m_exceptions[i].getMessage() );
        }
        final String message = msg.toString();

        assertEquals( message, exc.getMessage() );

        Exception[] exceptions = exc.getExceptions();
        assertEquals( m_exceptions.length, exceptions.length );

        for ( int i = 0; i < exceptions.length; i++ )
        {
            assertEquals( m_exceptions[i], exceptions[i] );
View Full Code Here

    }

    public void testNestedCreation()
    {
        final String message = "Message";
        CompositeException exc = new CompositeException( m_exceptions, message );
        assertNotNull( exc );
        assertNotNull( exc.getMessage() );
        assertTrue( null == exc.getCause() );
        assertNotNull( exc.getExceptions() );

        assertEquals( message, exc.getMessage() );

        Exception[] exceptions = exc.getExceptions();
        assertEquals( m_exceptions.length, exceptions.length );

        for ( int i = 0; i < exceptions.length; i++ )
        {
            assertEquals( m_exceptions[i], exceptions[i] );
View Full Code Here

    public void testIllegalArgument()
    {
        try
        {
            new CompositeException( null );
            fail( "Did not throw an IllegalArgumentException" );
        }
        catch ( IllegalArgumentException iae )
        {
            // SUCCESS!!
        }
        catch ( Exception e )
        {
            fail( "Threw the wrong exception: " + e.getClass().getName() );
        }

        try
        {
            new CompositeException( new Exception[]{} );
            fail( "Did not throw an IllegalArgumentException" );
        }
        catch ( IllegalArgumentException iae )
        {
            // SUCCESS!!
View Full Code Here

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.fortress.util.CompositeException

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.