avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/util ECMTestRig.java FortressTestRig.java
Date Sat, 03 May 2003 04:11:08 GMT
donaldp     2003/05/02 21:11:07

  Modified:    xfc/src/test/org/apache/excalibur/xfc/test xfcTestCase.java
               xfc/src/test/org/apache/excalibur/xfc/test/util
                        ECMTestRig.java FortressTestRig.java
  Log:
  styled and cleaned
  
  Revision  Changes    Path
  1.15      +83 -33    avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java
  
  Index: xfcTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- xfcTestCase.java	29 Mar 2003 18:53:26 -0000	1.14
  +++ xfcTestCase.java	3 May 2003 04:11:07 -0000	1.15
  @@ -51,12 +51,11 @@
   
   import junit.framework.TestCase;
   import junit.textui.TestRunner;
  -
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.configuration.ConfigurationUtil;
   import org.apache.avalon.framework.logger.ConsoleLogger;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.apache.excalibur.xfc.Module;
   import org.apache.excalibur.xfc.model.Model;
   import org.apache.excalibur.xfc.model.role.RoleRef;
  @@ -116,7 +115,7 @@
   
               fail( "Context validation failed" );
           }
  -        catch ( IllegalArgumentException e )
  +        catch( IllegalArgumentException e )
           {
               // should end up in here if all is ok.
           }
  @@ -155,17 +154,17 @@
           );
   
           // check each role has the right values, compared against the master copy
  -        for ( int i = 0; i < rolesMODEL.length; ++i )
  +        for( int i = 0; i < rolesMODEL.length; ++i )
           {
  -            String modelRoleName = rolesMODEL[i].getRole();
  +            String modelRoleName = rolesMODEL[ i ].getRole();
               Configuration masterRoleConfig = null;
   
               // get the real role configuration object
  -            for ( int j = 0; j < rolesREAL.length; ++j )
  +            for( int j = 0; j < rolesREAL.length; ++j )
               {
  -                if ( modelRoleName.equals( rolesREAL[j].getAttribute( "name" ) ) )
  +                if( modelRoleName.equals( rolesREAL[ j ].getAttribute( "name" ) ) )
                   {
  -                    masterRoleConfig = rolesREAL[j];
  +                    masterRoleConfig = rolesREAL[ j ];
                       break;
                   }
               }
  @@ -177,12 +176,12 @@
               );
   
               // convert our RoleRef object into a Configuration and compare with the master
  -            Configuration modelRoleConfig = ecm.buildRole( rolesMODEL[i] );
  +            Configuration modelRoleConfig = ecm.buildRole( rolesMODEL[ i ] );
   
               assertTrue(
                   "Role configuration trees differ\n" +
  -                "(master)" + ConfigurationUtil.list( masterRoleConfig ) +
  -                "(model)" + ConfigurationUtil.list( modelRoleConfig ),
  +                "(master)" + list( masterRoleConfig ) +
  +                "(model)" + list( modelRoleConfig ),
                   ConfigurationUtil.equals( masterRoleConfig, modelRoleConfig )
               );
           }
  @@ -263,17 +262,17 @@
           );
   
           // check each role has the right values, compared against the master copy
  -        for ( int i = 0; i < rolesMODEL.length; ++i )
  +        for( int i = 0; i < rolesMODEL.length; ++i )
           {
  -            String modelRoleName = rolesMODEL[i].getRole();
  +            String modelRoleName = rolesMODEL[ i ].getRole();
               Configuration masterRoleConfig = null;
   
               // get the real role configuration object
  -            for ( int j = 0; j < rolesREAL.length; ++j )
  +            for( int j = 0; j < rolesREAL.length; ++j )
               {
  -                if ( modelRoleName.equals( rolesREAL[j].getAttribute( "name" ) ) )
  +                if( modelRoleName.equals( rolesREAL[ j ].getAttribute( "name" ) ) )
                   {
  -                    masterRoleConfig = rolesREAL[j];
  +                    masterRoleConfig = rolesREAL[ j ];
                       break;
                   }
               }
  @@ -285,12 +284,12 @@
               );
   
               // convert our RoleRef object into a Configuration and compare with the master
  -            Configuration modelRoleConfig = ecm.buildRole( rolesMODEL[i] );
  +            Configuration modelRoleConfig = ecm.buildRole( rolesMODEL[ i ] );
   
               assertTrue(
                   "Role configuration trees differ\n" +
  -                "(master)" + ConfigurationUtil.list( masterRoleConfig ) +
  -                "(model)" + ConfigurationUtil.list( modelRoleConfig ),
  +                "(master)" + list( masterRoleConfig ) +
  +                "(model)" + list( modelRoleConfig ),
                   ConfigurationUtil.equals( masterRoleConfig, modelRoleConfig )
               );
           }
  @@ -367,13 +366,13 @@
                   "singleton", // org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler
               };
   
  -        for ( int i = 0; i < classes.length; ++i )
  +        for( int i = 0; i < classes.length; ++i )
           {
  -            String result = ecm.getHandler( classes[i] );
  +            String result = ecm.getHandler( classes[ i ] );
               assertTrue(
  -                "Class handler analysis failed for :" + classes[i] +
  -                ", expected was '" + handlers[i] + "', received was '" + result + "'",
  -                handlers[i].equals( result )
  +                "Class handler analysis failed for :" + classes[ i ] +
  +                ", expected was '" + handlers[ i ] + "', received was '" + result + "'",
  +                handlers[ i ].equals( result )
               );
           }
       }
  @@ -410,17 +409,17 @@
           );
   
           // check each role has the right values, compared against the master copy
  -        for ( int i = 0; i < rolesMODEL.length; ++i )
  +        for( int i = 0; i < rolesMODEL.length; ++i )
           {
  -            String modelRoleName = rolesMODEL[i].getRole();
  +            String modelRoleName = rolesMODEL[ i ].getRole();
               Configuration masterRoleConfig = null;
   
               // get the real role configuration object
  -            for ( int j = 0; j < rolesREAL.length; ++j )
  +            for( int j = 0; j < rolesREAL.length; ++j )
               {
  -                if ( modelRoleName.equals( rolesREAL[j].getAttribute( "name" ) ) )
  +                if( modelRoleName.equals( rolesREAL[ j ].getAttribute( "name" ) ) )
                   {
  -                    masterRoleConfig = rolesREAL[j];
  +                    masterRoleConfig = rolesREAL[ j ];
                       break;
                   }
               }
  @@ -432,12 +431,12 @@
               );
   
               // convert our RoleRef object into a Configuration and compare with the master
  -            Configuration modelRoleConfig = fortress.buildRole( rolesMODEL[i] );
  +            Configuration modelRoleConfig = fortress.buildRole( rolesMODEL[ i ] );
   
               assertTrue(
                   "Role configuration trees differ\n" +
  -                "(master)" + ConfigurationUtil.list( masterRoleConfig ) +
  -                "(model)" + ConfigurationUtil.list( modelRoleConfig ),
  +                "(master)" + list( masterRoleConfig ) +
  +                "(model)" + list( modelRoleConfig ),
                   ConfigurationUtil.equals( masterRoleConfig, modelRoleConfig )
               );
           }
  @@ -448,5 +447,56 @@
       public static final void main( String[] args )
       {
           TestRunner.run( xfcTestCase.class );
  +    }
  +
  +    /**
  +     * Returns a simple string representation of the the supplied configuration.
  +     * @param config a configuration
  +     * @return a simplified text representation of a configuration suitable
  +     *     for debugging
  +     */
  +    public static String list( Configuration config )
  +    {
  +        final StringBuffer buffer = new StringBuffer();
  +        list( buffer, "  ", config );
  +        buffer.append( "\n" );
  +        return buffer.toString();
  +    }
  +
  +    private static void list( StringBuffer buffer, String lead, Configuration config )
  +    {
  +
  +        buffer.append( "\n" + lead + "<" + config.getName() );
  +        String[] names = config.getAttributeNames();
  +        if( names.length > 0 )
  +        {
  +            for( int i = 0; i < names.length; i++ )
  +            {
  +                buffer.append( " "
  +                               + names[ i ] + "=\""
  +                               + config.getAttribute( names[ i ], "???" ) + "\"" );
  +            }
  +        }
  +        Configuration[] children = config.getChildren();
  +        if( children.length > 0 )
  +        {
  +            buffer.append( ">" );
  +            for( int j = 0; j < children.length; j++ )
  +            {
  +                list( buffer, lead + "  ", children[ j ] );
  +            }
  +            buffer.append( "\n" + lead + "</" + config.getName() + ">" );
  +        }
  +        else
  +        {
  +            if( config.getValue( null ) != null )
  +            {
  +                buffer.append( ">" + config.getValue( "" ) + "</" + config.getName()
+ ">" );
  +            }
  +            else
  +            {
  +                buffer.append( "/>" );
  +            }
  +        }
       }
   }
  
  
  
  1.10      +3 -5      avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/util/ECMTestRig.java
  
  Index: ECMTestRig.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/util/ECMTestRig.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ECMTestRig.java	22 Mar 2003 12:46:58 -0000	1.9
  +++ ECMTestRig.java	3 May 2003 04:11:07 -0000	1.10
  @@ -93,9 +93,7 @@
           {
               m_roles = new DefaultConfiguration( "", "" );
               roleref.accept( this );
  -            return m_roles.getChildren()[0];
  +            return m_roles.getChildren()[ 0 ];
           }
       }
  -}
  -
  -
  +}
  \ No newline at end of file
  
  
  
  1.8       +2 -2      avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/util/FortressTestRig.java
  
  Index: FortressTestRig.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/xfc/src/test/org/apache/excalibur/xfc/test/util/FortressTestRig.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FortressTestRig.java	22 Mar 2003 12:46:58 -0000	1.7
  +++ FortressTestRig.java	3 May 2003 04:11:07 -0000	1.8
  @@ -87,7 +87,7 @@
           {
               m_roles = new DefaultConfiguration( "", "" );
               roleref.accept( this );
  -            return m_roles.getChildren()[0];
  +            return m_roles.getChildren()[ 0 ];
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message