Skip to content

Bugfix/class not found jaxb #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.utplsql</groupId>
<artifactId>cli</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>cli</name>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>org.utplsql</groupId>
<artifactId>java-api</artifactId>
<version>3.1.0</version>
<version>3.1.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -61,6 +61,11 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/utplsql/cli/ConnectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/utplsql/cli/ReporterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ public void startReporterGatherers(ExecutorService executorService, final Connec
public List<ReporterOptions> getReporterOptionsList() {
return reporterOptionsList;
}

public int getNumberOfReporters() { return reporterOptionsList.size(); };
}
4 changes: 3 additions & 1 deletion src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public int run() throws Exception {

RunCommandChecker.checkOracleJDBCExists();

final ConnectionInfo ci = getConnectionInfo();

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

final ConnectionInfo ci = getConnectionInfo();
ci.setMaxConnections(getReporterManager().getNumberOfReporters()+1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why +1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need a separate connection for TestRunner to start. The Reporters are all in their own threads and due to concurrency it's always preferrable to have a separate connection for each thread.
Main thread: TestRunner
Thread 1: Reporter 1
Thread 2: Reporter 2

etc.


// Do the reporters initialization, so we can use the id to run and gather results.
try (Connection conn = ci.getConnection()) {

Expand Down
42 changes: 42 additions & 0 deletions src/test/java/org/utplsql/cli/AbstractFileOutputTest.java
Original file line number Diff line number Diff line change
@@ -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<Path> 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();
}
}
}
35 changes: 4 additions & 31 deletions src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
*
* @author pesse
*/
public class RunCommandCoverageReporterIT {
public class RunCommandCoverageReporterIT extends AbstractFileOutputTest {

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>");

private Set<Path> tempPaths;

private void addTempPath(Path path) {
tempPaths.add(path);
}

private String getTempCoverageFileName(int counter) {

Expand All @@ -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)
Expand Down Expand Up @@ -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 {

Expand All @@ -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"));
Expand Down Expand Up @@ -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("<script src='" + coverageAssetsPath.toString() + "/application.js' type='text/javascript'>"));

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

@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();
}
}
}
27 changes: 26 additions & 1 deletion src/test/java/org/utplsql/cli/RunCommandIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import org.junit.jupiter.api.Test;
import org.utplsql.api.compatibility.OptionalFeatures;
import org.utplsql.api.reporter.CoreReporters;

import java.nio.file.Paths;

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

/**
* System tests for run command.
*/
public class RunCommandIT {
public class RunCommandIT extends AbstractFileOutputTest {

@Test
public void run_Default() throws Exception {
Expand All @@ -26,6 +29,28 @@ public void run_Default() throws Exception {
else
assertEquals(0, result);
}
@Test
public void run_MultipleReporters() throws Exception {

String outputFileName = "output_" + System.currentTimeMillis() + ".xml";
addTempPath(Paths.get(outputFileName));

RunCommand runCmd = RunCommandTestHelper.createRunCommand(RunCommandTestHelper.getConnectionString(),
"-f=ut_documentation_reporter",
"-s",
"-f=" + CoreReporters.UT_SONAR_TEST_REPORTER.name(),
"-o=" + outputFileName,
"-c",
"--failure-exit-code=2");

int result = runCmd.run();

// Only expect failure-exit-code to work on several framework versions
if (OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(runCmd.getDatabaseVersion()))
assertEquals(2, result);
else
assertEquals(0, result);
}


}