Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Quick and simple try to make cli compatible with 3.1.0
  • Loading branch information
pesse committed Mar 11, 2018
commit 9d142e015a77252f8c805f3a0ecdef0b30fad34f
16 changes: 14 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.0.5-SNAPSHOT</version>
<version>3.1.0-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.0.5-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand All @@ -31,6 +31,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>orai18n</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/utplsql/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void main(String[] args) {
LocaleInitializer.initLocale();

JCommander jc = new JCommander();
jc.setProgramName("utplsql");
// jc.addCommand(HELP_CMD, new HelpCommand());
RunCommand runCmd = new RunCommand();
jc.addCommand(RUN_CMD, runCmd);
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import org.utplsql.api.*;
import org.utplsql.api.FileMapperOptions;
import org.utplsql.api.KeyValuePair;
import org.utplsql.api.TestRunner;
import org.utplsql.api.Version;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.exception.SomeTestsFailedException;
import org.utplsql.api.reporter.CoreReporters;
import org.utplsql.api.reporter.CoverageHTMLReporter;
import org.utplsql.api.reporter.Reporter;
import org.utplsql.api.reporter.ReporterFactory;
Expand Down Expand Up @@ -100,6 +104,7 @@ public class RunCommand {


private CompatibilityProxy compatibilityProxy;
private ReporterFactory reporterFactory;

public ConnectionInfo getConnectionInfo() {
return connectionInfoList.get(0);
Expand Down Expand Up @@ -154,6 +159,7 @@ public int run() throws Exception {

// First of all do a compatibility check and fail-fast
compatibilityProxy = checkFrameworkCompatibility(conn);
reporterFactory = ReporterFactory.createDefault(compatibilityProxy);

reporterList = initReporters(conn, reporterOptionsList);

Expand Down Expand Up @@ -218,15 +224,15 @@ private List<Reporter> initReporters( Connection conn, List<ReporterOptions> rep
final List<Reporter> reporterList = new ArrayList<>();

for (ReporterOptions ro : reporterOptionsList) {
Reporter reporter = ReporterFactory.createReporter(ro.getReporterName());
Reporter reporter = reporterFactory.createReporter(ro.getReporterName());

// Quick-hack for CoverageHTML Reporter
if ( reporter instanceof CoverageHTMLReporter && ro.outputToFile() ) {
((CoverageHTMLReporter)reporter).setAssetsPath(ro.getOutputFileName()+"_assets/");
CoverageHTMLReporter.writeReportAssetsTo(Paths.get(ro.getOutputFileName()+"_assets/"));
}

reporter.init(conn);
reporter.init(conn, compatibilityProxy, reporterFactory);
ro.setReporterObj(reporter);
reporterList.add(reporter);
}
Expand Down Expand Up @@ -259,7 +265,7 @@ private void startReporterGatherers(List<ReporterOptions> reporterOptionsList, E
printStreams.add(fileOutStream);
}

new OutputBuffer(ro.getReporterObj()).printAvailable(conn, printStreams);
ro.getReporterObj().getOutputBuffer().printAvailable(conn, printStreams);
} catch (SQLException | FileNotFoundException e) {
System.out.println(e.getMessage());
returnCode[0] = Cli.DEFAULT_ERROR_CODE;
Expand Down Expand Up @@ -310,7 +316,7 @@ public List<ReporterOptions> getReporterOptionsList() {

// If no reporter parameters were passed, use default reporter.
if (reporterOptionsList.isEmpty()) {
reporterOptionsList.add(new ReporterOptions(CustomTypes.UT_DOCUMENTATION_REPORTER));
reporterOptionsList.add(new ReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name()));
}

return reporterOptionsList;
Expand Down
13 changes: 7 additions & 6 deletions src/test/java/org/utplsql/cli/RunCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.api.Test;
import org.utplsql.api.CustomTypes;
import org.utplsql.api.reporter.CoreReporters;

import java.util.List;

Expand All @@ -19,7 +20,7 @@ public void reporterOptions_Default() {
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();

ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertNull(reporterOptions1.getOutputFileName());
assertFalse(reporterOptions1.outputToFile());
assertTrue(reporterOptions1.outputToScreen());
Expand All @@ -32,7 +33,7 @@ public void reporterOptions_OneReporter() {
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();

ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(reporterOptions1.getOutputFileName(), "output.txt");
assertTrue(reporterOptions1.outputToFile());
assertFalse(reporterOptions1.outputToScreen());
Expand All @@ -45,7 +46,7 @@ public void reporterOptions_OneReporterForceScreen() {
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();

ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(reporterOptions1.getOutputFileName(), "output.txt");
assertTrue(reporterOptions1.outputToFile());
assertTrue(reporterOptions1.outputToScreen());
Expand All @@ -58,7 +59,7 @@ public void reporterOptions_OneReporterForceScreenInverse() {
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();

ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(reporterOptions1.getOutputFileName(), "output.txt");
assertTrue(reporterOptions1.outputToFile());
assertTrue(reporterOptions1.outputToScreen());
Expand All @@ -73,13 +74,13 @@ public void reporterOptions_TwoReporters() {
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();

ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CustomTypes.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER, reporterOptions1.getReporterName());
assertNull(reporterOptions1.getOutputFileName());
assertFalse(reporterOptions1.outputToFile());
assertTrue(reporterOptions1.outputToScreen());

ReporterOptions reporterOptions2 = reporterOptionsList.get(1);
assertEquals(CustomTypes.UT_COVERAGE_HTML_REPORTER, reporterOptions2.getReporterName());
assertEquals(CoreReporters.UT_COVERAGE_HTML_REPORTER, reporterOptions2.getReporterName());
assertEquals(reporterOptions2.getOutputFileName(), "coverage.html");
assertTrue(reporterOptions2.outputToFile());
assertTrue(reporterOptions2.outputToScreen());
Expand Down