final Set removed,
final Set modified,
final File dir )
throws Exception
{
final DirectoryResource resource =
new DirectoryResource( dir.getCanonicalPath() );
final DirectoryTCListener listener = new DirectoryTCListener();
listener.enableLogging( new ConsoleLogger() );
resource.addPropertyChangeListener( listener );
final Iterator adds = added.iterator();
while( adds.hasNext() )
{
final String add = (String)adds.next();
touchFile( dir, add );
}
final Iterator mods = modified.iterator();
while( mods.hasNext() )
{
final String mod = (String)mods.next();
touchFile( dir, mod );
}
final Iterator rems = removed.iterator();
while( rems.hasNext() )
{
final String rem = (String)rems.next();
deleteFile( dir, rem );
}
longDelay();
resource.testModifiedAfter( System.currentTimeMillis() );
final int changeCount = listener.getChangeCount();
resource.testModifiedAfter( System.currentTimeMillis() + 1 );
testExpected( "Add", added, listener.getAdded() );
testExpected( "Remove", removed, listener.getRemoved() );
testExpected( "Modify", modified, listener.getModified() );
assertEquals( "Changes detected. (Should be " + changeCount +