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
Show all changes
33 commits
Select commit Hold shift + click to select a range
6717057
Failing test to catch and reproduce #143
pesse Jun 4, 2019
038981f
Merge branch 'develop' into feature/new_cli_library
pesse Jun 7, 2019
b21f651
Unit-Test to simulate passing all parameters that should be known
pesse Jun 7, 2019
ce849fc
Initial implementation of Picocli usage
pesse Jun 11, 2019
5520562
Some more tests around FileMapping
pesse Jun 12, 2019
f9c4cf7
New RunAction which does the logic based on RunCommandConfig
pesse Jun 12, 2019
d8cbce2
RunAction tested and functional so far
pesse Jun 12, 2019
3b5e168
Include RunAction into RunCommand
pesse Jun 12, 2019
60997d7
New entry point for Picocli
pesse Jun 12, 2019
d13ae5b
Extract functionality to interface
pesse Jun 12, 2019
5e86b01
Adapt tests to IRunCommand and implement necessary functionality
pesse Jun 12, 2019
00f3f5f
Change VersionCommand to Picocli
pesse Jun 12, 2019
2ce4e91
Change ReportersCommand to Picocli
pesse Jun 13, 2019
b88d5c5
Fix arity for mapping options and prevent NPE
pesse Jun 13, 2019
c80dc8c
Refactor RunCommandTest to cover new approach
pesse Jun 13, 2019
8eec2cb
Implement rules for printToScreen Reporters: Only one can go to screen
pesse Jun 13, 2019
ded39d3
Implemented new Picocli help
pesse Jun 13, 2019
6922e52
Removed some now unnecessary stuff
pesse Jun 13, 2019
5aa4c1d
We don't need the old RunCommand anymore, time to get rid of it
pesse Jun 13, 2019
60fcfaf
Improve help and help-tests
pesse Jun 13, 2019
a3608b5
Refactor: Remove unnecessary logic
pesse Jun 13, 2019
09bf357
Refactor: extract ReporterConfig -> ReporterOption conversion
pesse Jun 13, 2019
1b65b51
Refactor: getCommand() no longer needed
pesse Jun 13, 2019
77fd752
Refactor: Include only left check-functionality
pesse Jun 13, 2019
e443e3c
Refactor: Cleanup ReporterManager a bit
pesse Jun 13, 2019
0bdca7d
Get rid of JCommander dependency
pesse Jun 13, 2019
ae0e9c4
Move ConnectionString description to main Utplsql-Command
pesse Jun 18, 2019
f47c0de
Fix Typo
pesse Jun 18, 2019
bb18ea1
Some Refactorings and make things final
pesse Jun 18, 2019
1a984ff
Merge branch 'develop' into feature/new_cli_library
pesse Jun 18, 2019
81e0953
Reformatting
pesse Jun 18, 2019
a8acbb9
Add `-h` option to all commands and cover it with tests
pesse Jun 18, 2019
10bef7b
Adjust documentation to reflect parameter changes
pesse Jun 18, 2019
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
Prev Previous commit
Next Next commit
RunAction tested and functional so far
  • Loading branch information
pesse committed Jun 12, 2019
commit d8cbce21e825b555fc847f44f47c196112cdf0a4
21 changes: 18 additions & 3 deletions src/main/java/org/utplsql/cli/ReporterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;

Expand All @@ -23,10 +24,16 @@ class ReporterManager {
private ExecutorService executorService;

ReporterManager(List<String> reporterParams ) {
initReporterOptionsList(reporterParams);
parseReporterOptionsList(reporterParams);
initReporterOptionsList();
}

private void initReporterOptionsList( List<String> reporterParams ) {
ReporterManager( ReporterOptions[] reporterOptions ) {
this.reporterOptionsList = Arrays.asList(reporterOptions);
initReporterOptionsList();
}

private void parseReporterOptionsList( List<String> reporterParams ) {
reporterOptionsList = new ArrayList<>();
ReporterOptions reporterOptions = null;

Expand All @@ -44,13 +51,21 @@ private void initReporterOptionsList( List<String> reporterParams ) {
reporterOptions.forceOutputToScreen(true);
}
}
}

private void initReporterOptionsList( ) {

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

private ReporterOptions getDefaultReporterOption() {
return new ReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name());
}

private void abortGathering(Throwable e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

haveGatherErrorsOccured and getGatherErrors (below) are not used and haveGatherErrorsOccured contains typo

addGatherError(e);
executorService.shutdownNow();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I realized this might be an issue. We get the executorService from the outside but we shut it down here. I'm concerned if the caller is ok with its executorService been shut down.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's actually the purpose: If one Reporter Consumption fails, it should abort all the other Reporter threads.
But that's one of the things I want to do differently/more clear

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets abort tasks then, not the excutor

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, will make that more clear in a restructured version

Expand Down
22 changes: 19 additions & 3 deletions src/main/java/org/utplsql/cli/RunAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.utplsql.api.reporter.Reporter;
import org.utplsql.api.reporter.ReporterFactory;
import org.utplsql.cli.config.FileMapperConfig;
import org.utplsql.cli.config.ReporterConfig;
import org.utplsql.cli.config.RunCommandConfig;
import org.utplsql.cli.exception.DatabaseConnectionFailed;
import org.utplsql.cli.exception.ReporterTimeoutException;
Expand Down Expand Up @@ -54,6 +55,10 @@ void init() {
LoggerConfiguration.configure(config.getLogConfigLevel());
}

public RunCommandConfig getConfig() {
return config;
}

public int doRun() throws OracleCreateStatmenetStuckException {
init();
outputMainInformation();
Expand Down Expand Up @@ -270,9 +275,20 @@ private CompatibilityProxy checkFrameworkCompatibility(Connection conn) throws S
}

private ReporterManager getReporterManager() {
ArrayList<String> reporterParams = new ArrayList<>();
if ( reporterManager == null )
reporterManager = new ReporterManager(reporterParams);
if ( reporterManager == null ) {

ReporterConfig[] reporterConfigs = config.getReporters();
if ( reporterConfigs != null ) {
ReporterOptions[] options = new ReporterOptions[reporterConfigs.length];
for (int i = 0; i<reporterConfigs.length; i++ ) {
options[i] = new ReporterOptions(
reporterConfigs[i].getName(),
reporterConfigs[i].getOutput(),
reporterConfigs[i].isScreen());
}
reporterManager = new ReporterManager(options);
}
}

return reporterManager;
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/utplsql/cli/RunActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void reporterOptions_TwoReporters() throws Exception {
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());
assertNull(reporterOptions1.getOutputFileName());
assertFalse(reporterOptions1.outputToFile());
assertTrue(reporterOptions1.outputToScreen());
assertFalse(reporterOptions1.outputToScreen());

ReporterOptions reporterOptions2 = reporterOptionsList.get(1);
assertEquals(CoreReporters.UT_COVERAGE_HTML_REPORTER.name(), reporterOptions2.getReporterName());
Expand All @@ -90,13 +90,13 @@ void reporterOptions_TwoReporters() throws Exception {
assertTrue(reporterOptions2.outputToScreen());
}

/*@Test
@Test
void connectionString_asSysdba() throws Exception {
RunAction runCmd = TestHelper.createRunAction("sys as sysdba/mypass@connectstring/service");

assertEquals("sys as sysdba/mypass@connectstring/service",
runCmd.getConnectionInfo().getConnectionString());
}*/
runCmd.getConfig().getConnectString());
}

@Test
void randomOrder_default() throws Exception {
Expand Down