From d574541a0251440e360e434ec6e1693b2e0912db Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Mon, 10 Oct 2016 23:09:57 +0200 Subject: [PATCH] added proper shutdown of the executor service; added completion message; renamed execution blocking component back to scenario player; updated changelog --- CHANGELOG.md | 5 +++++ .../java/website/automate/jwebrobot/JWebRobot.java | 4 ++-- .../jwebrobot/executor/DefaultScenarioExecutor.java | 10 +++++----- .../automate/jwebrobot/player/ConsoleListener.java | 10 +++++----- .../{ExecutionStagnator.java => ScenarioPlayer.java} | 4 ++-- .../executor/DefaultScenarioExecutorTest.java | 6 +++--- 6 files changed, 22 insertions(+), 17 deletions(-) rename src/main/java/website/automate/jwebrobot/player/{ExecutionStagnator.java => ScenarioPlayer.java} (88%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae7ff3d..ea663a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed +- bridged java util logging to unify logging output + +### Added +- introduced mode option and stepwise/pausable interactive playback mode ## [1.5.0] ### Added diff --git a/src/main/java/website/automate/jwebrobot/JWebRobot.java b/src/main/java/website/automate/jwebrobot/JWebRobot.java index 947a7ce..20285d1 100644 --- a/src/main/java/website/automate/jwebrobot/JWebRobot.java +++ b/src/main/java/website/automate/jwebrobot/JWebRobot.java @@ -15,7 +15,7 @@ import website.automate.jwebrobot.loader.ScenarioFile; import website.automate.jwebrobot.loader.ScenarioLoader; import website.automate.jwebrobot.player.ConsoleListener; -import website.automate.jwebrobot.player.ExecutionStagnator; +import website.automate.jwebrobot.player.ScenarioPlayer; public class JWebRobot { @@ -47,7 +47,7 @@ public static void main(String[] args) { if(configurationProperties.isInteractive()){ consoleListener = ConsoleListener.getInstance(); - consoleListener.getPlayer().executeCommand(ExecutionStagnator.STOP); + consoleListener.getPlayer().executeCommand(ScenarioPlayer.STOP); } JWebRobot jWebRobot = injector.getInstance(JWebRobot.class); diff --git a/src/main/java/website/automate/jwebrobot/executor/DefaultScenarioExecutor.java b/src/main/java/website/automate/jwebrobot/executor/DefaultScenarioExecutor.java index 182665a..556761a 100644 --- a/src/main/java/website/automate/jwebrobot/executor/DefaultScenarioExecutor.java +++ b/src/main/java/website/automate/jwebrobot/executor/DefaultScenarioExecutor.java @@ -13,7 +13,7 @@ import website.automate.jwebrobot.expression.ConditionalExpressionEvaluator; import website.automate.jwebrobot.listener.ExecutionEventListeners; import website.automate.jwebrobot.mapper.action.AbstractActionMapper; -import website.automate.jwebrobot.player.ExecutionStagnator; +import website.automate.jwebrobot.player.ScenarioPlayer; import website.automate.jwebrobot.validator.ContextValidators; import website.automate.waml.io.model.Scenario; import website.automate.waml.io.model.action.Action; @@ -34,7 +34,7 @@ public class DefaultScenarioExecutor implements ScenarioExecutor { private final ActionPreprocessor actionPreprocessor; private final AbstractActionMapper abstractActionMapper; private final ScenarioPatternFilter scenarioPatternFilter; - private final ExecutionStagnator executionStagnator; + private final ScenarioPlayer scenarioPlayer; @Inject public DefaultScenarioExecutor( @@ -47,7 +47,7 @@ public DefaultScenarioExecutor( ActionPreprocessor actionPreprocessor, AbstractActionMapper abstractActionMapper, ScenarioPatternFilter scenarioPatternFilter, - ExecutionStagnator scenarioPlayer + ScenarioPlayer scenarioPlayer ) { this.webDriverProvider = webDriverProvider; this.actionExecutorFactory = actionExecutorFactory; @@ -58,7 +58,7 @@ public DefaultScenarioExecutor( this.actionPreprocessor = actionPreprocessor; this.abstractActionMapper = abstractActionMapper; this.scenarioPatternFilter =scenarioPatternFilter; - this.executionStagnator = scenarioPlayer; + this.scenarioPlayer = scenarioPlayer; } @Override @@ -121,7 +121,7 @@ public void runScenario(Scenario scenario, ScenarioExecutionContext scenarioExec } for (Action action : scenario.getSteps()) { - executionStagnator.pauseIfRequired(); + scenarioPlayer.pauseIfRequired(); ActionExecutor actionExecutor = actionExecutorFactory.getInstance(action.getClass()); diff --git a/src/main/java/website/automate/jwebrobot/player/ConsoleListener.java b/src/main/java/website/automate/jwebrobot/player/ConsoleListener.java index 748e254..40abedd 100644 --- a/src/main/java/website/automate/jwebrobot/player/ConsoleListener.java +++ b/src/main/java/website/automate/jwebrobot/player/ConsoleListener.java @@ -24,10 +24,10 @@ public class ConsoleListener implements Runnable { private static final String AVAILABLE_COMMANDS = "Next(N|n), Continue(C|c), Stop(S|s):"; - private ExecutionStagnator player; + private ScenarioPlayer player; @Inject - public ConsoleListener(ExecutionStagnator player) { + public ConsoleListener(ScenarioPlayer player) { super(); this.player = player; } @@ -62,7 +62,7 @@ private void printAvailableCommands(){ } private void printSuccessMessage(){ - System.out.println("Execution completed. Enter any key to exit..."); + System.out.println("Execution completed. Enter any key to exit:"); } public static ConsoleListener getInstance(){ @@ -78,11 +78,11 @@ public static ConsoleListener getInstance(){ return INSTANCE; } - public ExecutionStagnator getPlayer() { + public ScenarioPlayer getPlayer() { return player; } - public void setPlayer(ExecutionStagnator player) { + public void setPlayer(ScenarioPlayer player) { this.player = player; } diff --git a/src/main/java/website/automate/jwebrobot/player/ExecutionStagnator.java b/src/main/java/website/automate/jwebrobot/player/ScenarioPlayer.java similarity index 88% rename from src/main/java/website/automate/jwebrobot/player/ExecutionStagnator.java rename to src/main/java/website/automate/jwebrobot/player/ScenarioPlayer.java index c3f189c..421304c 100644 --- a/src/main/java/website/automate/jwebrobot/player/ExecutionStagnator.java +++ b/src/main/java/website/automate/jwebrobot/player/ScenarioPlayer.java @@ -7,7 +7,7 @@ import com.google.inject.Singleton; @Singleton -public class ExecutionStagnator { +public class ScenarioPlayer { public static final char NEXT = 'n'; public static final char CONTINUE = 'c'; @@ -43,6 +43,6 @@ public char getCommand() { } public boolean isValid(char command){ - return VALID_COMMANDS.contains(command); + return VALID_COMMANDS.contains(Character.toLowerCase(command)); } } diff --git a/src/test/java/website/automate/jwebrobot/executor/DefaultScenarioExecutorTest.java b/src/test/java/website/automate/jwebrobot/executor/DefaultScenarioExecutorTest.java index 18d6e06..f45e118 100644 --- a/src/test/java/website/automate/jwebrobot/executor/DefaultScenarioExecutorTest.java +++ b/src/test/java/website/automate/jwebrobot/executor/DefaultScenarioExecutorTest.java @@ -19,7 +19,7 @@ import website.automate.jwebrobot.listener.ExecutionEventListeners; import website.automate.jwebrobot.mapper.action.AbstractActionMapper; import website.automate.jwebrobot.mapper.action.ActionMapperProvider; -import website.automate.jwebrobot.player.ExecutionStagnator; +import website.automate.jwebrobot.player.ScenarioPlayer; import website.automate.jwebrobot.validator.ContextValidators; import website.automate.waml.io.model.Scenario; @@ -40,7 +40,7 @@ public class DefaultScenarioExecutorTest { @Mock private ScenarioExecutionContext context; @Mock private AbstractActionMapper abstractActionMapper; @Mock private ScenarioPatternFilter scenarioPatternFilter; - @Mock private ExecutionStagnator executionStagnator; + @Mock private ScenarioPlayer scenarioPlayer; private DefaultScenarioExecutor scenarioExecutor; @@ -50,7 +50,7 @@ public void init(){ validator, conditionalExpressionEvaluator, scenarioPreprocessor, actionPreprocessor, abstractActionMapper, scenarioPatternFilter, - executionStagnator); + scenarioPlayer); when(scenarioPreprocessor.preprocess(scenario, context)).thenReturn(preprocessedScenario); }