Skip to content

Commit e8251c7

Browse files
authored
Merge pull request #86 from utPLSQL/bugfix/class_not_found_jaxb
Fixes #82 Fixes #80 Fixes #85
2 parents 055b6a5 + a2a7618 commit e8251c7

File tree

7 files changed

+87
-35
lines changed

7 files changed

+87
-35
lines changed

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.utplsql</groupId>
66
<artifactId>cli</artifactId>
7-
<version>3.1.0-SNAPSHOT</version>
7+
<version>3.1.1-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>cli</name>
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>org.utplsql</groupId>
2424
<artifactId>java-api</artifactId>
25-
<version>3.1.0</version>
25+
<version>3.1.1-SNAPSHOT</version>
2626
<scope>compile</scope>
2727
<exclusions>
2828
<exclusion>
@@ -61,6 +61,11 @@
6161
<version>${junit.jupiter.version}</version>
6262
<scope>test</scope>
6363
</dependency>
64+
<dependency>
65+
<groupId>javax.xml.bind</groupId>
66+
<artifactId>jaxb-api</artifactId>
67+
<version>2.3.0</version>
68+
</dependency>
6469
</dependencies>
6570

6671
<build>

src/main/java/org/utplsql/cli/ConnectionInfo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ public ConnectionInfo(String connectionInfo) {
2727

2828
pds.setJdbcUrl("jdbc:oracle:thin:" + connectionInfo);
2929
pds.setAutoCommit(false);
30+
}
3031

32+
public void setMaxConnections( int maxConnections ) {
33+
pds.setMaximumPoolSize(maxConnections);
3134
}
3235

3336
public Connection getConnection() throws SQLException {

src/main/java/org/utplsql/cli/ReporterManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ public void startReporterGatherers(ExecutorService executorService, final Connec
116116
public List<ReporterOptions> getReporterOptionsList() {
117117
return reporterOptionsList;
118118
}
119+
120+
public int getNumberOfReporters() { return reporterOptionsList.size(); };
119121
}

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public int run() throws Exception {
113113

114114
RunCommandChecker.checkOracleJDBCExists();
115115

116-
final ConnectionInfo ci = getConnectionInfo();
117116

118117
final List<Reporter> reporterList;
119118
final List<String> testPaths = getTestPaths();
@@ -145,6 +144,9 @@ public int run() throws Exception {
145144
final ArrayList<String> finalIncludeObjectsList = includeObjectsList;
146145
final ArrayList<String> finalExcludeObjectsList = excludeObjectsList;
147146

147+
final ConnectionInfo ci = getConnectionInfo();
148+
ci.setMaxConnections(getReporterManager().getNumberOfReporters()+1);
149+
148150
// Do the reporters initialization, so we can use the id to run and gather results.
149151
try (Connection conn = ci.getConnection()) {
150152

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.utplsql.cli;
2+
3+
import org.junit.jupiter.api.AfterEach;
4+
import org.junit.jupiter.api.BeforeEach;
5+
6+
import java.io.File;
7+
import java.nio.file.Path;
8+
import java.util.HashSet;
9+
import java.util.Set;
10+
11+
public abstract class AbstractFileOutputTest {
12+
13+
private Set<Path> tempPaths;
14+
15+
protected void addTempPath(Path path) {
16+
tempPaths.add(path);
17+
}
18+
19+
protected boolean tempPathExists( Path path ) { return tempPaths.contains(path); }
20+
21+
@BeforeEach
22+
public void setupTest() {
23+
tempPaths = new HashSet<>();
24+
}
25+
26+
@AfterEach
27+
public void deleteTempFiles() {
28+
tempPaths.forEach(p -> deleteDir(p.toFile()));
29+
}
30+
31+
void deleteDir(File file) {
32+
if (file.exists()) {
33+
File[] contents = file.listFiles();
34+
if (contents != null) {
35+
for (File f : contents) {
36+
deleteDir(f);
37+
}
38+
}
39+
file.delete();
40+
}
41+
}
42+
}

src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@
2222
*
2323
* @author pesse
2424
*/
25-
public class RunCommandCoverageReporterIT {
25+
public class RunCommandCoverageReporterIT extends AbstractFileOutputTest {
2626

2727
private static final Pattern REGEX_COVERAGE_TITLE = Pattern.compile("<a href=\"[a-zA-Z0-9#]+\" class=\"src_link\" title=\"[a-zA-Z\\._]+\">([a-zA-Z0-9\\._]+)<\\/a>");
2828

29-
private Set<Path> tempPaths;
30-
31-
private void addTempPath(Path path) {
32-
tempPaths.add(path);
33-
}
3429

3530
private String getTempCoverageFileName(int counter) {
3631

@@ -47,7 +42,7 @@ private Path getTempCoverageFilePath() {
4742
int i = 1;
4843
Path p = Paths.get(getTempCoverageFileName(i));
4944

50-
while ((Files.exists(p) || tempPaths.contains(p)) && i < 100)
45+
while ((Files.exists(p) || tempPathExists(p)) && i < 100)
5146
p = Paths.get(getTempCoverageFileName(i++));
5247

5348
if (i >= 100)
@@ -77,11 +72,6 @@ private boolean hasCoverageListed(String content, String packageName) {
7772
return false;
7873
}
7974

80-
@BeforeEach
81-
public void setupTest() {
82-
tempPaths = new HashSet<>();
83-
}
84-
8575
@Test
8676
public void run_CodeCoverageWithIncludeAndExclude() throws Exception {
8777

@@ -90,10 +80,9 @@ public void run_CodeCoverageWithIncludeAndExclude() throws Exception {
9080
RunCommand runCmd = RunCommandTestHelper.createRunCommand(RunCommandTestHelper.getConnectionString(),
9181
"-f=ut_coverage_html_reporter", "-o=" + coveragePath, "-s", "-exclude=app.award_bonus,app.betwnstr");
9282

93-
9483
int result = runCmd.run();
9584

96-
String content = new Scanner(coveragePath).useDelimiter("\\Z").next();
85+
String content = new String(Files.readAllBytes(coveragePath));
9786

9887
assertEquals(true, hasCoverageListed(content, "app.remove_rooms_by_name"));
9988
assertEquals(false, hasCoverageListed(content, "app.award_bonus"));
@@ -122,27 +111,11 @@ public void coverageReporterWriteAssetsToOutput() throws Exception {
122111
assertTrue(applicationJs.exists());
123112

124113
// Check correct script-part in HTML source exists
125-
String content = new Scanner(coveragePath).useDelimiter("\\Z").next();
114+
String content = new String(Files.readAllBytes(coveragePath));
126115
assertTrue(content.contains("<script src='" + coverageAssetsPath.toString() + "/application.js' type='text/javascript'>"));
127116

128117
// Check correct title exists
129118
assertTrue(content.contains("<title>Code coverage</title>"));
130119
}
131120

132-
@AfterEach
133-
public void deleteTempFiles() {
134-
tempPaths.forEach(p -> deleteDir(p.toFile()));
135-
}
136-
137-
void deleteDir(File file) {
138-
if (file.exists()) {
139-
File[] contents = file.listFiles();
140-
if (contents != null) {
141-
for (File f : contents) {
142-
deleteDir(f);
143-
}
144-
}
145-
file.delete();
146-
}
147-
}
148121
}

src/test/java/org/utplsql/cli/RunCommandIT.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import org.junit.jupiter.api.Test;
44
import org.utplsql.api.compatibility.OptionalFeatures;
5+
import org.utplsql.api.reporter.CoreReporters;
6+
7+
import java.nio.file.Paths;
58

69
import static org.junit.jupiter.api.Assertions.assertEquals;
710

811
/**
912
* System tests for run command.
1013
*/
11-
public class RunCommandIT {
14+
public class RunCommandIT extends AbstractFileOutputTest {
1215

1316
@Test
1417
public void run_Default() throws Exception {
@@ -26,6 +29,28 @@ public void run_Default() throws Exception {
2629
else
2730
assertEquals(0, result);
2831
}
32+
@Test
33+
public void run_MultipleReporters() throws Exception {
34+
35+
String outputFileName = "output_" + System.currentTimeMillis() + ".xml";
36+
addTempPath(Paths.get(outputFileName));
37+
38+
RunCommand runCmd = RunCommandTestHelper.createRunCommand(RunCommandTestHelper.getConnectionString(),
39+
"-f=ut_documentation_reporter",
40+
"-s",
41+
"-f=" + CoreReporters.UT_SONAR_TEST_REPORTER.name(),
42+
"-o=" + outputFileName,
43+
"-c",
44+
"--failure-exit-code=2");
45+
46+
int result = runCmd.run();
47+
48+
// Only expect failure-exit-code to work on several framework versions
49+
if (OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(runCmd.getDatabaseVersion()))
50+
assertEquals(2, result);
51+
else
52+
assertEquals(0, result);
53+
}
2954

3055

3156
}

0 commit comments

Comments
 (0)