* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.io;
-import junit.framework.TestCase;
-
-import org.apache.oro.io.AwkFilenameFilter;
import static org.mockito.Mockito.*;
+import junit.framework.TestCase;
public class DirectoryMonitorTest extends TestCase {
private static final String REGEX = "^.*\\.txt$";
data = new TestData(this);
data.clean();
listener = mock(DirectoryMonitor.Listener.class);
- monitor = new DirectoryMonitor(data.getRoot(), new AwkFilenameFilter(
+ monitor = new DirectoryMonitor(data.getRoot(), new RegexFilenameFilter(
REGEX), listener);
}
verifyNoMoreInteractions(listener);
}
+ public void testFileModificationTimeChanged() throws InterruptedException {
+ data.createFile(FILE1, "hello");
+ monitor.poll();
+ reset(listener);
+ data.deleteFile(FILE1);
+ Thread.sleep(2000);
+ data.createFile(FILE1, "hello");
+
+ monitor.poll();
+ verify(listener).fileChanged(data.getFile(FILE1));
+ verifyNoMoreInteractions(listener);
+ }
+
public void testFileFilterIsUsed() {
monitor.poll();
monitor.poll();
data.createFile(FILE1, "hello");
- stubVoid(listener).toThrow(new RuntimeException()).on().fileCreated(
- data.getFile(FILE1));
+ stubVoid(listener).toThrow(new RuntimeException()).on()
+ .fileCreated(data.getFile(FILE1));
try {
monitor.poll();