Skip to content

Commit 7e654c5

Browse files
committed
Use Java 11 Files APIs
1 parent 6c1bf0f commit 7e654c5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

platform-tests/src/test/java/org/junit/platform/console/ConsoleDetailsTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.junit.jupiter.api.function.Executable;
4444
import org.junit.platform.console.options.Details;
4545
import org.junit.platform.console.options.Theme;
46+
import org.opentest4j.TestAbortedException;
4647

4748
/**
4849
* @since 1.0
@@ -211,13 +212,13 @@ public void execute() throws Throwable {
211212
var result = wrapper.execute(Optional.empty(), args);
212213

213214
var optionalUri = toUri(dirName, outName);
214-
if (!optionalUri.isPresent()) {
215+
if (optionalUri.isEmpty()) {
215216
if (Boolean.getBoolean("org.junit.platform.console.ConsoleDetailsTests.writeResultOut")) {
216217
// do not use Files.createTempDirectory(prefix) as we want one folder for one container
217218
var temp = Paths.get(System.getProperty("java.io.tmpdir"), dirName.replace('/', '-'));
218219
Files.createDirectories(temp);
219-
var path = Files.write(temp.resolve(outName), result.out.getBytes(UTF_8));
220-
assumeTrue(false,
220+
var path = Files.writeString(temp.resolve(outName), result.out);
221+
throw new TestAbortedException(
221222
format("resource `%s` not found\nwrote console stdout to: %s/%s", dirName, outName, path));
222223
}
223224
fail("could not load resource named `" + dirName + "/" + outName + "`");

platform-tests/src/test/java/org/junit/platform/reporting/legacy/xml/LegacyXmlReportGeneratingListenerTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
package org.junit.platform.reporting.legacy.xml;
1212

13-
import static java.nio.charset.StandardCharsets.UTF_8;
1413
import static java.util.Collections.emptySet;
1514
import static java.util.Collections.singleton;
1615
import static org.assertj.core.api.Assertions.assertThat;
@@ -418,7 +417,7 @@ private void executeTests(TestEngine engine, Path tempDirectory, Clock clock) {
418417

419418
private String readValidXmlFile(Path xmlFile) throws Exception {
420419
assertTrue(Files.exists(xmlFile), () -> "File does not exist: " + xmlFile);
421-
var content = new String(Files.readAllBytes(xmlFile), UTF_8);
420+
var content = Files.readString(xmlFile);
422421
assertValidAccordingToJenkinsSchema(content);
423422
return content;
424423
}

0 commit comments

Comments
 (0)