@Override public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException { delegate.setAttribute(resolveRelative(path), attribute, value, options); }
@Override public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException { Path r = unroot(path); if (log.isTraceEnabled()) { log.trace("setAttribute({})[{}] {}={}", path, r, attribute, value); } FileSystemProvider p = provider(r); p.setAttribute(r, attribute, value, options); }
@Override public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException { Path r = unroot(path); if (log.isTraceEnabled()) { log.trace("setAttribute({})[{}] {}={}", path, r, attribute, value); } FileSystemProvider p = provider(r); p.setAttribute(r, attribute, value, options); }
@Override public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException { BundleFileSystem fs = (BundleFileSystem) path.getFileSystem(); origProvider(path).setAttribute(fs.unwrap(path), attribute, value, options); }
@Override public void setAttribute(final Path path, final String attribute, final Object value, final LinkOption... options) throws IOException { wrapped().setAttribute(unwrap(path), attribute, value, options); } }
@Override public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException { Path r = unroot(path); FileSystemProvider p = provider(r); p.setAttribute(r, attribute, value, options); }
@Test @Category( { Attributes.class, Writable.class, LastModifiedTime.class } ) public void testSetLastModifiedTimeViaString() throws IOException { FileTime past = FileTime.fromMillis( System.currentTimeMillis() - 100000 ); final Path file = getFile(); FS.provider().setAttribute( file, "basic:lastModifiedTime", past ); assertThat( Files.getLastModifiedTime( file ) ). usingComparator( FileTimeComparator.isWithIn( 2000 ) ).isEqualTo( past ); }
@Test @Category( { Attributes.class, Writable.class, Attributes.class, CreationTime.class } ) public void testSetCreationTimeViaString() throws IOException { FileTime past = FileTime.fromMillis( System.currentTimeMillis() - 100000 ); final Path file = fileTA(); FS.provider().setAttribute( file, "basic:creationTime", past ); assertThat( Files.readAttributes( file, BasicFileAttributes.class ).creationTime() ). usingComparator( FileTimeComparator::roughlyComparableTo ).isEqualTo( past ); }
@Test @Category( { Attributes.class, SlowTest.class, Writable.class } ) public void testSetCreationTimeDoesNotChangeLastAccessTime() throws IOException, InterruptedException { final Path file = fileTA(); FileTime before = Files.readAttributes( file, BasicFileAttributes.class ).lastAccessTime(); waitForAttribute(); FS.provider().setAttribute( file, "basic:creationTime", FileTime.fromMillis( System.currentTimeMillis() - 100000 ) ); assertThat( Files.readAttributes( file, BasicFileAttributes.class ).lastAccessTime() ).isEqualTo( before ); }
@Test @Category( { Attributes.class, Writable.class, LastAccessTime.class } ) public void testSetLastAccessTimeViaString() throws IOException { FileTime past = FileTime.fromMillis( System.currentTimeMillis() - 100000 ); final Path file = fileTA(); FS.provider().setAttribute( file, "basic:lastAccessTime", past ); assertThat( Files.readAttributes( file, BasicFileAttributes.class ).lastAccessTime() ). usingComparator( FileTimeComparator::roughlyComparableTo ).isEqualTo( past ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetIsOtherThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:isOther", true )).isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetSizeThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:size", 7 ) ). isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetIsLinkThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:isSymbolicLink", true ) ). isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetIsRegularFileThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:isRegularFile", true )).isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetIsDirectoryThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:isDirectory", true ) ). isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( { Attributes.class, Writable.class } ) public void testSetFileKeyThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "basic:fileKey", true )).isInstanceOf( IllegalArgumentException.class ); }
@Test @Category( Attributes.class ) public void testSetUnsupportedAttributeThrows() throws IOException { assertThatThrownBy( () -> FS.provider().setAttribute( fileTA(), "whoaa:freeze", true )).isInstanceOf( UnsupportedOperationException.class ); }