diff --git a/pom.xml b/pom.xml index 2e9c16e..4d1e25b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.utplsql cli - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT jar cli @@ -22,7 +22,7 @@ org.utplsql java-api - 3.1.0 + 3.1.1-SNAPSHOT compile @@ -61,6 +61,11 @@ ${junit.jupiter.version} test + + javax.xml.bind + jaxb-api + 2.3.0 + diff --git a/src/main/java/org/utplsql/cli/ConnectionInfo.java b/src/main/java/org/utplsql/cli/ConnectionInfo.java index d96a67f..f1a32a2 100644 --- a/src/main/java/org/utplsql/cli/ConnectionInfo.java +++ b/src/main/java/org/utplsql/cli/ConnectionInfo.java @@ -27,7 +27,10 @@ public ConnectionInfo(String connectionInfo) { pds.setJdbcUrl("jdbc:oracle:thin:" + connectionInfo); pds.setAutoCommit(false); + } + public void setMaxConnections( int maxConnections ) { + pds.setMaximumPoolSize(maxConnections); } public Connection getConnection() throws SQLException { diff --git a/src/main/java/org/utplsql/cli/ReporterManager.java b/src/main/java/org/utplsql/cli/ReporterManager.java index 22f59a8..aac7ddf 100644 --- a/src/main/java/org/utplsql/cli/ReporterManager.java +++ b/src/main/java/org/utplsql/cli/ReporterManager.java @@ -116,4 +116,6 @@ public void startReporterGatherers(ExecutorService executorService, final Connec public List getReporterOptionsList() { return reporterOptionsList; } + + public int getNumberOfReporters() { return reporterOptionsList.size(); }; } diff --git a/src/main/java/org/utplsql/cli/RunCommand.java b/src/main/java/org/utplsql/cli/RunCommand.java index 2251853..12ea83f 100644 --- a/src/main/java/org/utplsql/cli/RunCommand.java +++ b/src/main/java/org/utplsql/cli/RunCommand.java @@ -113,7 +113,6 @@ public int run() throws Exception { RunCommandChecker.checkOracleJDBCExists(); - final ConnectionInfo ci = getConnectionInfo(); final List reporterList; final List testPaths = getTestPaths(); @@ -145,6 +144,9 @@ public int run() throws Exception { final ArrayList finalIncludeObjectsList = includeObjectsList; final ArrayList finalExcludeObjectsList = excludeObjectsList; + final ConnectionInfo ci = getConnectionInfo(); + ci.setMaxConnections(getReporterManager().getNumberOfReporters()+1); + // Do the reporters initialization, so we can use the id to run and gather results. try (Connection conn = ci.getConnection()) { diff --git a/src/test/java/org/utplsql/cli/AbstractFileOutputTest.java b/src/test/java/org/utplsql/cli/AbstractFileOutputTest.java new file mode 100644 index 0000000..7cafd58 --- /dev/null +++ b/src/test/java/org/utplsql/cli/AbstractFileOutputTest.java @@ -0,0 +1,42 @@ +package org.utplsql.cli; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +import java.io.File; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; + +public abstract class AbstractFileOutputTest { + + private Set tempPaths; + + protected void addTempPath(Path path) { + tempPaths.add(path); + } + + protected boolean tempPathExists( Path path ) { return tempPaths.contains(path); } + + @BeforeEach + public void setupTest() { + tempPaths = new HashSet<>(); + } + + @AfterEach + public void deleteTempFiles() { + tempPaths.forEach(p -> deleteDir(p.toFile())); + } + + void deleteDir(File file) { + if (file.exists()) { + File[] contents = file.listFiles(); + if (contents != null) { + for (File f : contents) { + deleteDir(f); + } + } + file.delete(); + } + } +} diff --git a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java index 7a2e6f5..cc661ef 100644 --- a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java +++ b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java @@ -22,15 +22,10 @@ * * @author pesse */ -public class RunCommandCoverageReporterIT { +public class RunCommandCoverageReporterIT extends AbstractFileOutputTest { private static final Pattern REGEX_COVERAGE_TITLE = Pattern.compile("([a-zA-Z0-9\\._]+)<\\/a>"); - private Set tempPaths; - - private void addTempPath(Path path) { - tempPaths.add(path); - } private String getTempCoverageFileName(int counter) { @@ -47,7 +42,7 @@ private Path getTempCoverageFilePath() { int i = 1; Path p = Paths.get(getTempCoverageFileName(i)); - while ((Files.exists(p) || tempPaths.contains(p)) && i < 100) + while ((Files.exists(p) || tempPathExists(p)) && i < 100) p = Paths.get(getTempCoverageFileName(i++)); if (i >= 100) @@ -77,11 +72,6 @@ private boolean hasCoverageListed(String content, String packageName) { return false; } - @BeforeEach - public void setupTest() { - tempPaths = new HashSet<>(); - } - @Test public void run_CodeCoverageWithIncludeAndExclude() throws Exception { @@ -90,10 +80,9 @@ public void run_CodeCoverageWithIncludeAndExclude() throws Exception { RunCommand runCmd = RunCommandTestHelper.createRunCommand(RunCommandTestHelper.getConnectionString(), "-f=ut_coverage_html_reporter", "-o=" + coveragePath, "-s", "-exclude=app.award_bonus,app.betwnstr"); - int result = runCmd.run(); - String content = new Scanner(coveragePath).useDelimiter("\\Z").next(); + String content = new String(Files.readAllBytes(coveragePath)); assertEquals(true, hasCoverageListed(content, "app.remove_rooms_by_name")); assertEquals(false, hasCoverageListed(content, "app.award_bonus")); @@ -122,27 +111,11 @@ public void coverageReporterWriteAssetsToOutput() throws Exception { assertTrue(applicationJs.exists()); // Check correct script-part in HTML source exists - String content = new Scanner(coveragePath).useDelimiter("\\Z").next(); + String content = new String(Files.readAllBytes(coveragePath)); assertTrue(content.contains("