avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test DirectoryTestCase.java
Date Fri, 13 Sep 2002 10:55:27 GMT
donaldp     2002/09/13 03:55:27

  Modified:    monitor/src/test/org/apache/avalon/excalibur/monitor/test
                        DirectoryTestCase.java
  Log:
  Add unit test to make sure that directory monitor works even when directory is deleted.
  
  Revision  Changes    Path
  1.3       +29 -6     jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCase.java
  
  Index: DirectoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DirectoryTestCase.java	13 Sep 2002 10:11:41 -0000	1.2
  +++ DirectoryTestCase.java	13 Sep 2002 10:55:27 -0000	1.3
  @@ -67,12 +67,35 @@
           }
           finally
           {
  -            final File[] files = dir.listFiles();
  -            for( int i = 0; i < files.length; i++ )
  -            {
  -                files[ i ].delete();
  -            }
  +            deleteDir( dir );
           }
  +    }
  +
  +    public void testDirectoryDelete()
  +        throws Exception
  +    {
  +        final File dir = createDir();
  +        final DirectoryResource resource =
  +            new DirectoryResource( dir.getCanonicalPath() );
  +        deleteDir( dir );
  +        try
  +        {
  +            resource.testModifiedAfter( System.currentTimeMillis() );
  +        }
  +        catch( final Exception e )
  +        {
  +            fail( "Received exception when dir deleted: " + e );
  +        }
  +    }
  +
  +    private void deleteDir( final File dir )
  +    {
  +        final File[] files = dir.listFiles();
  +        for( int i = 0; i < files.length; i++ )
  +        {
  +            files[ i ].delete();
  +        }
  +        dir.delete();
       }
   
       private File createDir()
  
  
  

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


Mime
View raw message