Package org.uberfire.java.nio.fs.file

Examples of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider


    }

    @Test
    public void checkNewFileChannel() throws IOException {
        final File temp = File.createTempFile( "foo", "bar" );
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), temp );

        final FileChannel stream = fsProvider.newFileChannel( path, null );

        assertThat( stream ).isNotNull();
        stream.close();
    }
View Full Code Here


        stream.close();
    }

    @Test(expected = org.uberfire.java.nio.IOException.class)
    public void fileChannelFileDoesntExists() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "/path/to/file.txt", false );

        fsProvider.newFileChannel( path, null );
    }
View Full Code Here

        fsProvider.newFileChannel( path, null );
    }

    @Test(expected = IllegalArgumentException.class)
    public void fileChannelNull() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        fsProvider.newFileChannel( null, null );
    }
View Full Code Here

        fsProvider.newFileChannel( null, null );
    }

    @Test
    public void checkNewByteChannelToCreateFile() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final String userBasedPath = System.getProperty( "user.dir" ) + "/byte_some_file_here.txt";

        final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), userBasedPath, false );
        assertThat( path.toFile().exists() ).isFalse();

        final SeekableByteChannel channel = fsProvider.newByteChannel( path, null );

        assertThat( channel ).isNotNull();
        assertThat( path.toFile().exists() ).isTrue();
        path.toFile().delete();
        assertThat( path.toFile().exists() ).isFalse();
View Full Code Here

        assertThat( path.toFile().exists() ).isFalse();
    }

    @Test(expected = FileAlreadyExistsException.class)
    public void newByteChannelFileAlreadyExists() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final File tempFile = File.createTempFile( "foo", "bar" );
        final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), tempFile );

        assertThat( path.toFile().exists() ).isTrue();
        assertThat( path.toFile() ).isEqualTo( tempFile );

        fsProvider.newByteChannel( path, null );
    }
View Full Code Here

        fsProvider.newByteChannel( path, null );
    }

    @Test(expected = org.uberfire.java.nio.IOException.class)
    public void newByteChannelInvalidPath() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final String userBasedPath = System.getProperty( "user.dir" ) + "path/to/some_file_here.txt";

        final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), userBasedPath, false );
        assertThat( path.toFile().exists() ).isFalse();

        fsProvider.newByteChannel( path, null );
    }
View Full Code Here

        fsProvider.newByteChannel( path, null );
    }

    @Test(expected = IllegalArgumentException.class)
    public void newByteChannelNull() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        fsProvider.newByteChannel( null, null );
    }
View Full Code Here

        fsProvider.newByteChannel( null, null );
    }

    @Test(expected = UnsupportedOperationException.class)
    public void newAsynchronousFileChannelUnsupportedOp() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "/path/to/file.txt", false );

        fsProvider.newAsynchronousFileChannel( path, null, null );
    }
View Full Code Here

        fsProvider.newAsynchronousFileChannel( path, null, null );
    }

    @Test(expected = IllegalArgumentException.class)
    public void newAsynchronousFileChannelNull() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        fsProvider.newAsynchronousFileChannel( null, null, null );
    }
View Full Code Here

        fsProvider.newAsynchronousFileChannel( null, null, null );
    }

    @Test
    public void seekableByteChannel() throws IOException {
        final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();

        final String userBasedPath = System.getProperty( "user.dir" ) + "/my_byte_some_file_here.txt";

        final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), userBasedPath, false );
        assertThat( path.toFile().exists() ).isFalse();

        final SeekableByteChannel channel = fsProvider.newByteChannel( path, null );

        assertThat( channel ).isNotNull();
        assertThat( path.toFile().exists() ).isTrue();

        assertThat( channel.isOpen() ).isTrue();
View Full Code Here

TOP

Related Classes of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider

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.