Fix compatiblity with Microsoft Windows

Closes gh-879
This commit is contained in:
Stephane Nicoll
2019-05-28 14:30:51 +02:00
parent 62d0a94364
commit e6f287b298
6 changed files with 29 additions and 12 deletions

View File

@@ -60,13 +60,17 @@ class GradleWrapperContributorTests {
private Consumer<Path> isNotExecutable() {
return (path) -> {
if (Files.isExecutable(path)) {
if (supportsExecutableFlag() && Files.isExecutable(path)) {
throw Failures.instance().failure(String
.format("%nExpecting:%n <%s>%nto not be executable.", path));
}
};
}
private static boolean supportsExecutableFlag() {
return !System.getProperty("os.name").startsWith("Windows");
}
Path contribute(String gradleVersion) throws IOException {
Path projectDir = Files.createTempDirectory(this.directory, "project-");
new GradleWrapperContributor(gradleVersion).contribute(projectDir);

View File

@@ -52,13 +52,17 @@ class MavenWrapperContributorTests {
private Consumer<Path> isNotExecutable() {
return (path) -> {
if (Files.isExecutable(path)) {
if (supportsExecutableFlag() && Files.isExecutable(path)) {
throw Failures.instance().failure(String
.format("%nExpecting:%n <%s>%nto not be executable.", path));
}
};
}
private static boolean supportsExecutableFlag() {
return !System.getProperty("os.name").startsWith("Windows");
}
Path contribute() throws IOException {
Path projectDir = Files.createTempDirectory(this.directory, "project-");
new MavenWrapperContributor().contribute(projectDir);

View File

@@ -42,8 +42,8 @@ public class SourceCodeAssert {
}
public SourceCodeAssert equalsTo(Resource expected) {
try (InputStream stream = expected.getInputStream()) {
String expectedContent = StreamUtils.copyToString(stream,
try (InputStream in = expected.getInputStream()) {
String expectedContent = StreamUtils.copyToString(in,
Charset.forName("UTF-8"));
assertThat(this.content).describedAs("Content for %s", this.name)
.isEqualTo(expectedContent.replaceAll("\r\n", "\n"));