From 07b7e751caf008d8c2069a21cdcb1659831f6cc1 Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 17 May 2018 22:15:47 +0200 Subject: [PATCH 1/3] To be honest - that was a pretty dumb way of loading a file... --- .../java/org/utplsql/cli/RunCommandCoverageReporterIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java index 7a2e6f5..3bc2a21 100644 --- a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java +++ b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java @@ -90,10 +90,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")); From 41367ab903f925cce95bb86e14605ebe3eee9b74 Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 17 May 2018 22:19:23 +0200 Subject: [PATCH 2/3] Bump version and fix #82 --- pom.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 + From a2a76185b41d8152a668b40055aeacab0409d586 Mon Sep 17 00:00:00 2001 From: pesse Date: Thu, 17 May 2018 23:24:23 +0200 Subject: [PATCH 3/3] Limit connection pool to number of reporters +1 Fixes #85. Also added a multi-reporter integration-test --- .../java/org/utplsql/cli/ConnectionInfo.java | 3 ++ .../java/org/utplsql/cli/ReporterManager.java | 2 + src/main/java/org/utplsql/cli/RunCommand.java | 4 +- .../utplsql/cli/AbstractFileOutputTest.java | 42 +++++++++++++++++++ .../cli/RunCommandCoverageReporterIT.java | 32 ++------------ .../java/org/utplsql/cli/RunCommandIT.java | 27 +++++++++++- 6 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 src/test/java/org/utplsql/cli/AbstractFileOutputTest.java 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 3bc2a21..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 { @@ -121,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("