mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
20-FixResourceManagementIssues
This commit is contained in:
parent
64b84508ed
commit
12905e116b
2 changed files with 17 additions and 9 deletions
|
|
@ -30,6 +30,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static de.kosit.validationtool.impl.Helper.ASSERTIONS;
|
import static de.kosit.validationtool.impl.Helper.ASSERTIONS;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
@ -57,13 +58,15 @@ public class CommandlineApplicationTest {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanup() throws IOException {
|
public void cleanup() throws IOException {
|
||||||
Files.list(Paths.get("")).filter(p -> p.getFileName().toString().endsWith("-report.xml")).forEach(path -> {
|
try ( Stream<Path> stream = Files.list(Paths.get("")) ) {
|
||||||
try {
|
stream.filter(p -> p.getFileName().toString().endsWith("-report.xml")).forEach(path -> {
|
||||||
Files.delete(path);
|
try {
|
||||||
} catch (final IOException e) {
|
Files.delete(path);
|
||||||
log.error("Error deleting file", e);
|
} catch (final IOException e) {
|
||||||
}
|
log.error("Error deleting file", e);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
CommandLine.deactivate();
|
CommandLine.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,7 +189,9 @@ public class CommandlineApplicationTest {
|
||||||
Paths.get(Simple.SIMPLE_VALID).toString() };
|
Paths.get(Simple.SIMPLE_VALID).toString() };
|
||||||
CommandLineApplication.mainProgram(args);
|
CommandLineApplication.mainProgram(args);
|
||||||
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
|
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
|
||||||
assertThat(Files.list(this.output).filter(f -> f.toString().endsWith(".html")).count()).isPositive();
|
try ( Stream<Path> stream = Files.list(this.output) ) {
|
||||||
|
assertThat(stream.filter(f -> f.toString().endsWith(".html")).count()).isPositive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
|
@ -64,6 +65,8 @@ public class ExtractHtmlActionTest {
|
||||||
assertThat(this.action.isSkipped(b)).isFalse();
|
assertThat(this.action.isSkipped(b)).isFalse();
|
||||||
this.action.check(b);
|
this.action.check(b);
|
||||||
assertThat(b.isStopped()).isFalse();
|
assertThat(b.isStopped()).isFalse();
|
||||||
assertThat(Files.list(this.tmpDirectory).collect(Collectors.toList())).hasSize(1);
|
try ( Stream<Path> stream = Files.list(this.tmpDirectory) ) {
|
||||||
|
assertThat(stream.collect(Collectors.toList())).hasSize(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue