Examples of FileEvent


Examples of com.sun.jna.examples.FileMonitor.FileEvent

    private FileEvent waitForFileEvent(final int expectedFileEvent)
            throws InterruptedException {

        final Integer expectedFileEventInteger = new Integer(expectedFileEvent);

        FileEvent actualEvent = (FileEvent)events.get(expectedFileEventInteger);
        final long start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 5000 && actualEvent == null) {
            Thread.sleep(10);
            actualEvent = (FileEvent) events.get(expectedFileEventInteger);
        }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

    public void testNotifyOnFileDelete() throws Exception {
        monitor.addWatch(tmpdir);
        File file = File.createTempFile(getName(), ".tmp", tmpdir);
        file.delete();

        final FileEvent event = waitForFileEvent(FileMonitor.FILE_DELETED);
        assertNotNull("No delete event: " + events, event);
        assertEquals("Wrong target file for event", file, event.getFile());
    }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

        monitor.addWatch(tmpdir, FileMonitor.FILE_DELETED);
        File file = File.createTempFile(getName(), ".tmp", tmpdir);
        file.delete();

        final FileEvent event = waitForFileEvent(FileMonitor.FILE_DELETED);
        assertNotNull("No delete event: " + events, event);
        assertEquals("Wrong target file for event", file, event.getFile());
    }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

        File newFile = new File(file.getParentFile(), "newfile");
        newFile.deleteOnExit();
        file.deleteOnExit();
        file.renameTo(newFile);

        final FileEvent eventFilenameOld = waitForFileEvent(FileMonitor.FILE_NAME_CHANGED_OLD);
        final FileEvent eventFilenameNew = waitForFileEvent(FileMonitor.FILE_NAME_CHANGED_NEW);
        assertNotNull("No rename event (old): " + events, eventFilenameOld);
        assertNotNull("No rename event (new): " + events, eventFilenameNew);
        assertEquals("Wrong target file for event (old)", file, eventFilenameOld.getFile());
        assertEquals("Wrong target file for event (new)", newFile, eventFilenameNew.getFile());
    }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

        try {
            os.write(getName().getBytes());
        } finally {
            os.close();
        }
        final FileEvent event = waitForFileEvent(FileMonitor.FILE_MODIFIED);
        assertNotNull("No file modified event: " + events, event);
        assertEquals("Wrong target file for event (old)", file, event.getFile());
    }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

    }

    private void assertFileEventCreated(final File expectedFile)
            throws InterruptedException {

        final FileEvent actualEvent = waitForFileEvent(FileMonitor.FILE_CREATED);

        assertNotNull("No creation event: " + events, actualEvent);
        assertEquals("Wrong target file for event", expectedFile, actualEvent.getFile());
        events.clear();
    }
View Full Code Here

Examples of com.sun.jna.platform.FileMonitor.FileEvent

    private FileEvent waitForFileEvent(final int expectedFileEvent)
            throws InterruptedException {

        final Integer expectedFileEventInteger = new Integer(expectedFileEvent);

        FileEvent actualEvent = (FileEvent)events.get(expectedFileEventInteger);
        final long start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 5000 && actualEvent == null) {
            Thread.sleep(10);
            actualEvent = (FileEvent) events.get(expectedFileEventInteger);
        }
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileEvent

                iter.remove(); // We've processed it
                // Skip this file if it doesn't exist
                final File thisFile = new File(filePath);
                if (thisFile.exists()) {
                    // Record the notification
                    createEvents.add(new FileEvent(new FileDetails(thisFile,
                            thisFile.lastModified()), FileOperation.CREATED,
                            null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.put(thisFile, thisFile.lastModified());
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileEvent

                // Skip this file if it suddenly exists again (it shouldn't be
                // in the notify deleted in this case!)
                final File thisFile = new File(filePath);
                if (!thisFile.exists()) {
                    // Record the notification
                    deleteEvents.add(new FileEvent(new FileDetails(thisFile,
                            null), FileOperation.DELETED, null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.remove(thisFile);
                }
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileEvent

                iter.remove(); // We've processed it
                // Skip this file if it doesn't exist
                final File thisFile = new File(filePath);
                if (thisFile.exists()) {
                    // Record the notification
                    updateEvents.add(new FileEvent(new FileDetails(thisFile,
                            thisFile.lastModified()), FileOperation.UPDATED,
                            null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.put(thisFile, thisFile.lastModified());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.