Skip to content

Commit

Permalink
Fix for issue 654 ... again, many of the types from Java package 'jav…
Browse files Browse the repository at this point in the history
…a.nio.file.attribute' are not fs agnostic; as we prefer not having fs specific conditions, we limit ourselvs to basic attribute
  • Loading branch information
tglaeser committed Aug 1, 2020
1 parent d537dd4 commit 63d8579
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions testlib/src/main/java/com/diffplug/spotless/ResourceHarness.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.AclEntry;
import java.nio.file.attribute.AclFileAttributeView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
Expand Down Expand Up @@ -169,9 +168,15 @@ protected void assertOnResources(FormatterFunc step, String unformattedPath, Str
}

/** Reads file attributes from the output file and compares it to the attributes from the input file. */
protected void assertFileAttributesEqual(File input, File output) throws IOException {
List<AclEntry> inputAttributes = Files.getFileAttributeView(input.toPath(), AclFileAttributeView.class).getAcl();
List<AclEntry> outputAttributes = Files.getFileAttributeView(output.toPath(), AclFileAttributeView.class).getAcl();
protected void assertFileAttributesEqual(File input, File output) {
List<Boolean> inputAttributes = new LinkedList<>();
List<Boolean> outputAttributes = new LinkedList<>();
inputAttributes.add(Files.isReadable(input.toPath()));
inputAttributes.add(Files.isWritable(input.toPath()));
inputAttributes.add(Files.isExecutable(input.toPath()));
outputAttributes.add(Files.isReadable(output.toPath()));
outputAttributes.add(Files.isWritable(output.toPath()));
outputAttributes.add(Files.isExecutable(output.toPath()));
Assertions.assertThat(outputAttributes).isEqualTo(inputAttributes);
}

Expand Down

0 comments on commit 63d8579

Please sign in to comment.