donaldp 2002/09/13 03:11:42
Modified: monitor/src/java/org/apache/avalon/excalibur/monitor
ActiveMonitor.java DirectoryResource.java
PassiveMonitor.java
monitor/src/test/org/apache/avalon/excalibur/monitor/test
DirectoryTestCase.java
DirectoryTestCaseListener.java
MonitorTestCase.xtest
Added: monitor/src/test/org/apache/avalon/excalibur/monitor/test
ActiveMonitorComponent.java
PassiveMonitorComponent.java
Log:
Add unit tests to make sure that changes in directory are only noted once. Fix
DirectoryResource to make sure that added files are only detected first time they are
added.
Revision Changes Path
1.16 +2 -2
jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ActiveMonitor.java
Index: ActiveMonitor.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/ActiveMonitor.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ActiveMonitor.java 7 Sep 2002 12:15:00 -0000 1.15
+++ ActiveMonitor.java 13 Sep 2002 10:11:41 -0000 1.16
@@ -35,7 +35,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version $Id$
*/
-public final class ActiveMonitor
+public class ActiveMonitor
extends org.apache.avalon.excalibur.monitor.impl.ActiveMonitor
implements LogEnabled, Configurable, Startable, ThreadSafe
{
1.2 +2 -1
jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/DirectoryResource.java
Index: DirectoryResource.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/DirectoryResource.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectoryResource.java 8 Sep 2002 02:30:48 -0000 1.1
+++ DirectoryResource.java 13 Sep 2002 10:11:41 -0000 1.2
@@ -147,6 +147,7 @@
modifiedFiles );
}
+ existingFiles.addAll( addedFiles );
m_files = existingFiles;
}
1.12 +2 -2
jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/PassiveMonitor.java
Index: PassiveMonitor.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/PassiveMonitor.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PassiveMonitor.java 7 Sep 2002 12:14:01 -0000 1.11
+++ PassiveMonitor.java 13 Sep 2002 10:11:41 -0000 1.12
@@ -33,7 +33,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version $Id$
*/
-public final class PassiveMonitor
+public class PassiveMonitor
extends org.apache.avalon.excalibur.monitor.impl.PassiveMonitor
implements LogEnabled, Configurable, ThreadSafe
{
1.2 +7 -1
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectoryTestCase.java 8 Sep 2002 02:30:48 -0000 1.1
+++ DirectoryTestCase.java 13 Sep 2002 10:11:41 -0000 1.2
@@ -120,10 +120,16 @@
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 +
+ " as no changes occured between two tests)",
+ changeCount,
+ listener.getChangeCount() );
listener.reset();
}
1.2 +7 -0
jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCaseListener.java
Index: DirectoryTestCaseListener.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/DirectoryTestCaseListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectoryTestCaseListener.java 8 Sep 2002 02:30:48 -0000 1.1
+++ DirectoryTestCaseListener.java 13 Sep 2002 10:11:41 -0000 1.2
@@ -18,6 +18,7 @@
extends AbstractLogEnabled
implements PropertyChangeListener
{
+ private int m_changeCount;
private Set m_added = Collections.EMPTY_SET;
private Set m_removed = Collections.EMPTY_SET;
private Set m_modified = Collections.EMPTY_SET;
@@ -44,8 +45,14 @@
return m_modified;
}
+ public int getChangeCount()
+ {
+ return m_changeCount;
+ }
+
public void propertyChange( final PropertyChangeEvent event )
{
+ m_changeCount++;
final String name = event.getPropertyName();
final Set newValue = (Set)event.getNewValue();
if( name.equals( DirectoryResource.ADDED ) )
1.7 +2 -2
jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCase.xtest
Index: MonitorTestCase.xtest
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/MonitorTestCase.xtest,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MonitorTestCase.xtest 7 Sep 2002 12:14:02 -0000 1.6
+++ MonitorTestCase.xtest 13 Sep 2002 10:11:41 -0000 1.7
@@ -39,8 +39,8 @@
<role name="org.apache.avalon.excalibur.monitor.MonitorSelector"
shorthand="monitors"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
- <hint shorthand="active-monitor"
class="org.apache.avalon.excalibur.monitor.ActiveMonitor"/>
- <hint shorthand="passive-monitor"
class="org.apache.avalon.excalibur.monitor.PassiveMonitor"/>
+ <hint shorthand="active-monitor"
class="org.apache.avalon.excalibur.monitor.test.ActiveMonitorComponent"/>
+ <hint shorthand="passive-monitor"
class="org.apache.avalon.excalibur.monitor.test.PassiveMonitorComponent"/>
</role>
</roles>
1.1
jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/ActiveMonitorComponent.java
Index: ActiveMonitorComponent.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.monitor.test;
import org.apache.avalon.excalibur.monitor.ActiveMonitor;
import org.apache.avalon.framework.component.Component;
/**
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/09/13 10:11:41 $
*/
public class ActiveMonitorComponent
extends ActiveMonitor
implements Component
{
}
1.1
jakarta-avalon-excalibur/monitor/src/test/org/apache/avalon/excalibur/monitor/test/PassiveMonitorComponent.java
Index: PassiveMonitorComponent.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.monitor.test;
import org.apache.avalon.excalibur.monitor.PassiveMonitor;
import org.apache.avalon.framework.component.Component;
/**
* implement component
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/09/13 10:11:41 $
*/
public class PassiveMonitorComponent
extends PassiveMonitor
implements Component
{
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>