@Test public void testView() throws IOException { UserDefinedFileAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS); assertNotNull(view); assertThat(view.name()).isEqualTo("user"); assertThat(view.list()).isEmpty(); byte[] b1 = {0, 1, 2}; byte[] b2 = {0, 1, 2, 3, 4}; view.write("b1", ByteBuffer.wrap(b1)); view.write("b2", ByteBuffer.wrap(b2)); assertThat(view.list()).containsAtLeast("b1", "b2"); assertThat(file.getAttributeKeys()).containsExactly("user:b1", "user:b2"); assertThat(view.size("b1")).isEqualTo(3); assertThat(view.size("b2")).isEqualTo(5); ByteBuffer buf1 = ByteBuffer.allocate(view.size("b1")); ByteBuffer buf2 = ByteBuffer.allocate(view.size("b2")); view.read("b1", buf1); view.read("b2", buf2); assertThat(Arrays.equals(b1, buf1.array())).isTrue(); assertThat(Arrays.equals(b2, buf2.array())).isTrue(); view.delete("b2"); assertThat(view.list()).containsExactly("b1"); assertThat(file.getAttributeKeys()).containsExactly("user:b1"); try { view.size("b2"); fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage()).contains("not set"); } try { view.read("b2", ByteBuffer.allocate(10)); fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage()).contains("not set"); } view.write("b1", ByteBuffer.wrap(b2)); assertThat(view.size("b1")).isEqualTo(5); view.delete("b2"); }
@Override public UserDefinedFileAttributeView view( FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup); }
UserDefinedAttributeProvider extends AttributeProvider { @Override public UserDefinedFileAttributeView view( FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup); } }
UserDefinedAttributeProvider extends AttributeProvider { @Override public UserDefinedFileAttributeView view( FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup); } UserDefinedAttributeProvider(); }
UserDefinedAttributeProvider extends AttributeProvider { @Override public UserDefinedFileAttributeView view( FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup); } UserDefinedAttributeProvider(); @Override String name(); @Override ImmutableSet<String> fixedAttributes(); @Override boolean supports(String attribute); @Override ImmutableSet<String> attributes(File file); @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<UserDefinedFileAttributeView> viewType(); @Override UserDefinedFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); }
UserDefinedAttributeProvider extends AttributeProvider { @Override public UserDefinedFileAttributeView view( FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup); } UserDefinedAttributeProvider(); @Override String name(); @Override ImmutableSet<String> fixedAttributes(); @Override boolean supports(String attribute); @Override ImmutableSet<String> attributes(File file); @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<UserDefinedFileAttributeView> viewType(); @Override UserDefinedFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews);  }