Package org.apache.commons.vfs2.impl

Examples of org.apache.commons.vfs2.impl.DecoratedFileObject


    }

    public void testFileCreated() throws Exception
    {
        FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
        DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
        monitor.setDelay(100);
        monitor.addFile(fileObj);
        monitor.start();
        writeToFile(testFile);
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event", changeStatus == 3);
        monitor.stop();
    }
View Full Code Here


    public void testFileDeleted() throws Exception
    {
        writeToFile(testFile);
        FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
        DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
        monitor.setDelay(100);
        monitor.addFile(fileObj);
        monitor.start();
        testFile.delete();
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event", changeStatus == 2);
        monitor.stop();
    }
View Full Code Here

    public void testFileModified() throws Exception
    {
        writeToFile(testFile);
        FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
        DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
        monitor.setDelay(100);
        monitor.addFile(fileObj);
        monitor.start();
        // Need a long delay to insure the new timestamp doesn't truncate to be the same as
        // the current timestammp. Java only guarantees the timestamp will be to 1 second.
        Thread.sleep(1000);
        long value = System.currentTimeMillis();
        boolean rc = testFile.setLastModified(value);
        assertTrue("setLastModified succeeded",rc);
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event", changeStatus == 1);
        monitor.stop();
    }
View Full Code Here


    public void testFileRecreated() throws Exception
    {
        FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
        DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
        monitor.setDelay(100);
        monitor.addFile(fileObj);
        monitor.start();
        writeToFile(testFile);
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
        changeStatus = 0;
        testFile.delete();
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event " + changeStatus, changeStatus == 2);
        changeStatus = 0;
        Thread.sleep(500);
        monitor.addFile(fileObj);
        writeToFile(testFile);
        Thread.sleep(300);
        assertTrue("No event occurred", changeStatus != 0);
        assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
        monitor.stop();
    }
View Full Code Here

        // Create the file system manager
        manager = providerConfig.getDefaultFileSystemManager();
        manager.setFilesCache(providerConfig.getFilesCache());

        final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);
        manager.setReplicator(new PrivilegedFileReplicator(replicator));
        manager.setTemporaryFileStore(replicator);

        providerConfig.prepare(manager);
View Full Code Here

    @Override
    protected void setUp() throws Exception
    {
        super.setUp();

        manager = new DefaultFileSystemManager();
        manager.addProvider("ram", new RamFileProvider());
        manager.init();

        // File Systems Options
        RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSized, 0);
View Full Code Here

     * creates a new uninitialized file system manager
     * @throws Exception
     */
    protected DefaultFileSystemManager createManager() throws Exception
    {
        DefaultFileSystemManager fs = getProviderConfig().getDefaultFileSystemManager();
        fs.setFilesCache(getProviderConfig().getFilesCache());
        getProviderConfig().prepare(fs);
        if (!fs.hasProvider("file"))
        {
            fs.addProvider("file", new DefaultLocalFileProvider());
        }
        return fs;
    }
View Full Code Here

    /**
     * Returns a DefaultFileSystemManager instance (or subclass instance).
     */
    public DefaultFileSystemManager getDefaultFileSystemManager() {
        return new DefaultFileSystemManager();
    }
View Full Code Here

            return;
        }

        scratchFolder.delete(Selectors.EXCLUDE_SELF);

        DefaultFileSystemManager fs = createManager();
        fs.setCacheStrategy(CacheStrategy.MANUAL);
        fs.init();
        FileObject foBase2 = getBaseTestFolder(fs);

        FileObject cachedFolder = foBase2.resolveFile(scratchFolder.getName().getPath());

        FileObject[] fos = cachedFolder.getChildren();
View Full Code Here

            return;
        }

        scratchFolder.delete(Selectors.EXCLUDE_SELF);

        DefaultFileSystemManager fs = createManager();
        fs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
        fs.init();
        FileObject foBase2 = getBaseTestFolder(fs);

        FileObject cachedFolder = foBase2.resolveFile(scratchFolder.getName().getPath());

        FileObject[] fos = cachedFolder.getChildren();
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.impl.DecoratedFileObject

Copyright © 2018 www.massapicom. 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.