You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/03/17 17:48:49 UTC

cvs commit: avalon-excalibur/pool/impl/src/test/org/apache/avalon/excalibur/pool/test CascadingAssertionFailedError.java ResourceLimitingPoolMultithreadTestCase.java

mcconnell    2004/03/17 08:48:49

  Modified:    pool/impl/src/test/org/apache/avalon/excalibur/pool/test
                        CascadingAssertionFailedError.java
                        ResourceLimitingPoolMultithreadTestCase.java
  Log:
  Update testcase to sync. with 1.2 version.
  
  Revision  Changes    Path
  1.2       +1 -3      avalon-excalibur/pool/impl/src/test/org/apache/avalon/excalibur/pool/test/CascadingAssertionFailedError.java
  
  Index: CascadingAssertionFailedError.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/pool/impl/src/test/org/apache/avalon/excalibur/pool/test/CascadingAssertionFailedError.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CascadingAssertionFailedError.java	14 Mar 2004 18:01:43 -0000	1.1
  +++ CascadingAssertionFailedError.java	17 Mar 2004 16:48:49 -0000	1.2
  @@ -24,8 +24,6 @@
    * This is an extention to the testing framework so that we can get detailed
    * messages from JUnit (The AssertionFailedError hides the underlying cause)
    *
  - * @deprecated ECM is no longer supported
  - *
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Id$
    */
  
  
  
  1.2       +48 -40    avalon-excalibur/pool/impl/src/test/org/apache/avalon/excalibur/pool/test/ResourceLimitingPoolMultithreadTestCase.java
  
  Index: ResourceLimitingPoolMultithreadTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/pool/impl/src/test/org/apache/avalon/excalibur/pool/test/ResourceLimitingPoolMultithreadTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceLimitingPoolMultithreadTestCase.java	14 Mar 2004 18:01:43 -0000	1.1
  +++ ResourceLimitingPoolMultithreadTestCase.java	17 Mar 2004 16:48:49 -0000	1.2
  @@ -61,9 +61,9 @@
       {
           TestSuite suite = new TestSuite();
   
  -        Timer timer = new ConstantTimer( 100 );
  -        int maxUsers = 10;
  -        int iterations = 10;
  +        Timer timer = new ConstantTimer( 10 );
  +        int maxUsers = 20;
  +        int iterations = 50;
           long maxElapsedTime = 20000;
   
           Test testCase = new ResourceLimitingPoolMultithreadTestCase( "testGetPut" );
  @@ -98,45 +98,53 @@
   
       public static void oneTimeTearDown() throws Exception
       {
  -        /*
  -
  -        COMMENT OUT BECAUSE I'M GETTING 4, NOT 6 - SMELLS LIKE A TIMMING ERROR
  -        PROBABLY RESULTING FROM CHANGERS TO THE LOGGING (DOES THAT MAKE SENSE?)
  -
  -        // The timing of this test makes it so the pool should grow to 5 elements
  -        assertEquals( "1) Pool Ready Size", 6, m_pool.getReadySize() );
  -        assertEquals( "1) Pool Size", 6, m_pool.getSize() );
  -
  -        // Make sure that each of the objects are uniqe by checking them all back out.
  -        Poolable p1 = m_pool.get();
  -        Poolable p2 = m_pool.get();
  -        Poolable p3 = m_pool.get();
  -        Poolable p4 = m_pool.get();
  -        Poolable p5 = m_pool.get();
  +        // Dump the logger.
  +        System.out.println( "Debug output of the logger.  "
  +            + "This is useful for debugging problems if the test fails." );
  +        System.out.println( m_logger.toString() );
  +        System.out.println();
  +        
  +        // The current pool does not have a maximum pool size set so the size to which it has
  +        //  grown will depend greatly on the speed of the machine on which the test is run.
  +        // The size is well tested in other tests when the max size is fixed.
  +        int size = m_pool.getSize();
  +        
  +        System.out.println( "Final pool size is: " + size );
  +        System.out.println();
  +        
  +        // The ready size should be equal to the pool size at this point.
  +        assertEquals( "1) Pool Ready Size", size, m_pool.getReadySize() );
  +        // Any actual pool size is legal
  +        
  +        // Get all objects from the pool.
  +        Poolable[] ps = new Poolable[size];
  +        for ( int i = 0; i < ps.length; i++ )
  +        {
  +            ps[i] = m_pool.get();
  +        }
   
  +        // Make sure that all of the elements were checked out.
           assertEquals( "2) Pool Ready Size", 0, m_pool.getReadySize() );
  -        assertEquals( "2) Pool Size", 6, m_pool.getSize() );
  +        assertEquals( "2) Pool Size", size, m_pool.getSize() );
  +        
  +        // Iterate over the elements and make sure that they are all unique.  This
  +        //  is to make sure the pool has not been corrupted.
  +        for ( int i = 0; i < ps.length; i++ )
  +        {
  +            for ( int j = i + 1; j < ps.length; j++ )
  +            {
  +                assertTrue( "ps[" + i + "] != ps[" + j + "]", ps[i] != ps[j] );
  +            }
  +        }
  +        
  +        // Put all the elements back into the pool
  +        for ( int i = 0; i < ps.length; i++ )
  +        {
  +            m_pool.put( ps[i] );
  +        }
   
  -        assertTrue( "p1 != p2", p1 != p2 );
  -        assertTrue( "p1 != p3", p1 != p3 );
  -        assertTrue( "p1 != p4", p1 != p4 );
  -        assertTrue( "p1 != p4", p1 != p5 );
  -        assertTrue( "p2 != p3", p2 != p3 );
  -        assertTrue( "p2 != p4", p2 != p4 );
  -        assertTrue( "p2 != p4", p2 != p5 );
  -        assertTrue( "p3 != p4", p3 != p4 );
  -        assertTrue( "p3 != p4", p3 != p5 );
  -        assertTrue( "p3 != p4", p4 != p5 );
  -
  -        m_pool.put( p1 );
  -        m_pool.put( p2 );
  -        m_pool.put( p3 );
  -        m_pool.put( p4 );
  -        m_pool.put( p5 );
  -
  -        assertEquals( "3) Pool Ready Size", 5, m_pool.getReadySize() );
  -        assertEquals( "3) Pool Size", 5, m_pool.getSize() );
  -        */
  +        assertEquals( "3) Pool Ready Size", size, m_pool.getReadySize() );
  +        assertEquals( "3) Pool Size", size, m_pool.getSize() );
   
           m_pool.dispose();
   
  
  
  

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