Skip to content

Commit 3cd7c36

Browse files
pzygieloslachiewicz
authored andcommitted
Keep files in temporary directory to be deleted after test
1 parent e608719 commit 3cd7c36

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void testTreeTGFSerializing() throws Exception {
160160
* Test the JSON format serialization on DependencyNodes with circular dependence
161161
*/
162162
public void testTreeJsonCircularDependency() throws IOException {
163-
String outputFileName = testDir.getAbsolutePath() + "tree1.json";
163+
String outputFileName = testDir.getAbsolutePath() + File.separator + "tree1.json";
164164
File outputFile = new File(outputFileName);
165165
Files.createDirectories(outputFile.getParentFile().toPath());
166166
outputFile.createNewFile();
@@ -176,10 +176,11 @@ public void testTreeJsonCircularDependency() throws IOException {
176176
node1.getChildren().add(node2);
177177
node2.getChildren().add(node1);
178178

179-
JsonDependencyNodeVisitor jsonDependencyNodeVisitor =
180-
new JsonDependencyNodeVisitor(new OutputStreamWriter(new FileOutputStream(outputFile)));
179+
try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(outputFile))) {
180+
JsonDependencyNodeVisitor jsonDependencyNodeVisitor = new JsonDependencyNodeVisitor(outputStreamWriter);
181181

182-
jsonDependencyNodeVisitor.visit(node1);
182+
jsonDependencyNodeVisitor.visit(node1);
183+
}
183184
}
184185

185186
/*
@@ -239,7 +240,7 @@ public void testTreeJsonParsing() throws Exception {
239240
*/
240241
private List<String> runTreeMojo(String outputFile, String format) throws Exception {
241242
File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml");
242-
Path outputFilePath = Paths.get(testDir.getAbsolutePath() + outputFile);
243+
Path outputFilePath = Paths.get(testDir.getAbsolutePath(), outputFile);
243244
TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom);
244245
setVariableValueToObject(mojo, "outputEncoding", "UTF-8");
245246
setVariableValueToObject(mojo, "outputType", format);

0 commit comments

Comments
 (0)