Skip to content

Commit 0c36e59

Browse files
committed
Added absolut path test
1 parent e13c192 commit 0c36e59

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/main/java/org/utplsql/maven/plugin/io/ReportWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void writeReports(Connection connection, Reporter reporter, ReporterPara
114114
try {
115115
fileOutputStream.close();
116116
} catch (IOException e) {
117-
log.info(format("Failed to closing the report %s", reporterParameter.getClass()));
117+
log.error(format("Couldn't close the output stream %s", reporterParameter.getClass()));
118118
}
119119
}
120120
}

src/test/java/org/utplsql/maven/plugin/UtPLSQLMojoTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,39 @@ public void junitReporter() throws MojoExecutionException {
3838

3939
assertTrue(new File("target/junit-report.xml").exists());
4040
}
41+
42+
@Test
43+
public void absolutPath() throws MojoExecutionException {
44+
ReporterParameter junitReporter = new ReporterParameter();
45+
junitReporter.setConsoleOutput(true);
46+
47+
String os = System.getProperty("os.name");
48+
if (os.contains("Windows")) {
49+
junitReporter.setFileOutput("c:/tmp/junit-report.xml");
50+
} else {
51+
junitReporter.setFileOutput("/tmp/junit-report.xml");
52+
}
53+
junitReporter.setName(CoreReporters.UT_JUNIT_REPORTER.name());
54+
utPLSQLMojo.reporters.add(junitReporter);
55+
56+
utPLSQLMojo.execute();
57+
if (os.contains("Windows")) {
58+
assertTrue(new File("c:/tmp/junit-report.xml").exists());
59+
} else {
60+
assertTrue(new File("/tmp/junit-report.xml").exists());
61+
}
62+
}
63+
64+
@Test
65+
public void parentDoesNotExist() throws MojoExecutionException {
66+
ReporterParameter junitReporter = new ReporterParameter();
67+
junitReporter.setConsoleOutput(true);
68+
junitReporter.setFileOutput("not-exist/junit-report.xml");
69+
junitReporter.setName(CoreReporters.UT_JUNIT_REPORTER.name());
70+
utPLSQLMojo.reporters.add(junitReporter);
71+
72+
utPLSQLMojo.execute();
73+
74+
assertTrue(new File("target/not-exist/junit-report.xml").exists());
75+
}
4176
}

0 commit comments

Comments
 (0)