[jbehave-scm] [975] trunk: [Liz] All the before/after scenario stuff now works.
Title: [975] trunk: [Liz] All the before/after scenario stuff now works. Revision 975 Author sirenian Date 2008-10-16 05:10:08 -0500 (Thu, 16 Oct 2008) Log Message [Liz] All the before/after scenario stuff now works. NB: Ant build is broken and probably has been for some versions; SpringContainerBehaviour also not working due to library dependencies. Dan and I are about to Ivy this build so it should be fixed within a day or so. Modified Paths trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanTakeTurns.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/TheGridStartsEmpty.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/ThreeInARowWins.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/LolCatzSteps.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateSteps.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PendingStep.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/StepsConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreator.java Added Paths trunk/.hgignore trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/BeforeAndAfterSteps.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/util/ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/util/NoughtsAndCrossesScenario.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/util/OAndXUniverse.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/annotations/ trunk/jbehave-core/src/java/org/jbehave/Ensure.java trunk/jbehave-core/src/java/org/jbehave/scenario/annotations/AfterScenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/annotations/AfterSuccessfulScenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/annotations/AfterUnsuccessfulScenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/annotations/BeforeScenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/errors/BeforeOrAfterScenarioException.java trunk/lib/build/hamcrest-all-1.1.jar trunk/lib/production/picocontainer-2.6.jar trunk/lib/production/picocontainer-script-core-2.0.jar trunk/lib/production/spring-2.5.5.jar Property Changed trunk/ Diff Property changes: trunk Name: svn:ignore - spike bin jbehave.iml classes delete_me dist workspace jbehave.iws build target-eclipse target .classpath .project working + spike bin jbehave.iml classes delete_me dist workspace jbehave.iws build target-eclipse target .classpath .project working .hg Added: trunk/.hgignore (0 => 975) --- trunk/.hgignore (rev 0) +++ trunk/.hgignore 2008-10-16 10:10:08 UTC (rev 975) @@ -0,0 +1,5 @@ +syntax: regexp +^bin +^working +.DS_Store +.svn Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java (974 => 975) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java 2008-10-07 20:51:37 UTC (rev 974) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java 2008-10-16 10:10:08 UTC (rev 975) @@ -7,7 +7,9 @@ import org.jbehave.scenario.parser.ClasspathScenarioDefiner; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; +import com.lunivore.noughtsandcrosses.steps.BeforeAndAfterSteps; import com.lunivore.noughtsandcrosses.steps.LolCatzSteps; +import com.lunivore.noughtsandcrosses.util.OAndXUniverse; /** * Checks that we can support scenarios written in other languages, @@ -20,6 +22,10 @@ } public PlayersCanHazTurns(final ClassLoader classLoader) { + this(classLoader, new OAndXUniverse()); +} + +public PlayersCanHazTurns(final ClassLoader classLoader, OAndXUniverse universe) { super(new MostUsefulConfiguration() { public KeyWords keywords() { return new KeyWords("I can haz", "Gief", "Wen", "Den", "And"); @@ -28,7 +34,7 @@ return new ClasspathScenarioDefiner(new UnderscoredCamelCaseResolver(), new PatternScenarioParser(this), classLoader); } -}, new LolCatzSteps()); +
[jbehave-scm] [916] trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java: [Liz] runUsingSteps -> run
Title: [916] trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java: [Liz] runUsingSteps -> run Revision 916 Author sirenian Date 2008-09-02 02:48:16 -0500 (Tue, 02 Sep 2008) Log Message [Liz] runUsingSteps -> run Modified Paths trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java Diff Modified: trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java (915 => 916) --- trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java 2008-09-01 23:40:14 UTC (rev 915) +++ trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java 2008-09-02 07:48:16 UTC (rev 916) @@ -9,7 +9,7 @@ * scenario, eg: "ICanLogin". * * The Scenario should be in a matching text file in the same place, - * eg "i_can_login". + * eg: "i_can_login" * * Write some steps in your scenario, starting each new step with * Given, When, Then or And. To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [907] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Might help if Scenario told people how to start.
Title: [907] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Might help if Scenario told people how to start. Revision 907 Author sirenian Date 2008-08-30 02:56:19 -0500 (Sat, 30 Aug 2008) Log Message [Liz] Might help if Scenario told people how to start. Modified Paths trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java Diff Modified: trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java (906 => 907) --- trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java 2008-08-30 07:53:24 UTC (rev 906) +++ trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java 2008-08-30 07:56:19 UTC (rev 907) @@ -5,13 +5,16 @@ import org.junit.Test; /** - * - * A scenario is a collection of candidate steps that need to be run using a scenario runner. - * - * Users extend Scenario by providing candidate steps appropriate for the behaviour + * Extend this class to run your scenario. Call the class after your + * scenario, eg: "ICanLogin". * - * @author Elizabeth Keogh - * @author Mauro Talevi + * The Scenario shoudl be in a matching text file in the same place, + * eg: "i_can_login" + * + * Write some steps in your scenario, starting each new step with + * Given, When, Then or And. + * + * Then look at the Steps class. */ public abstract class Scenario { Modified: trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java (906 => 907) --- trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java 2008-08-30 07:53:24 UTC (rev 906) +++ trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java 2008-08-30 07:56:19 UTC (rev 907) @@ -32,7 +32,7 @@ * * When I log in as Liz with password: Pa55word * - * When the step is perfomed, the two parameters in the scenario definition + * When the step is perfomed, the parameters in the scenario definition * will be passed to the class, so in this case the effect will be * * mySteps.logIn("Liz", "Pa55word"); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [906] trunk/jbehave-core/src/java/org/jbehave: [Liz] Some more javadocs, started examples for ParameterConverters
Title: [906] trunk/jbehave-core/src/java/org/jbehave: [Liz] Some more javadocs, started examples for ParameterConverters Revision 906 Author sirenian Date 2008-08-30 02:53:24 -0500 (Sat, 30 Aug 2008) Log Message [Liz] Some more javadocs, started examples for ParameterConverters Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/java/org/jbehave/Configuration.java trunk/jbehave-core/src/java/org/jbehave/scenario/MostUsefulConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/PropertyBasedConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/ParameterConverters.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java Added Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/ParameterConvertersBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/errors/PendingErrorStrategy.java Removed Paths trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PendingStepStrategy.java Diff Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java (905 => 906) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java 2008-08-29 16:59:28 UTC (rev 905) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java 2008-08-30 07:53:24 UTC (rev 906) @@ -6,9 +6,9 @@ import org.jbehave.scenario.definition.ScenarioGivenWhenThenAnd; import org.jbehave.scenario.errors.ErrorStrategy; +import org.jbehave.scenario.errors.PendingErrorStrategy; import org.jbehave.scenario.reporters.PassSilentlyDecorator; import org.jbehave.scenario.reporters.PrintStreamScenarioReporter; -import org.jbehave.scenario.steps.PendingStepStrategy; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -41,13 +41,13 @@ @Test public void shouldUsePassingPendingStepStrategyByDefault() { System.clearProperty(PropertyBasedConfiguration.FAIL_ON_PENDING); -ensureThat(new PropertyBasedConfiguration().forPendingSteps(), is(PendingStepStrategy.PASSING)); +ensureThat(new PropertyBasedConfiguration().forPendingSteps(), is(PendingErrorStrategy.PASSING)); } @Test public void shouldUseFailingPendingStepStrategyWhenConfiguredToDoSo() { System.setProperty(PropertyBasedConfiguration.FAIL_ON_PENDING, "true"); -ensureThat(new PropertyBasedConfiguration().forPendingSteps(), is(PendingStepStrategy.FAILING)); +ensureThat(new PropertyBasedConfiguration().forPendingSteps(), is(PendingErrorStrategy.FAILING)); } @Test Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (905 => 906) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-29 16:59:28 UTC (rev 905) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-30 07:53:24 UTC (rev 906) @@ -10,9 +10,9 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.definition.KeyWords; import org.jbehave.scenario.errors.ErrorStrategy; +import org.jbehave.scenario.errors.PendingErrorStrategy; import org.jbehave.scenario.parser.ScenarioDefiner; import org.jbehave.scenario.reporters.ScenarioReporter; -import org.jbehave.scenario.steps.PendingStepStrategy; import org.jbehave.scenario.steps.StepCreator; import org.jbehave.scenario.steps.Steps; import org.junit.Test; @@ -58,7 +58,7 @@ public ErrorStrategy forHandlingErrors() { return null; } -public PendingStepStrategy forPendingSteps() { return null; } +public PendingErrorStrategy forPendingSteps() { return null; } public ScenarioReporter forReportingScenarios() { return null; } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java (905 => 906) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2008-08-29 16:59:28 UTC (rev 905) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2008-08-30 07:53:24 UTC (rev 906) @@ -12,9 +12,9 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.errors.ErrorStrategy; import org.jbehave.scenario.errors.ErrorStrategyInWhichWeTrustTheReporter; +import org.jbehave.scenario.errors.PendingErrorStrategy; import org.jbehave.scenario.reporters.ScenarioReporter; import org.jbehave.scenario.steps.CandidateStep; -import org.jbehave.scenario.steps.PendingStepStrategy; import org.jbehave.scenario.steps.Step; import org.jbehave.scenario.steps.StepCreator; import org.jbehave.scenario.steps.StepResul
[jbehave-scm] [900] trunk/jbehave-core/src/java/org/jbehave: [Liz] Some tidy up, internationalisation put back in again - lolcatz stories work...
Title: [900] trunk/jbehave-core/src/java/org/jbehave: [Liz] Some tidy up, internationalisation put back in again - lolcatz stories work... Revision 900 Author sirenian Date 2008-08-28 08:01:44 -0500 (Thu, 28 Aug 2008) Log Message [Liz] Some tidy up, internationalisation put back in again - lolcatz stories work... Modified Paths trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/ICanToggleACell.java trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/TheGridStartsEmpty.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/converters/TraderConverter.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StockSteps.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/TraderSellsAllStocks.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternScenarioParserBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioFileLoaderBehaviour.java trunk/jbehave-core/src/java/org/jbehave/Configuration.java trunk/jbehave-core/src/java/org/jbehave/scenario/PropertyBasedConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/PatternScenarioParser.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java Added Paths trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_haz_turns trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/LolCatzSteps.java trunk/jbehave-core/src/java/org/jbehave/scenario/MostUsefulConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java trunk/jbehave-core/src/java/org/jbehave/scenario/definition/ScenarioGivenWhenThenAnd.java Diff Modified: trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/ICanToggleACell.java (899 => 900) --- trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/ICanToggleACell.java 2008-08-26 13:38:55 UTC (rev 899) +++ trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/ICanToggleACell.java 2008-08-28 13:01:44 UTC (rev 900) @@ -19,7 +19,7 @@ @Override public ScenarioFileLoader forDefiningScenarios() { return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(), classLoader, -new PatternScenarioParser()); +new PatternScenarioParser(this)); } }, new GridSteps()); } Modified: trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/TheGridStartsEmpty.java (899 => 900) --- trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/TheGridStartsEmpty.java 2008-08-26 13:38:55 UTC (rev 899) +++ trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/TheGridStartsEmpty.java 2008-08-28 13:01:44 UTC (rev 900) @@ -19,7 +19,7 @@ @Override public ScenarioFileLoader forDefiningScenarios() { return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(), classLoader, -new PatternScenarioParser()); +new PatternScenarioParser(this)); } }, new GridSteps()); } Added: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java (0 => 900) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java (rev 0) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanHazTurns.java 2008-08-28 13:01:44 UTC (rev 900) @@ -0,0 +1,22 @@ +package com.lunivore.noughtsandcrosses; + +import org.jbehave.scenario.MostUsefulConfiguration; +import org.jbehave.scenario.Scenario; +import org.jbehave.scenario.definition.KeyWords; + +import com.lunivore.noughtsandcrosses.steps.LolCatzSteps; + +/** + * Checks that we can support scenarios written in other languages, + * eg: lolcatz + */ +public class PlayersCanHazTurns extends Scenario { + +public PlayersCanHazTurns() { +super(new MostUsefulConfiguration() { +public KeyWords keywords() { +return new KeyWords("I can haz", "Gief", "Wen", "Den", "And"); +} +}, new LolCatzSteps()); +} +} Added: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_haz
[jbehave-scm] [888] trunk/jbehave-core/src/java/org/jbehave: [Liz] Tidying up before the next bit; added a couple of examples and moved some files around
Title: [888] trunk/jbehave-core/src/java/org/jbehave: [Liz] Tidying up before the next bit; added a couple of examples and moved some files around Revision 888 Author sirenian Date 2008-08-24 09:07:13 -0500 (Sun, 24 Aug 2008) Log Message [Liz] Tidying up before the next bit; added a couple of examples and moved some files around Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PrefixCapturingPatternBuilderBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioClassNameFinderBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioFileLoaderBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PassSilentlyDecoratorBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepResultBehaviour.java trunk/jbehave-core/src/java/org/jbehave/Configuration.java trunk/jbehave-core/src/java/org/jbehave/scenario/PropertyBasedConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioClassNameFinder.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java trunk/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java trunk/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/StepResult.java Added Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/errors/ErrorStrategyBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/errors/ErrorStrategyInWhichWeTrustTheReporterBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/errors/InvalidScenarioClassPathException.java trunk/jbehave-core/src/java/org/jbehave/scenario/errors/InvalidScenarioResourceException.java trunk/jbehave-core/src/java/org/jbehave/scenario/errors/ScenarioNotFoundException.java trunk/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java Removed Paths trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioReporter.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/InvalidScenarioClassPathException.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/InvalidScenarioResourceException.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioNotFoundException.java Diff Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (887 => 888) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-23 15:06:43 UTC (rev 887) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-24 14:07:13 UTC (rev 888) @@ -10,6 +10,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.errors.ErrorStrategy; import org.jbehave.scenario.parser.ScenarioDefiner; +import org.jbehave.scenario.reporters.ScenarioReporter; import org.jbehave.scenario.steps.PendingStepStrategy; import org.jbehave.scenario.steps.StepCreator; import org.jbehave.scenario.steps.Steps; Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java (887 => 888) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2008-08-23 15:06:43 UTC (rev 887) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2008-08-24 14:07:13 UTC (rev 888) @@ -12,6 +12,7 @@ import org.jbehave.scenario.definition.Blurb; import org.jbehave.scenario.errors.ErrorStrategy; import org.jbehave.scenario.errors.ErrorStrategyInWhichWeTrustTheReporter; +import org.jbehave.scenario.reporters.ScenarioReporter; import org.jbehave.scenario.steps.CandidateStep; import org.jbehave.scenario.steps.PendingStepStrategy; import org.jbehave.scenario.steps.Step; Added: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/errors/ErrorStrategyBehaviour.java (0 => 888) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/errors/ErrorStrategyBehaviour.java (rev 0) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/errors/ErrorStrategyBehaviour.java 2008-08-24 14:07:13 UTC (rev 888) @@ -0,0 +1,16 @@ +package org.jbehave.scenario.errors; + +import org.junit.Test; + +public class ErrorStrategyBehaviour { + + @Test(expected=IllegalStateException.class) + public void shouldAllowErrorsToBeRethrown() throws
[jbehave-scm] [885] trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java: [Liz] Better documentation of reporting and explanation of why I haven't written an example
Title: [885] trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java: [Liz] Better documentation of reporting and explanation of why I haven't written an example Revision 885 Author sirenian Date 2008-08-20 07:25:19 -0500 (Wed, 20 Aug 2008) Log Message [Liz] Better documentation of reporting and explanation of why I haven't written an example Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java Diff Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (884 => 885) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-20 12:15:55 UTC (rev 884) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-20 12:25:19 UTC (rev 885) @@ -136,13 +136,17 @@ } @Test -public void shouldAllowPassingScenariosToBeSilent() throws Throwable { +public void shouldAllowAllScenariosToBeReportedToOutput() throws Throwable { System.setProperty(PropertyBasedConfiguration.OUTPUT_ALL, "true"); // The only way to test this would be to replace the reporter in the configuration. + // // As a JBehave user, I want to change reporters so that the reporter I specify - // is the one that's used. Doing anything which would allow this to be testable - // would conflict with that intuitive use! So, + // is the one that's used. + // + // Doing anything which would allow this to be testable - such as allowing + // dependency injection of a delegate reporter - would conflict with that + // intuitive use! So, I'm not writing an automated example for this. } @Test To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [884] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Passing scenarios are now silent, can configure reporter to output all by setting system property org.jbehave.outputall
Title: [884] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Passing scenarios are now silent, can configure reporter to output all by setting system property org.jbehave.outputall Revision 884 Author sirenian Date 2008-08-20 07:15:55 -0500 (Wed, 20 Aug 2008) Log Message [Liz] Passing scenarios are now silent, can configure reporter to output all by setting system property org.jbehave.outputall Modified Paths trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/PropertyBasedConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioReporter.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java Added Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PassSilentlyDecoratorBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java Diff Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns (883 => 884) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns 2008-08-18 18:34:12 UTC (rev 883) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns 2008-08-20 12:15:55 UTC (rev 884) @@ -17,3 +17,4 @@ Then the grid should look like XO. ... +... Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java (883 => 884) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java 2008-08-18 18:34:12 UTC (rev 883) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java 2008-08-20 12:15:55 UTC (rev 884) @@ -13,7 +13,6 @@ import org.jbehave.scenario.annotations.Given; import org.jbehave.scenario.annotations.Then; import org.jbehave.scenario.annotations.When; -import org.jbehave.scenario.steps.PendingError; import org.jbehave.scenario.steps.Steps; import org.lunivore.tyburn.WindowControl; Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java (883 => 884) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java 2008-08-18 18:34:12 UTC (rev 883) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java 2008-08-20 12:15:55 UTC (rev 884) @@ -3,6 +3,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.jbehave.Ensure.ensureThat; +import org.jbehave.scenario.reporters.PassSilentlyDecorator; +import org.jbehave.scenario.reporters.PrintStreamScenarioReporter; import org.jbehave.scenario.steps.PendingStepStrategy; import org.junit.After; import org.junit.Before; @@ -37,4 +39,16 @@ System.setProperty(PropertyBasedConfiguration.FAIL_ON_PENDING, "true"); ensureThat(new PropertyBasedConfiguration().forPendingSteps(), is(PendingStepStrategy.FAILING)); } + + @Test + public void shouldSwallowOutputFromPassingScenariosByDefault() { + System.clearProperty(PropertyBasedConfiguration.OUTPUT_ALL); + ensureThat(new PropertyBasedConfiguration().forReportingScenarios(), is(PassSilentlyDecorator.class)); + } + + @Test + public void shouldOutputAllWhenConfiguredToDoSo() { + System.setProperty(PropertyBasedConfiguration.OUTPUT_ALL, "true"); + ensureThat(new PropertyBasedConfiguration().forReportingScenarios(), is(PrintStreamScenarioReporter.class)); + } } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (883 => 884) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-18 18:34:12 UTC (rev 883) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-08-20 12:15:55 UTC (rev 884) @@ -38,10 +38,14 @@ private static final String NL = System.getProperty("line.separator"); private String originalFailOnPending; + private String originalPassSilently; @Before - public void captureExistingEnvironment() { + public void captureExistingEnvironmentAndMakeTheseExamplesWork() { originalFailOnPending = System.getProperty(PropertyBasedConfiguration.FAIL_ON_PENDING); + originalPassSilently = System.getProperty(PropertyBasedConfiguration.OUTPUT_ALL); + System.clearProperty(PropertyBasedConfiguration.FAIL_ON_PENDING); + System.clearProperty(PropertyBasedConfiguration.OUTPUT_ALL);
[jbehave-scm] [883] trunk: [Liz] Pending exceptions can now be made to fail the build, and steps can be made partially pending by throwing PendingError
Title: [883] trunk: [Liz] Pending exceptions can now be made to fail the build, and steps can be made partially pending by throwing PendingError Revision 883 Author sirenian Date 2008-08-18 13:34:12 -0500 (Mon, 18 Aug 2008) Log Message [Liz] Pending exceptions can now be made to fail the build, and steps can be made partially pending by throwing PendingError Modified Paths trunk/build.xml trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/three_in_a_row_wins trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyMultipleScenario.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepResultBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioReporter.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PendingStep.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/StepResult.java Added Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/PropertyBasedConfigurationBehaviour.java trunk/jbehave-core/src/java/org/jbehave/Configuration.java trunk/jbehave-core/src/java/org/jbehave/scenario/PropertyBasedConfiguration.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/ErrorStrategy.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PendingError.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PendingStepStrategy.java Removed Paths trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java trunk/jbehave-core/src/java/org/jbehave/Technique.java Diff Modified: trunk/build.xml (882 => 883) --- trunk/build.xml 2008-07-29 12:22:35 UTC (rev 882) +++ trunk/build.xml 2008-08-18 18:34:12 UTC (rev 883) @@ -22,7 +22,7 @@ - + @@ -191,6 +191,7 @@ description="Produces a jar file in the distribution directory." depends="jbehave-classes"> + Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns (882 => 883) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns 2008-07-29 12:22:35 UTC (rev 882) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns 2008-08-18 18:34:12 UTC (rev 883) @@ -17,4 +17,3 @@ Then the grid should look like XO. ... -... Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java (882 => 883) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java 2008-07-29 12:22:35 UTC (rev 882) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java 2008-08-18 18:34:12 UTC (rev 883) @@ -13,6 +13,7 @@ import org.jbehave.scenario.annotations.Given; import org.jbehave.scenario.annotations.Then; import org.jbehave.scenario.annotations.When; +import org.jbehave.scenario.steps.PendingError; import org.jbehave.scenario.steps.Steps; import org.lunivore.tyburn.WindowControl; Modified: trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/three_in_a_row_wins (882 => 883) --- trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/three_in_a_row_wins 2008-07-29 12:22:35 UTC (rev 882) +++ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/three_in_a_row_wins 2008-08-18 18:34:12 UTC (rev 883) @@ -1,4 +1,4 @@ -Given the grid looks like +Given a grid that looks like OO. XX. X.. Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java (882 => 883) --- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-07-29 12:22:35 UTC (rev 882) +++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-08-18 18:34:12 UTC (rev 883) @@ -1,6 +1,6 @@ package org.jbehave.examples.trader.scenarios; -import org.jbehave.OurTechnique; +import org.jbehave.scenario.PropertyBasedConfiguration; import
[jbehave-scm] [881] trunk/examples: [Liz] Multiple scenarios in the same file work independently; noughtsandcrosses provides examples (but not in build yet)
Title: [881] trunk/examples: [Liz] Multiple scenarios in the same file work independently; noughtsandcrosses provides examples (but not in build yet) Revision 881 Author sirenian Date 2008-07-28 14:31:08 -0500 (Mon, 28 Jul 2008) Log Message [Liz] Multiple scenarios in the same file work independently; noughtsandcrosses provides examples (but not in build yet) Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioRunnerBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternStepParserBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioFileLoaderBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepResultBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/PatternStepParser.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java Added Paths trunk/examples/noughtsandcrosses/ trunk/examples/noughtsandcrosses/lib/ trunk/examples/noughtsandcrosses/lib/tyburn-0.1.jar trunk/examples/noughtsandcrosses/src/ trunk/examples/noughtsandcrosses/src/behaviour/ trunk/examples/noughtsandcrosses/src/behaviour/com/ trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/ trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/noughtsandcrosses/ trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/noughtsandcrosses/game/ trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/noughtsandcrosses/game/GameModelBehaviour.java trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/noughtsandcrosses/game/WinningScenarioBehaviour.java trunk/examples/noughtsandcrosses/src/java/ trunk/examples/noughtsandcrosses/src/java/com/ trunk/examples/noughtsandcrosses/src/java/com/lunivore/ trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/ trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/NoughtsAndCrosses.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/ trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/Coord.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/Game.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/GameModel.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/GameObserver.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/Player.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/game/WinningScenario.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/view/ trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/view/ComponentNames.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/view/GridPanel.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/view/MessageLabel.java trunk/examples/noughtsandcrosses/src/java/com/lunivore/noughtsandcrosses/view/NoughtsAndCrossesFrame.java trunk/examples/noughtsandcrosses/src/scenario/ trunk/examples/noughtsandcrosses/src/scenario/com/ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/PlayersCanTakeTurns.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/TheGridStartsEmpty.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/ThreeInARowWins.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/players_can_take_turns trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/ trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/steps/GridSteps.java trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/the_grid_starts_empty trunk/examples/noughtsandcrosses/src/scenario/com/lunivore/noughtsandcrosses/three_in_a_row_wins trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyMultipleScenario.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/my_multiple_scenario Diff Added: trunk/examples/noughtsandcrosses/lib/tyburn-0.1.jar (Binary files differ) Property changes on: trunk/examples/noughtsandcrosses/lib/tyburn-0.1.jar ___ Name: svn:mime-type + application/octet-stream Added: trunk/examples/noughtsandcrosses/src/behaviour/com/lunivore/noughtsandcrosses/game/GameModelBehaviour.java (0 => 881) --- trunk/examples/noughtsandcrosses/src/behavi
[jbehave-scm] [880] trunk/jbehave-core/src/java/org/jbehave: Not passing steps as strings around any more, first step in refactoring for multiple scenarios in a file
Title: [880] trunk/jbehave-core/src/java/org/jbehave: Not passing steps as strings around any more, first step in refactoring for multiple scenarios in a file Revision 880 Author sirenian Date 2008-07-27 16:53:10 -0500 (Sun, 27 Jul 2008) Log Message Not passing steps as strings around any more, first step in refactoring for multiple scenarios in a file Modified Paths trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioFileLoaderBehaviour.java trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java trunk/jbehave-core/src/java/org/jbehave/Technique.java trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java Added Paths trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefinition.java Diff Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java (879 => 880) --- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-07-25 09:26:30 UTC (rev 879) +++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-07-27 21:53:10 UTC (rev 880) @@ -2,6 +2,7 @@ import org.jbehave.OurTechnique; import org.jbehave.scenario.Scenario; +import org.jbehave.scenario.parser.PatternStepParser; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; @@ -15,7 +16,7 @@ public StatusAlertCanBeActivated(final ClassLoader classLoader) { super(new OurTechnique() { public ScenarioFileLoader forDefiningScenarios() { -return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader); +return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader, new PatternStepParser()); } }, new StockSteps(10.0)); } Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java (879 => 880) --- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java 2008-07-25 09:26:30 UTC (rev 879) +++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java 2008-07-27 21:53:10 UTC (rev 880) @@ -2,6 +2,7 @@ import org.jbehave.OurTechnique; import org.jbehave.scenario.Scenario; +import org.jbehave.scenario.parser.PatternStepParser; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; @@ -16,7 +17,7 @@ super(new OurTechnique() { @Override public ScenarioFileLoader forDefiningScenarios() { - return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader); + return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader, new PatternStepParser()); } }, new StockSteps(100.0)); } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (879 => 880) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-25 09:26:30 UTC (rev 879) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-27 21:53:10 UTC (rev 880) @@ -16,6 +16,7 @@ import org.jbehave.scenario.annotations.When; import org.jbehave.scenario.parser.PatternStepParser; import org.jbehave.scenario.parser.ScenarioDefiner; +import org.jbehave.scenario.parser.ScenarioDefinition; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.StepParser; import org.jbehave.scenario.parser.scenarios.MyPendingScenario; @@ -41,7 +42,7 @@ PrintStreamScenarioReporter reporter = new PrintStreamScenarioReporter(new PrintStream(output)); MySteps steps = new MySteps(); - stub(fileLoader.loadStepsFor(MyScenario.class)).toReturn("my_scenario"); + stub(fileLoader.loadStepsFor(MyScenario.class)).toReturn(new ScenarioDefinition(stepParser, "my_scenario")); stub(stepParser.findSteps("my_scenario")).toReturn(Arrays.asList(new String[] { "Given I have 2 cows", "When I leave them over the winter", @@ -65,7 +66,7 @@ ScenarioReporter reporter = new BufferScenarioReporter(buffer); MySteps steps = new MySteps(); -stub(fileLoader.loadStepsFor(MyScenario.class)).toReturn("my_scenari
[jbehave-scm] [879] trunk/jbehave-core/src/java/org/jbehave: [Liz] Oops, missed some classes.
Title: [879] trunk/jbehave-core/src/java/org/jbehave: [Liz] Oops, missed some classes. Revision 879 Author sirenian Date 2008-07-25 04:26:30 -0500 (Fri, 25 Jul 2008) Log Message [Liz] Oops, missed some classes. Added Paths trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java trunk/jbehave-core/src/java/org/jbehave/Technique.java trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java Diff Added: trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java (0 => 879) --- trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java (rev 0) +++ trunk/jbehave-core/src/java/org/jbehave/OurTechnique.java 2008-07-25 09:26:30 UTC (rev 879) @@ -0,0 +1,21 @@ +package org.jbehave; + +import org.jbehave.scenario.parser.PatternStepParser; +import org.jbehave.scenario.parser.ScenarioFileLoader; +import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; +import org.jbehave.scenario.reporters.PrintStreamScenarioReporter; + +public class OurTechnique implements Technique { + + public PatternStepParser forParsingSteps() { + return new PatternStepParser(); + } + + public PrintStreamScenarioReporter forReportingScenarios() { + return new PrintStreamScenarioReporter(); + } + + public ScenarioFileLoader forDefiningScenarios() { + return new ScenarioFileLoader(new UnderscoredCamelCaseResolver()); + } +} Added: trunk/jbehave-core/src/java/org/jbehave/Technique.java (0 => 879) --- trunk/jbehave-core/src/java/org/jbehave/Technique.java (rev 0) +++ trunk/jbehave-core/src/java/org/jbehave/Technique.java 2008-07-25 09:26:30 UTC (rev 879) @@ -0,0 +1,20 @@ +package org.jbehave; + +import org.jbehave.scenario.ScenarioReporter; +import org.jbehave.scenario.parser.ScenarioDefiner; +import org.jbehave.scenario.parser.StepParser; + +/** + * Provides techniques for defining, parsing and reporting scenarios. + * + * @author Elizabeth Keogh + */ +public interface Technique { + + ScenarioDefiner forDefiningScenarios(); + + StepParser forParsingSteps(); + + ScenarioReporter forReportingScenarios(); + +} Added: trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java (0 => 879) --- trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java (rev 0) +++ trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioDefiner.java 2008-07-25 09:26:30 UTC (rev 879) @@ -0,0 +1,9 @@ +package org.jbehave.scenario.parser; + +import org.jbehave.scenario.Scenario; + +public interface ScenarioDefiner { + + String loadStepsFor(Class clazz); + +} \ No newline at end of file To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [878] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Moved constructors for scenarios into Technique, in preparation for the different ways of reporting / breaking the build
Title: [878] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Moved constructors for scenarios into Technique, in preparation for the different ways of reporting / breaking the build Revision 878 Author sirenian Date 2008-07-25 04:24:35 -0500 (Fri, 25 Jul 2008) Log Message [Liz] Moved constructors for scenarios into Technique, in preparation for the different ways of reporting / breaking the build Modified Paths trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/ScenarioFileLoaderBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java Added Paths trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java Removed Paths trunk/jbehave-core/src/java/org/jbehave/scenario/parser/ScenarioFileLoader.java Diff Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java (877 => 878) --- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-07-24 12:53:56 UTC (rev 877) +++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertCanBeActivated.java 2008-07-25 09:24:35 UTC (rev 878) @@ -1,5 +1,6 @@ package org.jbehave.examples.trader.scenarios; +import org.jbehave.OurTechnique; import org.jbehave.scenario.Scenario; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; @@ -11,8 +12,12 @@ this(Thread.currentThread().getContextClassLoader()); } -public StatusAlertCanBeActivated(ClassLoader classLoader) { -super(new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader), new StockSteps(10.0)); +public StatusAlertCanBeActivated(final ClassLoader classLoader) { +super(new OurTechnique() { + public ScenarioFileLoader forDefiningScenarios() { +return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader); + } +}, new StockSteps(10.0)); } } Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java (877 => 878) --- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java 2008-07-24 12:53:56 UTC (rev 877) +++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/StatusAlertIsNeverActivated.java 2008-07-25 09:24:35 UTC (rev 878) @@ -1,5 +1,6 @@ package org.jbehave.examples.trader.scenarios; +import org.jbehave.OurTechnique; import org.jbehave.scenario.Scenario; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver; @@ -11,8 +12,13 @@ this(Thread.currentThread().getContextClassLoader()); } -public StatusAlertIsNeverActivated(ClassLoader classLoader) { -super(new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader), new StockSteps(100.0)); +public StatusAlertIsNeverActivated(final ClassLoader classLoader) { +super(new OurTechnique() { + @Override + public ScenarioFileLoader forDefiningScenarios() { + return new ScenarioFileLoader(new UnderscoredCamelCaseResolver(".scenario"), classLoader); + } +}, new StockSteps(100.0)); } } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (877 => 878) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-24 12:53:56 UTC (rev 877) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-25 09:24:35 UTC (rev 878) @@ -10,10 +10,12 @@ import java.io.PrintStream; import java.util.Arrays; +import org.jbehave.Technique; import org.jbehave.scenario.annotations.Given; import org.jbehave.scenario.annotations.Then; import org.jbehave.scenario.annotations.When; import org.jbehave.scenario.parser.PatternStepParser; +import org.jbehave.scenario.parser.ScenarioDefiner; import org.jbehave.scenario.parser.ScenarioFileLoader; import org.jbehave.scenario.parser.StepParser; import org.jbehave.scenario.parser.scenarios.MyPendingScenario; @@ -36,16 +38,16 @@ ScenarioFileLoader fileLoader = mock(ScenarioFileLoader.class); StepParser stepParser = mock(PatternStepParser.class); ByteArrayOutputStream output = new ByteArrayOutputStream(); - ScenarioRunner runner = new ScenarioRunner(new PrintStreamScenarioReporter(new PrintStream(output)
[jbehave-scm] [877] trunk/jbehave-core/src/java/org/jbehave/scenario/steps: [Liz]: DollarStepPatternBuilder -> PrefixCapturingPatternBuilder, can configure with a prefix; also escapes all regexp char
Title: [877] trunk/jbehave-core/src/java/org/jbehave/scenario/steps: [Liz]: DollarStepPatternBuilder -> PrefixCapturingPatternBuilder, can configure with a prefix; also escapes all regexp characters Revision 877 Author sirenian Date 2008-07-24 07:53:56 -0500 (Thu, 24 Jul 2008) Log Message [Liz]: DollarStepPatternBuilder -> PrefixCapturingPatternBuilder, can configure with a prefix; also escapes all regexp characters Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/StepPatternBuilder.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java Added Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/PrefixCapturingPatternBuilderBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/PrefixCapturingPatternBuilder.java Removed Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/DollarStepPatternBuilderBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/DollarStepPatternBuilder.java Diff Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java (876 => 877) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2008-07-22 17:11:43 UTC (rev 876) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2008-07-24 12:53:56 UTC (rev 877) @@ -11,7 +11,7 @@ public class CandidateStepBehaviour { -private static final StepPatternBuilder PATTERN_BUILDER = new DollarStepPatternBuilder(); +private static final StepPatternBuilder PATTERN_BUILDER = new PrefixCapturingPatternBuilder(); private static final StepMonitor MONITOR = new SilentStepMonitor(); private static final String NL = System.getProperty("line.separator"); Deleted: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/DollarStepPatternBuilderBehaviour.java (876 => 877) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/DollarStepPatternBuilderBehaviour.java 2008-07-22 17:11:43 UTC (rev 876) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/DollarStepPatternBuilderBehaviour.java 2008-07-24 12:53:56 UTC (rev 877) @@ -1,67 +0,0 @@ -package org.jbehave.scenario.steps; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.jbehave.Ensure.ensureThat; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.Test; - - -public class DollarStepPatternBuilderBehaviour { - - private static final String NL = System.getProperty("line.separator"); - - @Test - public void shouldReplaceAllDollarArgumentsWithCaptures() { - StepPatternBuilder builder = new DollarStepPatternBuilder(); - ensureThat(builder.buildPattern("a house with $numberOfDoors doors and $some windows").matcher("a house with 3 doors and 4 windows").matches()); - ensureThat(builder.buildPattern("the house on $street").matcher("the house on Easy Street").matches()); - ensureThat(builder.buildPattern("$number houses").matcher("5 houses").matches()); - ensureThat(builder.buildPattern("my house").matcher("my house").matches()); - } - - @Test - public void shouldEscapeExistingBrackets() { - StepPatternBuilder matcher = new DollarStepPatternBuilder(); - ensureThat(matcher.buildPattern("I toggle the cell at ($column, $row)").matcher("I toggle the cell at (3, 4)").matches()); - } - - @Test - public void shouldNotCareSoMuchAboutWhitespace() { - StepPatternBuilder matcher = new DollarStepPatternBuilder(); - Pattern pattern = matcher.buildPattern("The grid looks like $grid"); - - // Given an argument on a new line - Matcher matched = pattern.matcher( -"The grid looks like" + NL + -".." + NL + -".." + NL -); - ensureThat(matched.matches()); - ensureThat(matched.group(1), equalTo( -".." + NL + -".." + NL)); - - // Given an argument on a new line with extra spaces - matched = pattern.matcher( -"The grid looks like " + NL + -".." + NL + -".." + NL -); - ensureThat(matched.matches()); - ensureThat(matched.group(1), equalTo( -".." + NL + -".." + NL)); - - // Given an argument with extra spaces - matched = pattern.matcher( -"The grid looks like ."); - ensureThat(matched.matches()); - ensureThat(matched.group(1), equalTo( -".")); - - } - -} Added: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/PrefixCapturingPatternBuilderBehaviour.java (0 => 877) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/PrefixCapturingPatternBuilderBehaviour.java (rev 0) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/step
[jbehave-scm] [876] trunk: [Liz] Put the website stuff back in, not up to date yet; changed build to produce 2.0 snapshot
Title: [876] trunk: [Liz] Put the website stuff back in, not up to date yet; changed build to produce 2.0 snapshot Revision 876 Author sirenian Date 2008-07-22 12:11:43 -0500 (Tue, 22 Jul 2008) Log Message [Liz] Put the website stuff back in, not up to date yet; changed build to produce 2.0 snapshot Modified Paths trunk/build.xml Added Paths trunk/website/ Diff Modified: trunk/build.xml (875 => 876) --- trunk/build.xml 2008-07-21 09:45:52 UTC (rev 875) +++ trunk/build.xml 2008-07-22 17:11:43 UTC (rev 876) @@ -1,5 +1,5 @@ - + @@ -205,7 +205,7 @@ - + Copied: trunk/website (from rev 802, trunk/website) ( => ) To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [874] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Cleaned up the code that creates the candidate steps; there is now only one kind of step (the others weren't doing much any
Title: [874] trunk/jbehave-core/src/java/org/jbehave/scenario: [Liz] Cleaned up the code that creates the candidate steps; there is now only one kind of step (the others weren't doing much anyway) and you can choose the words that signify the start of a step. Revision 874 Author sirenian Date 2008-07-20 15:28:57 -0500 (Sun, 20 Jul 2008) Log Message [Liz] Cleaned up the code that creates the candidate steps; there is now only one kind of step (the others weren't doing much anyway) and you can choose the words that signify the start of a step. Modified Paths trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepsBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/Scenario.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java Removed Paths trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Given.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Then.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/When.java Diff Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (873 => 874) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-20 14:17:53 UTC (rev 873) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-20 20:28:57 UTC (rev 874) @@ -43,7 +43,7 @@ stub(stepParser.findSteps("my_scenario")).toReturn(Arrays.asList(new String[] { "Given I have 2 cows", "When I leave them over the winter", -"Then I have 2 cows"})); +"Then I should have 2 cows"})); new MyScenario(fileLoader, stepParser, runner, steps).runUsingSteps(); @@ -51,7 +51,7 @@ ensureThat(output.toString(), equalTo( "Given I have 2 cows" + NL + "When I leave them over the winter (PENDING)" + NL + -"Then I have 2 cows (NOT PERFORMED)" + NL)); +"Then I should have 2 cows (NOT PERFORMED)" + NL)); } @Test @@ -67,7 +67,7 @@ stub(stepParser.findSteps("my_scenario")).toReturn(Arrays.asList(new String[] { "Given I have 2 cows", "When I leave them over the winter", -"Then I have 2 cows"})); +"Then I should have 2 cows"})); new MyScenario(fileLoader, stepParser, runner, steps).runUsingSteps(); @@ -75,7 +75,7 @@ ensureThat(buffer.toString(), equalTo( "Given I have 2 cows" + NL + "When I leave them over the winter (PENDING)" + NL + -"Then I have 2 cows (NOT PERFORMED)" + NL)); +"Then I should have 2 cows (NOT PERFORMED)" + NL)); } @Test @@ -97,12 +97,12 @@ "Given I have 2 cows", "When I put them in a field", "Then my cows should not die", -"Then I have 2 cows"})); +"Then I should have 2 cows"})); try { new MyScenario(fileLoader, stepParser, runner, steps).runUsingSteps(); - fail("Excpected the error to be rethrown"); + fail("Expected the error to be rethrown"); } catch (IllegalAccessError e) { ensureThat(e, equalTo(steps.error)); } @@ -111,7 +111,7 @@ "Given I have 2 cows" + NL + "When I put them in a field" + NL + "Then my cows should not die (FAILED)" + NL + -"Then I have 2 cows (NOT PERFORMED)" + NL)); +"Then I should have 2 cows (NOT PERFORMED)" + NL)); } @@ -134,7 +134,7 @@ @When("I put them in a field") public void ignoreCows() {} - @Then("I have $n cows") + @Then("I should have $n cows") public void checkCows(int numberOfCows) { ensureThat(this.numberOfCows, equalTo(numberOfCows)); } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java (873 => 874) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2008-07-20 14:17:53 UTC (rev 873) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java 2008-07-20 20:28:57 UTC (rev 874) @@ -17,18 +17,16 @@ @Test public void shouldMatchASimpleString() throws Exception { -CandidateStep candidateStep = new Given("I laugh", SomeSteps.class.getMethod("aMethod"), null, -PATTERN_BUILDER, MONITOR); +CandidateStep candidateStep = new CandidateStep("I laugh", SomeSteps.class.getMethod("aMethod"), null, +PATTERN_
[jbehave-scm] [873] trunk: [Liz] Build is now working without maven (sorry, Mauro!) and running all behaviours and scenarios correctly.
Title: [873] trunk: [Liz] Build is now working without maven (sorry, Mauro!) and running all behaviours and scenarios correctly. Revision 873 Author sirenian Date 2008-07-20 09:17:53 -0500 (Sun, 20 Jul 2008) Log Message [Liz] Build is now working without maven (sorry, Mauro!) and running all behaviours and scenarios correctly. Also added functionality to replace newlines in args with system newlines (so it will work on any system). Modified Paths trunk/build.xml trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java Diff Modified: trunk/build.xml (872 => 873) --- trunk/build.xml 2008-07-20 11:05:26 UTC (rev 872) +++ trunk/build.xml 2008-07-20 14:17:53 UTC (rev 873) @@ -1,225 +1,223 @@ - + + + - - - + + + + - - + + + + + + + + + + + + + + + + + + - - - - + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + - - + + + + + + + + + + - - - - + + + + + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java (872 => 873) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-20 11:05:26 UTC (rev 872) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/ScenarioBehaviour.java 2008-07-20 14:17:53 UTC (rev 873) @@ -156,19 +156,19 @@ } public void failed(String step, Throwable e) { -buffer.append(step+ " (FAILED)\n"); +buffer.append(step+ " (FAILED)" + NL); } public void notPerformed(String step) { -buffer.append(step+ " (NOT PERFORMED)\n"); +buffer.append(step+ " (NOT PERFORMED)" + NL); } public void pending(String step) { -buffer.append(step+ " (PENDING)\n"); +buffer.append(step+ " (PENDING)" + NL); } public void successful(String step) { -buffer.append(step+"\n"); +buffer.append(step+NL); } } Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java (872 => 873) --- trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java 2008-07-20 11:05:26 UTC (rev 872) +++ trunk/jbehave-core/src/behaviour/org/jbehave/scenario/parser/scenarios/MyPendingScenario.java 2008-07-20 14:17:53 UTC (rev 873) @@ -1,7 +1,16 @@ package org.jbehave.scenario.parser.scenarios; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + import org.jbehave.scenario.Scenario; +import org.jbehave.scenario.parser.ScenarioFileLoader; +import org.jbehave.scenario.reporters.PrintStreamScenarioReporter; public class MyPendingScenario extends Scenario { + public MyPendingScenario() { + // Making sure this doesn't output to the build while it's running + super(new ScenarioFileLoader(), new PrintStreamScenarioReporter(new PrintStream(new ByteArrayOutputStream(; + } } \ No newline at end of file Modified: trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/CandidateStepBeh
[jbehave-scm] [872] trunk/: [Liz] Added ant's working directory to ignore list
Title: [872] trunk/: [Liz] Added ant's working directory to ignore list Revision 872 Author sirenian Date 2008-07-20 06:05:26 -0500 (Sun, 20 Jul 2008) Log Message [Liz] Added ant's working directory to ignore list Property Changed trunk/ Diff Property changes: trunk Name: svn:ignore - spike bin jbehave.iml classes delete_me dist workspace jbehave.iws build target-eclipse target .classpath .project + spike bin jbehave.iml classes delete_me dist workspace jbehave.iws build target-eclipse target .classpath .project working To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [871] trunk/jbehave-core/src/java/org/jbehave/scenario/steps: [Liz] We no longer care about whitespace in args
Title: [871] trunk/jbehave-core/src/java/org/jbehave/scenario/steps: [Liz] We no longer care about whitespace in args Revision 871 Author sirenian Date 2008-07-18 08:29:54 -0500 (Fri, 18 Jul 2008) Log Message [Liz] We no longer care about whitespace in args Modified Paths trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/domain/GameBehaviour.java trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java trunk/examples/gameoflife/src/java/com/lunivore/gameoflife/view/string/StringRenderer.java trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/i_can_toggle_a_cell trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/the_grid_starts_empty trunk/jbehave-core/src/behaviour/org/jbehave/scenario/steps/DollarStepPatternBuilderBehaviour.java trunk/jbehave-core/src/java/org/jbehave/scenario/steps/DollarStepPatternBuilder.java Diff Modified: trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/domain/GameBehaviour.java (870 => 871) --- trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/domain/GameBehaviour.java 2008-06-27 11:50:05 UTC (rev 870) +++ trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/domain/GameBehaviour.java 2008-07-18 13:29:54 UTC (rev 871) @@ -16,7 +16,7 @@ StringRenderer renderer = new StringRenderer(); Game game = new Game(6, 4); game.setObserver(renderer); - ensureThat(renderer.asString(), CoreMatchers.equalTo(NL + + ensureThat(renderer.asString(), CoreMatchers.equalTo( ".." + NL + ".." + NL + ".." + NL + @@ -29,19 +29,19 @@ Game game = new Game(6, 4); game.setObserver(renderer); game.toggleCellAt(2, 1); - ensureThat(renderer.asString(), CoreMatchers.equalTo(NL + + ensureThat(renderer.asString(), CoreMatchers.equalTo( ".." + NL + "..X..." + NL + ".." + NL + "..")); game.toggleCellAt(2, 2); - ensureThat(renderer.asString(), CoreMatchers.equalTo(NL + + ensureThat(renderer.asString(), CoreMatchers.equalTo( ".." + NL + "..X..." + NL + "..X..." + NL + "..")); game.toggleCellAt(2, 1); - ensureThat(renderer.asString(), CoreMatchers.equalTo(NL + + ensureThat(renderer.asString(), CoreMatchers.equalTo( ".." + NL + ".." + NL + "..X..." + NL + Modified: trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java (870 => 871) --- trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java 2008-06-27 11:50:05 UTC (rev 870) +++ trunk/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java 2008-07-18 13:29:54 UTC (rev 871) @@ -22,7 +22,7 @@ stub(grid.hasLife(3, 4)).toReturn(true); renderer.gridChanged(grid); - ensureThat(renderer.asString(), equalTo(NL + + ensureThat(renderer.asString(), equalTo( "." + NL + "." + NL + "." + NL + Modified: trunk/examples/gameoflife/src/java/com/lunivore/gameoflife/view/string/StringRenderer.java (870 => 871) --- trunk/examples/gameoflife/src/java/com/lunivore/gameoflife/view/string/StringRenderer.java 2008-06-27 11:50:05 UTC (rev 870) +++ trunk/examples/gameoflife/src/java/com/lunivore/gameoflife/view/string/StringRenderer.java 2008-07-18 13:29:54 UTC (rev 871) @@ -10,7 +10,6 @@ public String asString() { StringBuilder builder = new StringBuilder(); - builder.append(NL); for (int row = 0; row < grid.getHeight(); row++) { for (int column = 0; column < grid.getWidth(); column++) { builder.append(grid.hasLife(column, row) ? "X" : "."); Modified: trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/i_can_toggle_a_cell (870 => 871) --- trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/i_can_toggle_a_cell 2008-06-27 11:50:05 UTC (rev 870) +++ trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/i_can_toggle_a_cell 2008-07-18 13:29:54 UTC (rev 871) @@ -1,20 +1,20 @@ Given a 5 by 5 game When I toggle the cell at (2, 3) -Then the grid should look like +Then the grid should look like . . . ..X.. . When I toggle the cell at (2, 4) -Then the grid should look like +Then the grid should look like . . . ..X.. ..X.. When I toggle the cell at (2, 3) -Then the grid should look like +Then the grid should look like . . . Modified: trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/the_grid_starts_empty (870 => 871) --- trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/the_grid_starts_empty 2008-06-27 11:50:05 UTC (rev 870) +++ trunk/examples/gameoflife/src/scenario/com/lunivore/gameoflife/the_grid_starts_empty 2008-07-18 13
[jbehave-scm] [802] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: Fixed comboboxes and keycodes for the mac
Title: [802] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: Fixed comboboxes and keycodes for the mac Revision 802 Author sirenian Date 2008-02-04 22:04:03 -0600 (Mon, 04 Feb 2008) Log Message Fixed comboboxes and keycodes for the mac Modified Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/QueueingAdapter.java Diff Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java (801 => 802) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java 2007-10-14 15:02:00 UTC (rev 801) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java 2008-02-05 04:04:03 UTC (rev 802) @@ -30,7 +30,7 @@ } public void causeBeat() { - if (System.getProperty("SLOW") != null) { + if (System.getProperty("com.sirenian.hellbound.SLOW") != null) { synchronized(this) { try { wait(700); Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (801 => 802) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-10-14 15:02:00 UTC (rev 801) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2008-02-05 04:04:03 UTC (rev 802) @@ -117,14 +117,17 @@ JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); comboBox.setName("a.combobox"); comboBox.setEditable(true); +comboBox.setSelectedItem("horse"); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(comboBox); frame.pack(); frame.setVisible(true); - + wrapper.enterText("a.combobox", "cow"); -ensureThat(comboBox.getEditor().getItem(), eq("cowhorse")); // because we didn't delete the previous value +// Due to the different focusing behaviour of eg: macs, PCs, this could say +// "cow" or "cowhorse" +ensureThat(comboBox.getEditor().getItem().toString(), contains("cow")); } finally { wrapper.closeWindow(); @@ -231,20 +234,4 @@ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } } - -public static void main(String[] args) { -AFrame frame = new AFrame(); - -JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); -comboBox.setName("a.combobox"); -comboBox.setEditable(true); - -frame.getContentPane().setLayout(new FlowLayout()); - -frame.getContentPane().add(comboBox); -frame.pack(); - - -frame.setVisible(true); -} } Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (801 => 802) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-10-14 15:02:00 UTC (rev 801) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2008-02-05 04:04:03 UTC (rev 802) @@ -78,7 +78,36 @@ } } -private void postKeyEvent(final Component component, final char key) { + public void pressKeycode(Window window, int keycode) { +QueueingKeyAdapter queuer = null; + +if(window instanceof JFrame) { +Container contentPane = ((JFrame)window).getContentPane(); +if (contentPane instanceof JComponent) { +queuer = new QueueingKeyAdapter(contentPane); +focuser.requestFocusOn(contentPane); +} +} else { +queuer = new QueueingKeyAdapter(window.getFocusOwner()); +focuser.requestFocusOn(window.getFocusOwner()); +} + +postKeycodeEvent(window, keycode); + +try { +queuer.waitForEvent(); +} finally { +queuer.removeSelfFromComponent(); +} + } + +private void postKeycodeEvent(Window window, int keycode) { +sysQueue.postEvent(createKeyPressEvent(window, keycode, KeyEvent.KEY_PRESSED)); +sysQueue.postEvent(createKeyPressEvent(window, keycode, KeyEvent.KEY_RELEASED)); +idler.waitForIdle(); + } + + private void postKeyEvent(final Component component, final c
[jbehave-scm] [799] trunk/build.xml: [EK] Added clean to default build target.
Title: [799] trunk/build.xml: [EK] Added clean to default build target. Revision 799 Author sirenian Date 2007-09-10 07:26:11 -0500 (Mon, 10 Sep 2007) Log Message [EK] Added clean to default build target. Modified Paths trunk/build.xml Diff Modified: trunk/build.xml (798 => 799) --- trunk/build.xml 2007-09-09 16:29:47 UTC (rev 798) +++ trunk/build.xml 2007-09-10 12:26:11 UTC (rev 799) @@ -49,7 +49,7 @@ - + description="build the jbehave binary and zip up the project" /> To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [798] trunk: [EK] Fixed the build file so that it will find and run all behaviours, rather than relying on AllBehaviours suites.
Title: [798] trunk: [EK] Fixed the build file so that it will find and run all behaviours, rather than relying on AllBehaviours suites. Revision 798 Author sirenian Date 2007-09-09 11:29:47 -0500 (Sun, 09 Sep 2007) Log Message [EK] Fixed the build file so that it will find and run all behaviours, rather than relying on AllBehaviours suites. Modified Paths trunk/build.xml trunk/core/src/java/org/jbehave/core/BehaviourRunner.java trunk/extensions/ant/src/java/org/jbehave/ant/TrimFilesetParser.java Diff Modified: trunk/build.xml (797 => 798) --- trunk/build.xml 2007-09-07 09:19:24 UTC (rev 797) +++ trunk/build.xml 2007-09-09 16:29:47 UTC (rev 798) @@ -104,14 +104,25 @@ + + - + + + + + + + + + - + + Modified: trunk/core/src/java/org/jbehave/core/BehaviourRunner.java (797 => 798) --- trunk/core/src/java/org/jbehave/core/BehaviourRunner.java 2007-09-07 09:19:24 UTC (rev 797) +++ trunk/core/src/java/org/jbehave/core/BehaviourRunner.java 2007-09-09 16:29:47 UTC (rev 798) @@ -87,8 +87,7 @@ } System.exit(runner.succeeded() ? 0 : 1); } catch (ClassNotFoundException e) { -e.printStackTrace(); -System.exit(1); +throw new RuntimeException(e); } } Modified: trunk/extensions/ant/src/java/org/jbehave/ant/TrimFilesetParser.java (797 => 798) --- trunk/extensions/ant/src/java/org/jbehave/ant/TrimFilesetParser.java 2007-09-07 09:19:24 UTC (rev 797) +++ trunk/extensions/ant/src/java/org/jbehave/ant/TrimFilesetParser.java 2007-09-09 16:29:47 UTC (rev 798) @@ -24,18 +24,19 @@ base.getAbsolutePath().length() + 1).replace('\\', '/') .replace('/', '.'); -int classnameIndex = classname.indexOf(".class"); -if (classnameIndex != -1) { -classname = classname.substring(0, classnameIndex); -} - -classnameIndex = classname.indexOf(".java"); -if (classnameIndex != -1) { -classname = classname.substring(0, classnameIndex); -} +classname = stripJavaOrClassFromEndOfFile(classname); classnames.add(classname); } return (String[]) classnames.toArray(new String[classnames.size()]); } + private String stripJavaOrClassFromEndOfFile(String classname) { + if (classname.length() > 6 && classname.substring(classname.length() - 6, classname.length()).equals(".class")) { + classname = classname.substring(0, classname.length() - 6); + } else if (classname.length() > 5 && classname.substring(classname.length() - 5, classname.length()).equals(".java")) { + classname = classname.substring(0, classname.length() -5); + } + return classname; + } + } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [796] trunk: [EK] Reverted...
Title: [796] trunk: [EK] Reverted... Revision 796 Author sirenian Date 2007-09-07 01:42:17 -0500 (Fri, 07 Sep 2007) Log Message [EK] Reverted... sorry, Shane, no generics please! Modified Paths trunk/core/jbehave-core.iml trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java trunk/core/src/behaviour/org/jbehave/core/behaviour/BehaviourClassBehaviour.java trunk/core/src/java/org/jbehave/core/BehaviourRunner.java trunk/core/src/java/org/jbehave/core/behaviour/BehaviourClass.java trunk/core/src/java/org/jbehave/core/behaviour/MethodVerifier.java trunk/extensions/ant/ant.iml trunk/extensions/jmock/jmock-extension.iml trunk/extensions/junit/junit-extension.iml trunk/extensions/swing/swing-extension.iml trunk/jbehave.ipr trunk/lib/lib.iml trunk/website/website.iml Removed Paths trunk/lib/test/ Diff Modified: trunk/core/jbehave-core.iml (795 => 796) --- trunk/core/jbehave-core.iml 2007-09-07 05:19:51 UTC (rev 795) +++ trunk/core/jbehave-core.iml 2007-09-07 06:42:17 UTC (rev 796) @@ -1,5 +1,6 @@ - + + @@ -10,7 +11,6 @@ - Modified: trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java (795 => 796) --- trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-09-07 05:19:51 UTC (rev 795) +++ trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-09-07 06:42:17 UTC (rev 796) @@ -7,11 +7,32 @@ */ package org.jbehave.core; -import net.sf.cotta.jbehave.BehavioursLoader; +import org.jbehave.core.behaviour.BehaviourBehaviours; import org.jbehave.core.behaviour.Behaviours; +import org.jbehave.core.exception.ExceptionBehaviours; +import org.jbehave.core.listener.ListenerBehaviours; +import org.jbehave.core.matchers.MatchersBehaviours; +import org.jbehave.core.minimock.MiniMockBehaviours; +import org.jbehave.core.mock.MockBehaviours; +import org.jbehave.core.result.ResultBehaviours; +import org.jbehave.core.story.StoryBehaviours; +import org.jbehave.core.threaded.ThreadedBehaviours; +import org.jbehave.core.util.UtilBehaviours; public class AllBehaviours implements Behaviours { public Class[] getBehaviours() { -return new BehavioursLoader(getClass()).loadBehaviours(); +return new Class[] { +BehaviourRunnerBehaviour.class, +BehaviourBehaviours.class, +ExceptionBehaviours.class, +ListenerBehaviours.class, +MatchersBehaviours.class, +MiniMockBehaviours.class, +MockBehaviours.class, +ResultBehaviours.class, +StoryBehaviours.class, +ThreadedBehaviours.class, +UtilBehaviours.class +}; } } Modified: trunk/core/src/behaviour/org/jbehave/core/behaviour/BehaviourClassBehaviour.java (795 => 796) --- trunk/core/src/behaviour/org/jbehave/core/behaviour/BehaviourClassBehaviour.java 2007-09-07 05:19:51 UTC (rev 795) +++ trunk/core/src/behaviour/org/jbehave/core/behaviour/BehaviourClassBehaviour.java 2007-09-07 06:42:17 UTC (rev 796) @@ -24,6 +24,8 @@ */ public class BehaviourClassBehaviour extends UsingMiniMock { +private BehaviourVerifier nullVerifier = new BehaviourVerifier(BehaviourListener.NULL); + public static class ClassWithOneBehaviourMethod { public void shouldDoOneThing() {} } @@ -39,26 +41,41 @@ } }; } - + +private Matcher isBehaviourMethodFor(final String name) { +return new Matcher() { +public boolean matches(Object arg) { +BehaviourMethod behaviourMethod = (BehaviourMethod)arg; +return behaviourMethod != null && behaviourMethod.method().getName().equals(name); +} +public String toString() { +return "behaviour method for " + name; +} +}; +} + public void shouldVerifySingleBehaviourMethod() throws Exception { // given Mock listener = mock(BehaviourListener.class); -listener.expects("before").once(); -listener.expects("after").once(); -listener.expects("gotResult").once(); +final Behaviour[] capturedBehaviour = new Behaviour[1]; // the behaviour + +BehaviourVerifier verifier = new BehaviourVerifier(null) { // hand-rolled mock for concrete class +public void verifyBehaviour(Behaviour behaviour) { +capturedBehaviour[0] = behaviour; +} +}; +Behaviour behaviour = new BehaviourClass(ClassWithOneBehaviourMethod.class, verifier); -BehaviourClass behaviour = new BehaviourClass(ClassWithOneBehaviourMethod.class); - // when behaviour.verifyTo((BehaviourListener) listener); // then -listener.verify(); +ensureThat(capturedBehaviour[0], isBehaviourMeth
[jbehave-scm] [786] trunk/core/src/java/org/jbehave/core/story: [EK] Oops, we put some stuff in for debugging and forgot to take it out.
Title: [786] trunk/core/src/java/org/jbehave/core/story: [EK] Oops, we put some stuff in for debugging and forgot to take it out. Revision 786 Author sirenian Date 2007-08-16 07:53:33 -0500 (Thu, 16 Aug 2007) Log Message [EK] Oops, we put some stuff in for debugging and forgot to take it out. Also removed the System.exit calls and let the exceptions propagate instead. Modified Paths trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java trunk/core/src/java/org/jbehave/core/story/StoryRunner.java trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java Diff Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (785 => 786) --- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-15 17:17:30 UTC (rev 785) +++ trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-16 12:53:33 UTC (rev 786) @@ -41,17 +41,12 @@ story.narrateTo(renderer); } -public static void main(String[] args) { -try { -StoryPrinter printer = new StoryPrinter( -new StoryLoader(new TextStoryParser(), StoryPrinter.class.getClassLoader()), -new PlainTextRenderer(System.out)); -for (int i = 0; i < args.length; i++) { -printer.print(args[i]); -} -} catch (Exception e) { -e.printStackTrace(); -System.exit(1); -} +public static void main(String[] args) throws MalformedURLException, InstantiationException, IllegalAccessException, ClassNotFoundException { +StoryPrinter printer = new StoryPrinter( +new StoryLoader(new TextStoryParser(), StoryPrinter.class.getClassLoader()), +new PlainTextRenderer(System.out)); +for (int i = 0; i < args.length; i++) { +printer.print(args[i]); +} } } Modified: trunk/core/src/java/org/jbehave/core/story/StoryRunner.java (785 => 786) --- trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-08-15 17:17:30 UTC (rev 785) +++ trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-08-16 12:53:33 UTC (rev 786) @@ -69,18 +69,12 @@ return (Story) classLoader.loadClass(className).newInstance(); } -public static void main(String[] args) throws ClassNotFoundException { -Thread.currentThread().getContextClassLoader().loadClass("com.sirenian.hellbound.stories.TheGlyphIsConstrainedByThePit"); -try { -StoryRunner runner = new StoryRunner(); -for (int i = 0; i < args.length; i++) { -runner.run(args[i], System.out); -} -System.exit(runner.succeeded() ? 0 : 1); -} catch (Exception e) { -e.printStackTrace(); -System.exit(1); +public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { +StoryRunner runner = new StoryRunner(); +for (int i = 0; i < args.length; i++) { +runner.run(args[i], System.out); } +System.exit(runner.succeeded() ? 0 : 1); } Modified: trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java (785 => 786) --- trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-15 17:17:30 UTC (rev 785) +++ trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-16 12:53:33 UTC (rev 786) @@ -43,21 +43,15 @@ outputStream.close(); } -public static void main(String[] args) throws ClassNotFoundException { +public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { File directory = new File(args[0]); -Thread.currentThread().getContextClassLoader().loadClass("com.sirenian.hellbound.stories.TheGlyphIsConstrainedByThePit"); - -try { -StoryToDirectoryPrinter printer = new StoryToDirectoryPrinter( -new StoryLoader(new TextStoryParser(), Thread.currentThread().getContextClassLoader()), -directory); - -for (int i = 1; i < args.length; i++) { -printer.print(args[i]); -} -} catch (Exception e) { -e.printStackTrace(); -//System.exit(1); -} + +StoryToDirectoryPrinter printer = new StoryToDirectoryPrinter( +new StoryLoader(new TextStoryParser(), Thread.currentThread().getContextClassLoader()), +directory); + +for (int i = 1; i < args.length; i++) { +printer.print(args[i]); +} } } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [785] trunk/core/src/java/org/jbehave/core/story: [ElizabethKeogh] Exit with error if exception encountered (so that the ant build fails if it can't print the stories for any reason)
Title: [785] trunk/core/src/java/org/jbehave/core/story: [ElizabethKeogh] Exit with error if exception encountered (so that the ant build fails if it can't print the stories for any reason) Revision 785 Author sirenian Date 2007-08-15 12:17:30 -0500 (Wed, 15 Aug 2007) Log Message [ElizabethKeogh] Exit with error if exception encountered (so that the ant build fails if it can't print the stories for any reason) Modified Paths trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java Diff Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (784 => 785) --- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-15 17:07:05 UTC (rev 784) +++ trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-15 17:17:30 UTC (rev 785) @@ -51,6 +51,7 @@ } } catch (Exception e) { e.printStackTrace(); +System.exit(1); } } } Modified: trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java (784 => 785) --- trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-15 17:07:05 UTC (rev 784) +++ trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-15 17:17:30 UTC (rev 785) @@ -57,6 +57,7 @@ } } catch (Exception e) { e.printStackTrace(); +//System.exit(1); } } } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [784] trunk: Fixed the story printing!
Title: [784] trunk: Fixed the story printing! Revision 784 Author sirenian Date 2007-08-15 12:07:05 -0500 (Wed, 15 Aug 2007) Log Message Fixed the story printing! Modified Paths trunk/build.xml trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryLoader.java trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java trunk/core/src/java/org/jbehave/core/story/StoryRunner.java trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story Diff Modified: trunk/build.xml (783 => 784) --- trunk/build.xml 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/build.xml 2007-08-15 17:07:05 UTC (rev 784) @@ -49,7 +49,7 @@ - + description="build the jbehave binary and zip up the project" /> @@ -242,7 +242,7 @@ - + Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java (783 => 784) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-08-15 17:07:05 UTC (rev 784) @@ -463,4 +463,10 @@ ensureThat(exception, isNotNull()); } +public void shouldAllowNameToBeSpecified() throws Exception { +Named scenario = new MultiStepScenario("My scenario"){ +protected void specifySteps() {}}; + +ensureThat(scenario.getName(), eq("My scenario")); +} } Modified: trunk/core/src/java/org/jbehave/core/story/StoryLoader.java (783 => 784) --- trunk/core/src/java/org/jbehave/core/story/StoryLoader.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/java/org/jbehave/core/story/StoryLoader.java 2007-08-15 17:07:05 UTC (rev 784) @@ -36,8 +36,12 @@ } public Story loadStory(Class storyClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException { -return (Story) classLoader.loadClass(storyClass.getName()).newInstance(); +return loadStoryClass(storyClass.getName()); } + +public Story loadStoryClass(String storyClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { +return (Story) classLoader.loadClass(storyClassName).newInstance(); +} protected Reader getReader(String resource, ClassLoader classLoader) { InputStream is = classLoader.getResourceAsStream(resource); Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (783 => 784) --- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-15 17:07:05 UTC (rev 784) @@ -29,8 +29,8 @@ this.renderer = renderer; } -public void print(String storyPath) throws MalformedURLException { -Story story = storyLoader.loadStory(storyPath); +public void print(String storyPath) throws MalformedURLException, InstantiationException, IllegalAccessException, ClassNotFoundException { +Story story = storyLoader.loadStoryClass(storyPath); story.specify(); story.narrateTo(renderer); } Modified: trunk/core/src/java/org/jbehave/core/story/StoryRunner.java (783 => 784) --- trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-08-15 17:07:05 UTC (rev 784) @@ -69,7 +69,8 @@ return (Story) classLoader.loadClass(className).newInstance(); } -public static void main(String[] args) { +public static void main(String[] args) throws ClassNotFoundException { +Thread.currentThread().getContextClassLoader().loadClass("com.sirenian.hellbound.stories.TheGlyphIsConstrainedByThePit"); try { StoryRunner runner = new StoryRunner(); for (int i = 0; i < args.length; i++) { Modified: trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java (783 => 784) --- trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java 2007-08-15 17:07:05 UTC (rev 784) @@ -29,7 +29,7 @@ private void print(String storyClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException { -Story story = loader.loadStory(storyClass); +Story story = loader.loadStoryClass(storyClass); String[] storyNameParts = story.getClass().getName().split("\\."
[jbehave-scm] [783] trunk/.classpath: [EK] Classpath for ant 1.7 (added sablecc too)
Title: [783] trunk/.classpath: [EK] Classpath for ant 1.7 (added sablecc too) Revision 783 Author sirenian Date 2007-08-15 07:16:28 -0500 (Wed, 15 Aug 2007) Log Message [EK] Classpath for ant 1.7 (added sablecc too) Modified Paths trunk/.classpath Diff Modified: trunk/.classpath (782 => 783) --- trunk/.classpath 2007-08-14 16:07:17 UTC (rev 782) +++ trunk/.classpath 2007-08-15 12:16:28 UTC (rev 783) @@ -1,38 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [782] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Fixed stories and behaviours in headless mode.
Title: [782] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Fixed stories and behaviours in headless mode. Revision 782 Author sirenian Date 2007-08-14 11:07:17 -0500 (Tue, 14 Aug 2007) Log Message [EK] Fixed stories and behaviours in headless mode. Modified Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/HellboundIsRunning.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/HeadlessChecker.java Diff Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/HellboundIsRunning.java (781 => 782) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/HellboundIsRunning.java 2007-08-14 07:36:24 UTC (rev 781) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/HellboundIsRunning.java 2007-08-14 16:07:17 UTC (rev 782) @@ -5,6 +5,7 @@ import org.jbehave.core.story.domain.CleansUpWorld; import org.jbehave.core.story.domain.World; import org.jbehave.threaded.swing.DefaultWindowWrapper; +import org.jbehave.threaded.swing.HeadlessChecker; import com.sirenian.hellbound.Hellbound; import com.sirenian.hellbound.engine.EngineQueue; @@ -52,7 +53,9 @@ public void cleanUp(World world) { Logger.debug(this, "tidyUp Given"); -Hellbound hellbound = (Hellbound) world.get(WorldKey.HELLBOUND); -hellbound.stopHellbound(); +if (!new HeadlessChecker().isHeadless()) { +Hellbound hellbound = (Hellbound) world.get(WorldKey.HELLBOUND); +hellbound.stopHellbound(); +} } } Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/HeadlessChecker.java (781 => 782) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/HeadlessChecker.java 2007-08-14 07:36:24 UTC (rev 781) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/HeadlessChecker.java 2007-08-14 16:07:17 UTC (rev 782) @@ -4,10 +4,14 @@ public class HeadlessChecker { -public void check() { -if ("true".equals(System.getProperty("java.awt.headless"))) { +public void check() throws PendingException { +if (isHeadless()) { throw new PendingException("Cannot verify behaviour when performing in headless mode."); } } +public boolean isHeadless() { +return "true".equals(System.getProperty("java.awt.headless")); +} + } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [781] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java: [EK] Adding the HeadlessChecker to the behaviours (how did these ever work?!)
Title: [781] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java: [EK] Adding the HeadlessChecker to the behaviours (how did these ever work?!) Revision 781 Author sirenian Date 2007-08-14 02:36:24 -0500 (Tue, 14 Aug 2007) Log Message [EK] Adding the HeadlessChecker to the behaviours (how did these ever work?!) Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java (780 => 781) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java 2007-08-12 11:45:51 UTC (rev 780) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java 2007-08-14 07:36:24 UTC (rev 781) @@ -8,6 +8,7 @@ import org.jbehave.core.mock.Matcher; import org.jbehave.core.mock.UsingMatchers; +import org.jbehave.threaded.swing.HeadlessChecker; import com.sirenian.hellbound.Hellbound; import com.sirenian.hellbound.domain.Segment; @@ -38,6 +39,7 @@ ); public void shouldBeScaledToFitThePit() { + new HeadlessChecker().check(); JFrame frame = new JFrame(); PitPanel panel = new PitPanel(SCALE, WIDTH, HEIGHT, Hellbound.COLORMAP); frame.getContentPane().add(panel); @@ -47,6 +49,7 @@ } public void shouldDrawGlyphsAndRepaintWithNoError() { + new HeadlessChecker().check(); final RenderedPit renderedPit = new RenderedPit(SCALE, WIDTH, HEIGHT, COLORMAP); @@ -63,6 +66,7 @@ } public void shouldCleanGlyphsAfterMovement() { + new HeadlessChecker().check(); RenderedPit renderedPit = new RenderedPit(SCALE, WIDTH, HEIGHT, COLORMAP); PitPanel panel = createPitPanelWithDoublePaint(renderedPit); @@ -81,6 +85,7 @@ } public void shouldNotCleanGlyphsOfOtherTypesAfterMovement() { + new HeadlessChecker().check(); RenderedPit renderedPit = new RenderedPit(SCALE, WIDTH, HEIGHT, COLORMAP); PitPanel panel = createPitPanelWithDoublePaint(renderedPit); @@ -97,6 +102,7 @@ } private JFrame createFrameAndDisplay(PitPanel panel) { + new HeadlessChecker().check(); JFrame frame = new JFrame(); frame.getContentPane().add(panel); frame.pack(); @@ -105,6 +111,7 @@ } private PitPanel createPitPanelWithDoublePaint(final RenderedPit pg) { + new HeadlessChecker().check(); PitPanel panel = new PitPanel(SCALE, WIDTH, HEIGHT, Hellbound.COLORMAP) { private static final long serialVersionUID = 1L; To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [780] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Moved the headless checker into DefaultWindowWrapper.
Title: [780] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Moved the headless checker into DefaultWindowWrapper. Revision 780 Author sirenian Date 2007-08-12 06:45:51 -0500 (Sun, 12 Aug 2007) Log Message [EK] Moved the headless checker into DefaultWindowWrapper. Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java (779 => 780) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-12 09:54:40 UTC (rev 779) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-12 11:45:51 UTC (rev 780) @@ -15,8 +15,6 @@ public class FrontPanelBehaviour extends UsingMiniMock { public void shouldContainTheButtonToStartTheGame() throws Exception { - new HeadlessChecker().check(); - WindowWrapper wrapper = new DefaultWindowWrapper("TestFrame"); Mock gameStarter = mock(GameRequestListener.class); Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java (779 => 780) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-08-12 09:54:40 UTC (rev 779) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-08-12 11:45:51 UTC (rev 780) @@ -37,6 +37,7 @@ } public DefaultWindowWrapper(String windowName, ComponentFinder finder) { + new HeadlessChecker().check(); this.windowName = windowName; this.finder = finder; sysQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [779] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java: [EK] Fixed front panel behaviour in headless mode.
Title: [779] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java: [EK] Fixed front panel behaviour in headless mode. Revision 779 Author sirenian Date 2007-08-12 04:54:40 -0500 (Sun, 12 Aug 2007) Log Message [EK] Fixed front panel behaviour in headless mode. Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java (778 => 779) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-11 07:55:48 UTC (rev 778) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-12 09:54:40 UTC (rev 779) @@ -7,6 +7,7 @@ import org.jbehave.core.minimock.UsingMiniMock; import org.jbehave.core.mock.Mock; import org.jbehave.threaded.swing.DefaultWindowWrapper; +import org.jbehave.threaded.swing.HeadlessChecker; import org.jbehave.threaded.swing.WindowWrapper; import com.sirenian.hellbound.domain.game.GameRequestListener; @@ -14,7 +15,8 @@ public class FrontPanelBehaviour extends UsingMiniMock { public void shouldContainTheButtonToStartTheGame() throws Exception { - + new HeadlessChecker().check(); + WindowWrapper wrapper = new DefaultWindowWrapper("TestFrame"); Mock gameStarter = mock(GameRequestListener.class); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [778] trunk: [EK] Moved up to ant 1.7, added clonevm to behaviour and story targets.
Title: [778] trunk: [EK] Moved up to ant 1.7, added clonevm to behaviour and story targets. Revision 778 Author sirenian Date 2007-08-11 02:55:48 -0500 (Sat, 11 Aug 2007) Log Message [EK] Moved up to ant 1.7, added clonevm to behaviour and story targets. Modified Paths trunk/build.xml trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java trunk/extensions/ant/src/java/org/jbehave/ant/StoryRunnerTask.java Added Paths trunk/lib/extensions/ant-1.7.0.jar Removed Paths trunk/lib/extensions/ant-1.6.5.jar Diff Modified: trunk/build.xml (777 => 778) --- trunk/build.xml 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/build.xml 2007-08-11 07:55:48 UTC (rev 778) @@ -10,7 +10,7 @@ - + @@ -49,7 +49,7 @@ - + description="build the jbehave binary and zip up the project" /> @@ -190,7 +190,7 @@ - + @@ -229,7 +229,7 @@ - + Modified: trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java (777 => 778) --- trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java 2007-08-11 07:55:48 UTC (rev 778) @@ -84,7 +84,19 @@ }); ensureThat(exception, isNotNull()); } + +public void shouldSupportCloningTheVm() throws Exception { +FileSet fileSet = new FileSet(); + +task.addBehaviours(fileSet); +task.setCloneVm(true); +task.execute(); +List list = Arrays.asList(runner.commandLineLog); +ensureThat(list, collectionContains(BehaviourClassOne.class.getName())); +ensureThat(list, collectionContains(BehaviourClassTwo.class.getName())); +} + private static class StubCommandRunner implements CommandRunner { private int valueToReturn; private Task taskLog; Modified: trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java (777 => 778) --- trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java 2007-08-11 07:55:48 UTC (rev 778) @@ -77,6 +77,19 @@ ensureThat(exception, isNotNull()); } +public void shouldSupportCloningTheVm() throws Exception { + +FileSet fileSet = new FileSet(); + +task.addStories(fileSet); +task.setCloneVm(true); +task.execute(); + +List list = Arrays.asList(runner.commandLineLog); +ensureThat(list, collectionContains(StoryClassOne.class.getName())); +ensureThat(list, collectionContains(StoryClassTwo.class.getName())); +} + private static class StubCommandRunner implements CommandRunner { private int valueToReturn; private Task taskLog; Modified: trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java (777 => 778) --- trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java 2007-08-11 07:55:48 UTC (rev 778) @@ -35,6 +35,8 @@ public Commandline.Argument createJvmarg() { return commandLine.createVmArgument(); } + + public void setMaxmemory(int megabyte) { createJvmarg().setLine("-Xmx" + megabyte + "m"); Modified: trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java (777 => 778) --- trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java 2007-08-11 07:55:48 UTC (rev 778) @@ -42,6 +42,9 @@ invoke(); } + public void setCloneVm(boolean cloneVm) { + commandLine.setCloneVm(cloneVm); + } private void appendAntTaskJar() { createClasspath().append(new Path(getProject(), locate())); Modified: trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java (777 => 778) --- trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java 2007-08-04 01:57:52 UTC (rev 777) +++ trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java 2007-08-11 07:55:48 UTC (rev 778) @@ -27,5 +27,9 @@ public void addBehaviours(FileSet fileset) { super.addFilesetTarget(fileset); } + +public void setCloneVm(boolean cloneVm) { +super.setCloneVm(cloneVm); +} } Modi
[jbehave-scm] [738] trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java: [EK] OutcomeUsingMiniMock was overriding Outcome, but missing the exception in the signature
Title: [738] trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java: [EK] OutcomeUsingMiniMock was overriding Outcome, but missing the exception in the signature Revision 738 Author sirenian Date 2007-06-16 03:48:51 -0500 (Sat, 16 Jun 2007) Log Message [EK] OutcomeUsingMiniMock was overriding Outcome, but missing the exception in the signature Modified Paths trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java Diff Modified: trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java (737 => 738) --- trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java 2007-06-11 00:56:32 UTC (rev 737) +++ trunk/core/src/java/org/jbehave/core/minimock/story/domain/OutcomeUsingMiniMock.java 2007-06-16 08:48:51 UTC (rev 738) @@ -21,7 +21,7 @@ * @author Dan North */ public abstract class OutcomeUsingMiniMock extends UsingMiniMock implements Outcome { -public abstract void verify(World world); + public void narrateTo(Renderer renderer) { renderer.renderOutcome(this); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [736] trunk/core/src/java/org/jbehave/core/story: [EK] Made it possible to override run() in a story and throw a PendingException without failing a build
Title: [736] trunk/core/src/java/org/jbehave/core/story: [EK] Made it possible to override run() in a story and throw a PendingException without failing a build Revision 736 Author sirenian Date 2007-05-28 14:54:06 -0500 (Mon, 28 May 2007) Log Message [EK] Made it possible to override run() in a story and throw a PendingException without failing a build Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryRunner.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java (735 => 736) --- trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java 2007-05-24 18:02:00 UTC (rev 735) +++ trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java 2007-05-28 19:54:06 UTC (rev 736) @@ -3,16 +3,16 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import org.jbehave.core.Block; import org.jbehave.core.Ensure; +import org.jbehave.core.exception.PendingException; import org.jbehave.core.listener.BehaviourListener; import org.jbehave.core.minimock.UsingMiniMock; import org.jbehave.core.mock.Mock; import org.jbehave.core.story.domain.Narrative; import org.jbehave.core.story.domain.Story; -import org.jbehave.core.story.domain.World; import org.jbehave.core.story.listener.PlainTextScenarioListener; import org.jbehave.core.story.renderer.Renderer; -import org.jbehave.core.story.result.ScenarioResult; public class StoryRunnerBehaviour extends UsingMiniMock { @@ -29,17 +29,31 @@ verifyMocks(); } + + public void shouldOutputPendingExeptionsWithoutFailingTheStory() throws Exception { + final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + final PrintStream stream = new PrintStream(buffer); + + Exception exception = runAndCatch(Exception.class, new Block() { + public void run() throws Exception { +new StoryRunner().run(PendingStory.class.getName(), stream); + } + }); + + Ensure.that(exception, isNull()); +Ensure.that(buffer.toString(), contains("P")); + Ensure.that(buffer.toString(), contains("Total: 1. Pending: 1.")); + + verifyMocks(); + } -public static class MyStory extends UsingMiniMock implements Story { +public static class PendingStory extends UsingMiniMock implements Story { private Mock mock; - public MyStory() { -ScenarioResult resultA = new ScenarioResult("scenarioA", "MyStory", ScenarioResult.SUCCEEDED); -ScenarioResult resultB = new ScenarioResult("scenarioB", "MyStory", ScenarioResult.SUCCEEDED); - + public PendingStory() { mock = mock(Story.class); mock.expects("addListener").with(isA(PlainTextScenarioListener.class)); - mock.expects("run").with(a(World.class)).will(returnValue(new ScenarioResult[] {resultA, resultB})); + mock.expects("run").will(throwException(new PendingException("TODO"))); } public Narrative narrative() { Modified: trunk/core/src/java/org/jbehave/core/story/StoryRunner.java (735 => 736) --- trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-05-24 18:02:00 UTC (rev 735) +++ trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-05-28 19:54:06 UTC (rev 736) @@ -9,8 +9,11 @@ import java.io.OutputStreamWriter; import java.io.PrintStream; +import org.jbehave.core.exception.PendingException; +import org.jbehave.core.result.Result; import org.jbehave.core.story.domain.Story; import org.jbehave.core.story.listener.PlainTextScenarioListener; +import org.jbehave.core.util.CamelCaseConverter; @@ -46,7 +49,14 @@ public void run(Story story, PrintStream printStream) { PlainTextScenarioListener listener = new PlainTextScenarioListener(new OutputStreamWriter(printStream)); story.addListener(listener); -story.run(); +try { + story.run(); +} catch (PendingException pe) { + listener.gotResult( + new Result("", + new CamelCaseConverter(story.getClass()).toPhrase(), + pe)); +} listener.printReport(); succeeded = succeeded && !listener.hasBehaviourFailures(); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [735] trunk/core/src/java/org/jbehave/core/mock: [EK] No point doing containsInOrder(...) with only one argument.
Title: [735] trunk/core/src/java/org/jbehave/core/mock: [EK] No point doing containsInOrder(...) with only one argument. Revision 735 Author sirenian Date 2007-05-24 13:02:00 -0500 (Thu, 24 May 2007) Log Message [EK] No point doing containsInOrder(...) with only one argument. Modified Paths trunk/core/src/java/org/jbehave/core/matchers/UsingArrayMatchers.java trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java Diff Modified: trunk/core/src/java/org/jbehave/core/matchers/UsingArrayMatchers.java (734 => 735) --- trunk/core/src/java/org/jbehave/core/matchers/UsingArrayMatchers.java 2007-05-24 17:43:38 UTC (rev 734) +++ trunk/core/src/java/org/jbehave/core/matchers/UsingArrayMatchers.java 2007-05-24 18:02:00 UTC (rev 735) @@ -152,10 +152,6 @@ return matchers; } -public static CustomMatcher containsInOrder(Object a) { -return containsInOrder(new Object[] {a}); -} - public static CustomMatcher containsInOrder(Object a, Object b) { return containsInOrder(new Object[] {a, b}); } @@ -168,10 +164,6 @@ return containsInOrder(allEq(objects)); } -public static CustomMatcher containsInOrder(Matcher a) { -return containsInOrder(new Matcher[] {a}); -} - public static CustomMatcher containsInOrder(Matcher a, Matcher b) { return containsInOrder(new Matcher[] {a, b}); } Modified: trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java (734 => 735) --- trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java 2007-05-24 17:43:38 UTC (rev 734) +++ trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java 2007-05-24 18:02:00 UTC (rev 735) @@ -154,10 +154,6 @@ return matchers; } - public static CustomMatcher containsInOrder(Object a) { - return containsInOrder(new Object[] {a}); - } - public static CustomMatcher containsInOrder(Object a, Object b) { return containsInOrder(new Object[] {a, b}); } @@ -169,10 +165,6 @@ public static CustomMatcher containsInOrder(Object[] objects) { return containsInOrder(allEq(objects)); } - - public static CustomMatcher containsInOrder(Matcher a) { - return containsInOrder(new Matcher[] {a}); - } public static CustomMatcher containsInOrder(Matcher a, Matcher b) { return containsInOrder(new Matcher[] {a, b}); Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (734 => 735) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-24 17:43:38 UTC (rev 734) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-24 18:02:00 UTC (rev 735) @@ -317,10 +317,6 @@ } -public CustomMatcher collectionContainingInOrder(Object a) { -return UsingCollectionMatchers.containsInOrder(a); -} - public CustomMatcher collectionContainingInOrder(Object a, Object b) { return UsingCollectionMatchers.containsInOrder(a, b); } @@ -337,10 +333,6 @@ return UsingCollectionMatchers.containsInOrder(objects); } -public CustomMatcher collectionContainingInOrder(Matcher a) { -return UsingCollectionMatchers.containsInOrder(a); -} - public CustomMatcher collectionContainingInOrder(Matcher a, Matcher b) { return UsingCollectionMatchers.containsInOrder(a, b); } @@ -414,11 +406,6 @@ return UsingArrayMatchers.containsOnly(a, b, c); } - -public CustomMatcher arrayContainingInOrder(Object a) { -return UsingArrayMatchers.containsInOrder(a); -} - public CustomMatcher arrayContainingInOrder(Object a, Object b) { return UsingArrayMatchers.containsInOrder(a, b); } @@ -435,10 +422,6 @@ return UsingArrayMatchers.containsInOrder(objects); } -public CustomMatcher arrayContainingInOrder(Matcher a) { -return UsingArrayMatchers.containsInOrder(a); -} - public CustomMatcher arrayContainingInOrder(Matcher a, Matcher b) { return UsingArrayMatchers.containsInOrder(a, b); } Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (734 => 735) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 17:43:38 UTC (rev 734) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 18:02:00 UTC (rev 735) @@ -4,8 +4,6 @@ import java.awt.Component; import java.awt.Container; import java.awt.EventQueue; -import java.awt.ItemSelectable; -import java.awt.TextComponent; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.KeyEvent; @@ -14,8 +12,6 @@ import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.Sw
[jbehave-scm] [734] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Fixed comboboxes!
Title: [734] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Fixed comboboxes! Revision 734 Author sirenian Date 2007-05-24 12:43:38 -0500 (Thu, 24 May 2007) Log Message [EK] Fixed comboboxes! Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (733 => 734) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-05-24 17:25:43 UTC (rev 733) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-05-24 17:43:38 UTC (rev 734) @@ -85,14 +85,29 @@ } public void shouldEnterTextIntoAComboBox() throws Exception { -shouldEnterTextIntoComboBox(false); +checkForHeadless(); +DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); + +try { +AFrame frame = new AFrame(); + +JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); +comboBox.setName("a.combobox"); +frame.getContentPane().setLayout(new FlowLayout()); +frame.getContentPane().add(comboBox); +frame.pack(); +frame.setVisible(true); + +wrapper.enterText("a.combobox", "cow"); + +ensureThat(comboBox.getSelectedItem(), eq("cow")); + +} finally { +wrapper.closeWindow(); +} } -//public void shouldEnterTextIntoAnEditableComboBox() throws Exception { -//shouldEnterTextIntoComboBox(true); -//} - -private void shouldEnterTextIntoComboBox(boolean editable) throws ComponentFinderException, TimeoutException { +public void shouldEnterTextIntoAnEditableComboBox() throws Exception { checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); @@ -101,7 +116,7 @@ JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); comboBox.setName("a.combobox"); -comboBox.setEditable(editable); +comboBox.setEditable(true); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(comboBox); frame.pack(); @@ -109,15 +124,14 @@ wrapper.enterText("a.combobox", "cow"); -ensureThat(comboBox.getSelectedItem(), eq("cow")); +ensureThat(comboBox.getEditor().getItem(), eq("cowhorse")); // because we didn't delete the previous value - } finally { wrapper.closeWindow(); } } - - public void shouldFindComponent() throws ComponentFinderException, TimeoutException { + +public void shouldFindComponent() throws ComponentFinderException, TimeoutException { checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (733 => 734) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 17:25:43 UTC (rev 733) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 17:43:38 UTC (rev 734) @@ -4,13 +4,18 @@ import java.awt.Component; import java.awt.Container; import java.awt.EventQueue; +import java.awt.ItemSelectable; +import java.awt.TextComponent; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.text.JTextComponent; import org.jbehave.core.threaded.TimeoutException; @@ -31,7 +36,15 @@ } public void typeIntoComponent(Component component, String text) { -QueueingKeyAdapter queuer = new QueueingKeyAdapter(component); +focuser.requestFocusOn(component); +QueueingAdapter queuer; + +if (component instanceof JComboBox && ((JComboBox)component).isEditable()) { +queuer = new QueueingKeyAdapter(((JComboBox)component).getEditor().getEditorComponent()); +} else { +queuer = new QueueingKeyAdapter(component); +} + try {
[jbehave-scm] [733] trunk/core/src/java/org/jbehave/core/threaded: [EK] Proper focus requesting when typing; using the QueueingAdapter for listening to typed event.
Title: [733] trunk/core/src/java/org/jbehave/core/threaded: [EK] Proper focus requesting when typing; using the QueueingAdapter for listening to typed event. Revision 733 Author sirenian Date 2007-05-24 12:25:43 -0500 (Thu, 24 May 2007) Log Message [EK] Proper focus requesting when typing; using the QueueingAdapter for listening to typed event. Modified Paths trunk/core/src/java/org/jbehave/core/threaded/QueuedObjectHolder.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/QueueingAdapter.java Diff Modified: trunk/core/src/java/org/jbehave/core/threaded/QueuedObjectHolder.java (732 => 733) --- trunk/core/src/java/org/jbehave/core/threaded/QueuedObjectHolder.java 2007-05-24 17:14:38 UTC (rev 732) +++ trunk/core/src/java/org/jbehave/core/threaded/QueuedObjectHolder.java 2007-05-24 17:25:43 UTC (rev 733) @@ -53,4 +53,10 @@ return object; } +public void clear() { +synchronized(waitingPlace) { +object = null; +} +} + } Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (732 => 733) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 17:14:38 UTC (rev 732) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-05-24 17:25:43 UTC (rev 733) @@ -6,14 +6,12 @@ import java.awt.EventQueue; import java.awt.Toolkit; import java.awt.Window; -import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import javax.swing.JComponent; import javax.swing.JFrame; -import org.jbehave.core.exception.PendingException; -import org.jbehave.core.threaded.QueuedObjectHolder; import org.jbehave.core.threaded.TimeoutException; /** @@ -21,15 +19,15 @@ */ class CharacterTyper { -private static final String TEXT_TYPING_UNSUPPORTED = "Text typing is not supported for your Swing library."; - private EventQueue sysQueue; private Idler idler; +private Focuser focuser; CharacterTyper() { sysQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); idler = new Idler(); +focuser = new Focuser(); } public void typeIntoComponent(Component component, String text) { @@ -40,7 +38,7 @@ queuer.waitForEvent(); } } finally { -queuer.removeSelf(); +queuer.removeSelfFromComponent(); } } @@ -55,9 +53,11 @@ Container contentPane = ((JFrame)window).getContentPane(); if (contentPane instanceof JComponent) { queuer = new QueueingKeyAdapter(contentPane); +focuser.requestFocusOn(contentPane); } } else { queuer = new QueueingKeyAdapter(window.getFocusOwner()); +focuser.requestFocusOn(window.getFocusOwner()); } postKeyEvent(window, key); @@ -65,7 +65,7 @@ try { queuer.waitForEvent(); } finally { -queuer.removeSelf(); +queuer.removeSelfFromComponent(); } } @@ -85,29 +85,30 @@ c); } -private class QueueingKeyAdapter extends KeyAdapter { -private QueuedObjectHolder holder = new QueuedObjectHolder(); -private final Component component; +private class QueueingKeyAdapter extends QueueingAdapter implements KeyListener { public QueueingKeyAdapter(Component component) { -this.component = component; -component.requestFocus(); -component.addKeyListener(this); +super(component, "KeyEvent"); } + public void keyTyped(KeyEvent e) { -holder.set(e); +eventOccurred(); } -public void waitForEvent() { -try { -holder.get(1000); -} catch (TimeoutException e) { -throw new PendingException(TEXT_TYPING_UNSUPPORTED); -} -idler.waitForIdle(); + +protected void addSelfToComponent() { +component.addKeyListener(this); } - -public void removeSelf() { +protected void removeSelfFromComponent() { component.removeKeyListener(this); } + +public void keyPressed(KeyEvent e) { +// TODO Auto-generated method stub + +} +public void keyReleased(KeyEvent e) { +// TODO Auto-generated method stub + +} } } Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/QueueingAdapter.java (732 => 733) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/QueueingAdapter.java 2007-05-24 17:14:38 UTC (rev 732) +++ trunk/extensio
[jbehave-scm] [732] trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java: [EK] Well, that works.
Title: [732] trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java: [EK] Well, that works. Revision 732 Author sirenian Date 2007-05-24 12:14:38 -0500 (Thu, 24 May 2007) Log Message [EK] Well, that works. Modified Paths trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java (731 => 732) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-05-24 17:13:26 UTC (rev 731) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-05-24 17:14:38 UTC (rev 732) @@ -29,6 +29,8 @@ private Idler idler; +private Focuser focuser; + public DefaultWindowWrapper(String windowName) { this(windowName, new ComponentFinder()); @@ -41,6 +43,7 @@ idler = new Idler(); typer = new CharacterTyper(); clicker = new ButtonClicker(); +focuser = new Focuser(); } public void closeWindow() throws TimeoutException { @@ -57,7 +60,7 @@ public void enterText(String componentName, String text) throws ComponentFinderException, TimeoutException { Component component = findComponent(componentName); - component.requestFocus(); + focuser.requestFocusOn(component); typer.typeIntoComponent(component, text); } @@ -112,7 +115,7 @@ } public void requestWindowFocus() throws TimeoutException { -getOpenWindow().requestFocus(); +focuser.requestFocusOn(getOpenWindow()); idler.waitForIdle(); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [731] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Focusing is event-driven too! This version only as broken as it already was, next step to fix it.
Title: [731] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Focusing is event-driven too! This version only as broken as it already was, next step to fix it. Revision 731 Author sirenian Date 2007-05-24 12:13:26 -0500 (Thu, 24 May 2007) Log Message [EK] Focusing is event-driven too! This version only as broken as it already was, next step to fix it. Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java Added Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/FocuserBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/Focuser.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/QueueingAdapter.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (730 => 731) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-05-23 12:48:52 UTC (rev 730) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-05-24 17:13:26 UTC (rev 731) @@ -7,6 +7,7 @@ import javax.swing.Action; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; @@ -77,10 +78,44 @@ ensureThat(textField.getText(), eq("Text1")); ensureThat(textArea.getText(), eq("Text2")); + } finally { wrapper.closeWindow(); } } + +public void shouldEnterTextIntoAComboBox() throws Exception { +shouldEnterTextIntoComboBox(false); +} + +//public void shouldEnterTextIntoAnEditableComboBox() throws Exception { +//shouldEnterTextIntoComboBox(true); +//} + +private void shouldEnterTextIntoComboBox(boolean editable) throws ComponentFinderException, TimeoutException { +checkForHeadless(); +DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); + +try { +AFrame frame = new AFrame(); + +JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); +comboBox.setName("a.combobox"); +comboBox.setEditable(editable); +frame.getContentPane().setLayout(new FlowLayout()); +frame.getContentPane().add(comboBox); +frame.pack(); +frame.setVisible(true); + +wrapper.enterText("a.combobox", "cow"); + +ensureThat(comboBox.getSelectedItem(), eq("cow")); + + +} finally { +wrapper.closeWindow(); +} +} public void shouldFindComponent() throws ComponentFinderException, TimeoutException { checkForHeadless(); @@ -164,7 +199,7 @@ new HeadlessChecker().check(); } -public class AFrame extends JFrame { +public static class AFrame extends JFrame { private static final String FRAME_NAME = "a.window"; private static final String ACTION_KEY = "AFrame.action"; @@ -182,4 +217,20 @@ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } } + +public static void main(String[] args) { +AFrame frame = new AFrame(); + +JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); +comboBox.setName("a.combobox"); +comboBox.setEditable(true); + +frame.getContentPane().setLayout(new FlowLayout()); + +frame.getContentPane().add(comboBox); +frame.pack(); + + +frame.setVisible(true); +} } Added: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/FocuserBehaviour.java (0 => 731) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/FocuserBehaviour.java (rev 0) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/FocuserBehaviour.java 2007-05-24 17:13:26 UTC (rev 731) @@ -0,0 +1,76 @@ +package org.jbehave.threaded.swing; + +import java.awt.FlowLayout; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import org.jbehave.core.mock.UsingMatchers; + +public class FocuserBehaviour extends UsingMatchers { + +public void shouldRequestFocusOnAComponent() { +checkForHeadless(); +Focuser focuser = new Focuser(); +AFrame frame = new AFrame(); + +try { + +JComboBox comboBox = new JComboBox(new Object[] {"horse", "cow", "sheep"}); +comboBox.setName("
[jbehave-scm] [730] trunk/extensions/junit/src/java/org/jbehave/junit: [EK] Included patch for JUnitAdapter; thank you very much Alexandre!
Title: [730] trunk/extensions/junit/src/java/org/jbehave/junit: [EK] Included patch for JUnitAdapter; thank you very much Alexandre! Revision 730 Author sirenian Date 2007-05-23 07:48:52 -0500 (Wed, 23 May 2007) Log Message [EK] Included patch for JUnitAdapter; thank you very much Alexandre! Modified Paths trunk/extensions/junit/src/behaviour/org/jbehave/junit/JUnitAdapterBehaviour.java trunk/extensions/junit/src/java/org/jbehave/junit/JUnitAdapter.java Diff Modified: trunk/extensions/junit/src/behaviour/org/jbehave/junit/JUnitAdapterBehaviour.java (729 => 730) --- trunk/extensions/junit/src/behaviour/org/jbehave/junit/JUnitAdapterBehaviour.java 2007-05-23 05:56:18 UTC (rev 729) +++ trunk/extensions/junit/src/behaviour/org/jbehave/junit/JUnitAdapterBehaviour.java 2007-05-23 12:48:52 UTC (rev 730) @@ -77,6 +77,42 @@ } } +public void shouldCountMultipleBehaviourMethodsAsTestsRecursively() { +// setup +JUnitAdapter.setBehaviours (new BehavioursWithOneBehavioursClass()); +Test suite = JUnitAdapter.suite(); +// execute +int testCaseCount = suite.countTestCases(); + +// verify +ensureThat(testCaseCount, eq(3)); +} + +public static class BehavioursWithOneBehavioursClass implements Behaviours { +public Class[] getBehaviours() { +return new Class[] { +new AnotherBehavioursWithOneBehavioursClass().getClass() +}; +} +} + +public static class AnotherBehavioursWithOneBehavioursClass implements Behaviours { +public Class[] getBehaviours() { +return new Class[] { +new BehavioursWithTwoBehaviourClasses().getClass() +}; +} +} + +public static class BehavioursWithTwoBehaviourClasses implements Behaviours { +public Class[] getBehaviours() { +return new Class[] { +HasTwoMethods.class, +HasSingleMethod.class +}; +} +} + public void shouldNotExecuteBehaviourMethodsWhileCountingThem() throws Exception { // setup JUnitAdapter.setBehaviours(new BehavioursAdapter(HasFailingMethod.class)); Modified: trunk/extensions/junit/src/java/org/jbehave/junit/JUnitAdapter.java (729 => 730) --- trunk/extensions/junit/src/java/org/jbehave/junit/JUnitAdapter.java 2007-05-23 05:56:18 UTC (rev 729) +++ trunk/extensions/junit/src/java/org/jbehave/junit/JUnitAdapter.java 2007-05-23 12:48:52 UTC (rev 730) @@ -89,10 +89,14 @@ } private static TestSuite createBehavioursTestSuite(Behaviours behaviours) { -TestSuite suite = new TestSuite(behaviours.toString()); -Class[] behaviourClasses = behaviours.getBehaviours(); -for ( int i = 0; i < behaviourClasses.length; i++ ){ -suite.addTest(createBehaviourTestSuite(new BehaviourClass(behaviourClasses[i]))); +TestSuite suite = new TestSuite(behaviours.toString()); +Class[] behaviourClasses = behaviours.getBehaviours (); +for ( int i = 0; i < behaviourClasses.length; i++ ) { +if (isBehavioursType(behaviourClasses[i])) { +suite.addTest(createBehavioursTestSuite((Behaviours)newInstance(behaviourClasses[i]))); +} else { +suite.addTest(createBehaviourTestSuite(new BehaviourClass(behaviourClasses[i]))); +} } return suite; } @@ -106,6 +110,18 @@ return suite; } + +private static boolean isBehavioursType(Class clazz) { +Class[] interfaces = clazz.getInterfaces(); +for ( int i = 0; i < interfaces.length; i++ ) { +if (interfaces[i].equals(Behaviours.class)) { +return true; +} +} +return false; +} + + private static Behaviours getBehaviours() { if ( behaviours != null ){ return behaviours; To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [729] trunk/core/src/java/org/jbehave/core/mock: [EK] Put Array and remaining Collection matchers into UsingMatchers
Title: [729] trunk/core/src/java/org/jbehave/core/mock: [EK] Put Array and remaining Collection matchers into UsingMatchers Revision 729 Author sirenian Date 2007-05-23 00:56:18 -0500 (Wed, 23 May 2007) Log Message [EK] Put Array and remaining Collection matchers into UsingMatchers Modified Paths trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java (728 => 729) --- trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java 2007-05-22 13:51:08 UTC (rev 728) +++ trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java 2007-05-23 05:56:18 UTC (rev 729) @@ -1,5 +1,8 @@ package org.jbehave.core.mock; +import java.util.Arrays; +import java.util.List; + import org.jbehave.core.Block; import org.jbehave.core.exception.PendingException; import org.jbehave.core.exception.VerificationException; @@ -39,5 +42,16 @@ } }); m.ensureThat(e, m.isNotNull()); + +String[] array = new String[]{"cow", "horse"}; +List list = Arrays.asList(array); + m.ensureThat(array, m.arrayContaining("cow")); + m.ensureThat(array, m.arrayContainingOnly("horse", "cow")); + m.ensureThat(array, m.arrayContainingInOrder("cow", "horse")); + m.ensureThat(list, m.collectionContaining("cow")); + m.ensureThat(list, m.collectionContainingOnly("horse", "cow")); + m.ensureThat(list, m.collectionContainingInOrder("cow", "horse")); + m.ensureThat(array, m.arrayContaining(m.endsWith("ow"))); + m.ensureThat(list, m.collectionContaining(m.startsWith("hor"))); } } Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (728 => 729) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-22 13:51:08 UTC (rev 728) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-23 05:56:18 UTC (rev 729) @@ -4,6 +4,7 @@ import org.jbehave.core.Block; import org.jbehave.core.Ensure; +import org.jbehave.core.matchers.UsingArrayMatchers; import org.jbehave.core.matchers.UsingCollectionMatchers; import org.jbehave.core.matchers.UsingEqualityMatchers; import org.jbehave.core.matchers.UsingExceptions; @@ -136,38 +137,6 @@ return UsingStringMatchers.contains(fragment); } -public CustomMatcher collectionContaining(Matcher[] matchers) { -return UsingCollectionMatchers.contains(matchers); -} - -public CustomMatcher collectionContaining(Object[] objects) { -return UsingCollectionMatchers.contains(objects); -} - -public CustomMatcher collectionContaining(Matcher a) { -return UsingCollectionMatchers.contains(a); -} - -public CustomMatcher collectionContaining(Matcher a, Matcher b) { -return UsingCollectionMatchers.contains(a, b); -} - -public CustomMatcher collectionContaining(Matcher a, Matcher b, Matcher c) { -return UsingCollectionMatchers.contains(a, b, c); -} - -public CustomMatcher collectionContaining(Object a) { -return UsingCollectionMatchers.contains(a); -} - -public CustomMatcher collectionContaining(Object a, Object b) { -return UsingCollectionMatchers.contains(a, b); -} - -public CustomMatcher collectionContaining(Object a, Object b, Object c) { -return UsingCollectionMatchers.contains(a, b, c); -} - public CustomMatcher and(Matcher a, Matcher b) { return UsingLogicalMatchers.and(a, b); } @@ -281,4 +250,200 @@ public void todo(String message) { UsingExceptions.todo(message); } + +public CustomMatcher collectionContaining(Matcher[] matchers) { +return UsingCollectionMatchers.contains(matchers); +} + +public CustomMatcher collectionContaining(Object[] objects) { +return UsingCollectionMatchers.contains(objects); +} + +public CustomMatcher collectionContaining(Matcher a) { +return UsingCollectionMatchers.contains(a); +} + +public CustomMatcher collectionContaining(Matcher a, Matcher b) { +return UsingCollectionMatchers.contains(a, b); +} + +public CustomMatcher collectionContaining(Matcher a, Matcher b, Matcher c) { +return UsingCollectionMatchers.contains(a, b, c); +} + +public CustomMatcher collectionContaining(Object a) { +return UsingCollectionMatchers.contains(a); +} + +public CustomMatcher collectionContaining(Object a, Object b) { +return UsingCollectionMatchers.contains(a, b); +} + +public CustomMatcher collectionContaining(Object a, Object b, Object c) { +return UsingCollectionMatchers.contains(a, b, c); +} +
[jbehave-scm] [728] trunk/core/src/java/org/jbehave/core: [EK] Added UsingArrayMatchers; still needs to be included in UsingMatchers.
Title: [728] trunk/core/src/java/org/jbehave/core: [EK] Added UsingArrayMatchers; still needs to be included in UsingMatchers. Revision 728 Author sirenian Date 2007-05-22 08:51:08 -0500 (Tue, 22 May 2007) Log Message [EK] Added UsingArrayMatchers; still needs to be included in UsingMatchers. Added 2.0 comment, uncommented some behaviours (oops). Modified Paths trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/Ensure.java Added Paths trunk/core/src/behaviour/org/jbehave/core/matchers/UsingArrayMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/matchers/UsingArrayMatchers.java Diff Added: trunk/core/src/behaviour/org/jbehave/core/matchers/UsingArrayMatchersBehaviour.java (0 => 728) --- trunk/core/src/behaviour/org/jbehave/core/matchers/UsingArrayMatchersBehaviour.java (rev 0) +++ trunk/core/src/behaviour/org/jbehave/core/matchers/UsingArrayMatchersBehaviour.java 2007-05-22 13:51:08 UTC (rev 728) @@ -0,0 +1,82 @@ +package org.jbehave.core.matchers; + +import org.jbehave.core.Ensure; +import org.jbehave.core.mock.Matcher; +import org.jbehave.core.mock.UsingMatchers.CustomMatcher; + +public class UsingArrayMatchersBehaviour { + +private Matcher eq(Object value) { + return UsingEqualityMatchers.eq(value); + } + + private Matcher not(Matcher matcher) { + return UsingLogicalMatchers.not(matcher); + } + +public void shouldProvideMatchersForCollectionsContainingAThing() { +Integer[] array = new Integer[] { Integer.valueOf(3) }; + +Ensure.that(array, UsingArrayMatchers.contains(Integer.valueOf(3))); +Ensure.that(array, UsingArrayMatchers.contains(eq(Integer.valueOf(3; + +Ensure.that(array, not(UsingArrayMatchers.contains(Integer.valueOf(5; +Ensure.that(array, UsingLogicalMatchers.not(UsingArrayMatchers.contains(eq(Integer.valueOf(5); +} + + public void shouldProvideMatchersForCollectionsContainingSomeThings() { +Integer[] array = new Integer[] { +Integer.valueOf(3), +Integer.valueOf(4), +Integer.valueOf(5)}; + + Ensure.that(array, UsingLogicalMatchers.not(UsingArrayMatchers.contains(Integer.valueOf(7; + Ensure.that(array, UsingArrayMatchers.contains(Integer.valueOf(3), Integer.valueOf(4))); + Ensure.that(array, UsingArrayMatchers.contains(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); +Ensure.that(array, UsingArrayMatchers.contains(new Object[] {Integer.valueOf(3)})); + + Ensure.that(array, not(UsingArrayMatchers.contains(eq(Integer.valueOf(7); + Ensure.that(array, UsingArrayMatchers.contains(eq(Integer.valueOf(3)), eq(Integer.valueOf(4; + Ensure.that(array, UsingArrayMatchers.contains(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; +Ensure.that(array, UsingArrayMatchers.contains(new Matcher[] {eq(Integer.valueOf(3))})); +} + + public void shouldProvideMatchersForCollectionsContainingOnlyThings() { +Integer[] array = new Integer[] { +Integer.valueOf(3), +Integer.valueOf(4), +Integer.valueOf(5)}; + + Ensure.that(array, UsingLogicalMatchers.not(UsingArrayMatchers.containsOnly(Integer.valueOf(3), Integer.valueOf(4; + Ensure.that(array, UsingArrayMatchers.containsOnly(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); + Ensure.that(array, UsingArrayMatchers.containsOnly(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; + } + + public void shouldProvideMatchersForCollectionsContainingThingsInOrder() { +Integer[] array = new Integer[] { +Integer.valueOf(3), +Integer.valueOf(4), +Integer.valueOf(5)}; + + Ensure.that(array, not(UsingArrayMatchers.containsInOrder(Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(4; + Ensure.that(array, UsingArrayMatchers.containsInOrder(Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5))); + } + +public void shouldDescribeMatchersForCollections() { +Integer[] array = new Integer[] { Integer.valueOf(5), Integer.valueOf(6)}; + +CustomMatcher contains = UsingArrayMatchers.contains(Integer.valueOf(4), Integer.valueOf(5)); +CustomMatcher containsOnly = UsingArrayMatchers.containsOnly(Integer.valueOf(4), Integer.valueOf(5)); +CustomMatcher containsInOrder = UsingArrayMatchers.containsInOrder(Integer.valueOf(4), Integer.valueOf(5)); + +// Describe what we expected +Ensure.that(contains.toString(), eq("an array containing [equal to <4>, equal to <5>]")); +Ensure.that(containsOnly.toString(), eq("an array containing [equal to <4>, equal to <5>] and nothing else")); +Ensure.that(containsInOrde
[jbehave-scm] [727] trunk/core/src/java/org/jbehave/core/mock: [EK] Finished Collection matchers; descriptions are now much better too.
Title: [727] trunk/core/src/java/org/jbehave/core/mock: [EK] Finished Collection matchers; descriptions are now much better too. Revision 727 Author sirenian Date 2007-05-20 12:55:12 -0500 (Sun, 20 May 2007) Log Message [EK] Finished Collection matchers; descriptions are now much better too. Added some TODOs for 2.0. Modified Paths trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java trunk/core/src/behaviour/org/jbehave/core/matchers/UsingLogicalMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java trunk/core/src/java/org/jbehave/core/matchers/UsingLogicalMatchers.java trunk/core/src/java/org/jbehave/core/mock/Matcher.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java (726 => 727) --- trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-17 18:12:12 UTC (rev 726) +++ trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-20 17:55:12 UTC (rev 727) @@ -6,85 +6,85 @@ import org.jbehave.core.exception.VerificationException; import org.jbehave.core.mock.Matcher; import org.jbehave.core.mock.UsingMatchers; +import org.jbehave.core.mock.UsingMatchers.CustomMatcher; public class UsingCollectionMatchersBehaviour { private static final String NL = System.getProperty("line.separator"); -private Matcher eq(Integer value) { +private Matcher eq(Object value) { return UsingEqualityMatchers.eq(value); } private Matcher not(Matcher matcher) { return UsingLogicalMatchers.not(matcher); } +// +//public void shouldProvideMatchersForCollectionsContainingAThing() { +//ArrayList list = new ArrayList(); +//list.add(Integer.valueOf(3)); +// +//Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3))); +//Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(3; +// +//Ensure.that(list, not(UsingCollectionMatchers.contains(Integer.valueOf(5; +//Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.contains(eq(Integer.valueOf(5); +//} +// +// public void shouldProvideMatchersForCollectionsContainingSomeThings() { +//ArrayList list = new ArrayList(); +//list.add(Integer.valueOf(3)); +//list.add(Integer.valueOf(4)); +//list.add(Integer.valueOf(5)); +// +// Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.contains(Integer.valueOf(7; +// Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3), Integer.valueOf(4))); +// Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); +//Ensure.that(list, UsingCollectionMatchers.contains(new Object[] {Integer.valueOf(3)})); +// +// Ensure.that(list, not(UsingCollectionMatchers.contains(eq(Integer.valueOf(7); +// Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(3)), eq(Integer.valueOf(4; +// Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; +//Ensure.that(list, UsingCollectionMatchers.contains(new Matcher[] {eq(Integer.valueOf(3))})); +//} +// +// public void shouldProvideMatchersForCollectionsContainingOnlyThings() { +//ArrayList list = new ArrayList(); +//list.add(Integer.valueOf(3)); +//list.add(Integer.valueOf(4)); +//list.add(Integer.valueOf(5)); +// +// Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.containsOnly(Integer.valueOf(3), Integer.valueOf(4; +// Ensure.that(list, UsingCollectionMatchers.containsOnly(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); +// Ensure.that(list, UsingCollectionMatchers.containsOnly(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; +// } +// +// public void shouldProvideMatchersForCollectionsContainingThingsInOrder() { +//ArrayList list = new ArrayList(); +//list.add(Integer.valueOf(3)); +//list.add(Integer.valueOf(4)); +//list.add(Integer.valueOf(5)); +// +// Ensure.that(list, not(UsingCollectionMatchers.containsInOrder(Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(4; +// Ensure.that(list, UsingCollectionMatchers.containsInOrder(Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5))); +// } -public void shouldProvideMatchersForCollectionsContainingAThing() { -ArrayList list = new ArrayList(); -list.add(Integer.valueOf(3)); - -Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3))); -Ensure.that(list, UsingCollectionMatchers.contains(eq(Inte
[jbehave-scm] [726] trunk/core/src/java/org/jbehave/core: [EK] Yet more collection constraints
Title: [726] trunk/core/src/java/org/jbehave/core: [EK] Yet more collection constraints Revision 726 Author sirenian Date 2007-05-17 13:12:12 -0500 (Thu, 17 May 2007) Log Message [EK] Yet more collection constraints Modified Paths trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/Ensure.java trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java (725 => 726) --- trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-14 19:58:06 UTC (rev 725) +++ trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-17 18:12:12 UTC (rev 726) @@ -22,11 +22,11 @@ ArrayList list = new ArrayList(); list.add(Integer.valueOf(3)); -Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3))); -Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(3; +Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3))); +Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(3; -Ensure.that(list, not(UsingCollectionMatchers.collectionContaining(Integer.valueOf(5; -Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(5); +Ensure.that(list, not(UsingCollectionMatchers.contains(Integer.valueOf(5; +Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.contains(eq(Integer.valueOf(5); } public void shouldProvideMatchersForCollectionsContainingSomeThings() { @@ -35,16 +35,27 @@ list.add(Integer.valueOf(4)); list.add(Integer.valueOf(5)); - Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(Integer.valueOf(7; - Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3), Integer.valueOf(4))); - Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); -Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Object[] {Integer.valueOf(3)})); + Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.contains(Integer.valueOf(7; + Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3), Integer.valueOf(4))); + Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); +Ensure.that(list, UsingCollectionMatchers.contains(new Object[] {Integer.valueOf(3)})); - Ensure.that(list, not(UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(7); - Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(3)), eq(Integer.valueOf(4; - Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; -Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Matcher[] {eq(Integer.valueOf(3))})); + Ensure.that(list, not(UsingCollectionMatchers.contains(eq(Integer.valueOf(7); + Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(3)), eq(Integer.valueOf(4; + Ensure.that(list, UsingCollectionMatchers.contains(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; +Ensure.that(list, UsingCollectionMatchers.contains(new Matcher[] {eq(Integer.valueOf(3))})); } + + public void shouldProvideMatchersForCollectionsContainingOnlyThings() { +ArrayList list = new ArrayList(); +list.add(Integer.valueOf(3)); +list.add(Integer.valueOf(4)); +list.add(Integer.valueOf(5)); + + Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.containsOnly(Integer.valueOf(3), Integer.valueOf(4; + Ensure.that(list, UsingCollectionMatchers.containsOnly(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); + Ensure.that(list, UsingCollectionMatchers.containsOnly(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; + } public void shouldDescribeMatchersForCollections() { UsingMatchers m = new UsingMatchers() {}; @@ -53,17 +64,27 @@ list.add(Integer.valueOf(5)); try { -Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3))); +Ensure.that(list, UsingCollectionMatchers.contains(Integer.valueOf(3))); +UsingExceptions.fail("Didn't throw exception"); } catch (VerificationException e) { -Ensure.that(e.getMessage(), UsingEqualityMat
[jbehave-scm] [725] trunk/core/src/java/org/jbehave/core/matchers: [EK] More collection constraints
Title: [725] trunk/core/src/java/org/jbehave/core/matchers: [EK] More collection constraints Revision 725 Author sirenian Date 2007-05-14 14:58:06 -0500 (Mon, 14 May 2007) Log Message [EK] More collection constraints Modified Paths trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/matchers/UsingCollectionMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java (724 => 725) --- trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-14 18:10:05 UTC (rev 724) +++ trunk/core/src/behaviour/org/jbehave/core/matchers/UsingCollectionMatchersBehaviour.java 2007-05-14 19:58:06 UTC (rev 725) @@ -4,38 +4,64 @@ import org.jbehave.core.Ensure; import org.jbehave.core.exception.VerificationException; +import org.jbehave.core.mock.Matcher; import org.jbehave.core.mock.UsingMatchers; public class UsingCollectionMatchersBehaviour { private static final String NL = System.getProperty("line.separator"); +private Matcher eq(Integer value) { + return UsingEqualityMatchers.eq(value); + } + + private Matcher not(Matcher matcher) { + return UsingLogicalMatchers.not(matcher); + } + public void shouldProvideMatchersForCollectionsContainingAThing() { ArrayList list = new ArrayList(); -list.add(new Integer(3)); +list.add(Integer.valueOf(3)); -Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Integer(3))); -Ensure.that(list, UsingCollectionMatchers.collectionContaining(UsingEqualityMatchers.eq(new Integer(3; +Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3))); +Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(3; -Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(new Integer(5; -Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(UsingEqualityMatchers.eq(new Integer(5); +Ensure.that(list, not(UsingCollectionMatchers.collectionContaining(Integer.valueOf(5; +Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(5); } + + public void shouldProvideMatchersForCollectionsContainingSomeThings() { +ArrayList list = new ArrayList(); +list.add(Integer.valueOf(3)); +list.add(Integer.valueOf(4)); +list.add(Integer.valueOf(5)); + + Ensure.that(list, UsingLogicalMatchers.not(UsingCollectionMatchers.collectionContaining(Integer.valueOf(7; + Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3), Integer.valueOf(4))); + Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(5), Integer.valueOf(4), Integer.valueOf(3))); +Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Object[] {Integer.valueOf(3)})); + + Ensure.that(list, not(UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(7); + Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(3)), eq(Integer.valueOf(4; + Ensure.that(list, UsingCollectionMatchers.collectionContaining(eq(Integer.valueOf(5)), eq(Integer.valueOf(4)), eq(Integer.valueOf(3; +Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Matcher[] {eq(Integer.valueOf(3))})); +} public void shouldDescribeMatchersForCollections() { UsingMatchers m = new UsingMatchers() {}; ArrayList list = new ArrayList(); -list.add(new Integer(5)); +list.add(Integer.valueOf(5)); try { -Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Integer(3))); +Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(3))); } catch (VerificationException e) { Ensure.that(e.getMessage(), UsingEqualityMatchers.eq("Expected: " + NL + "a collection containing [equal to <3>]" + NL + "but got: " + NL + "[5]")); } -list.add(new Integer(6)); +list.add(Integer.valueOf(6)); try { -Ensure.that(list, UsingCollectionMatchers.collectionContaining(new Integer(4), new Integer(5))); +Ensure.that(list, UsingCollectionMatchers.collectionContaining(Integer.valueOf(4), Integer.valueOf(5))); } catch (VerificationException e) { Ensure.that(e.getMessage(), UsingEqualityMatchers.eq("Expected: " + NL + "a collection containing [equal to <4>, equal to <5>]" + NL + "but got: " + NL + "[5, 6]")); } Modified: trunk/core/src/java/org/jbe
[jbehave-scm] [724] trunk/core/src/java/org/jbehave/core: [EK] Tidying up the latest Matchers stuff, removing the added CustomMatcher because it breaks the API
Title: [724] trunk/core/src/java/org/jbehave/core: [EK] Tidying up the latest Matchers stuff, removing the added CustomMatcher because it breaks the API Revision 724 Author sirenian Date 2007-05-14 13:10:05 -0500 (Mon, 14 May 2007) Log Message [EK] Tidying up the latest Matchers stuff, removing the added CustomMatcher because it breaks the API Modified Paths trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java trunk/core/src/java/org/jbehave/core/Ensure.java trunk/core/src/java/org/jbehave/core/matchers/UsingEqualityMatchers.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Removed Paths trunk/core/src/java/org/jbehave/core/matchers/CustomMatcher.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java (723 => 724) --- trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-05-05 12:22:57 UTC (rev 723) +++ trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-05-14 18:10:05 UTC (rev 724) @@ -13,18 +13,25 @@ import org.jbehave.core.behaviour.Behaviours; import org.jbehave.core.exception.JBehaveFrameworkErrorBehaviour; import org.jbehave.core.listener.PlainTextMethodListenerBehaviour; +import org.jbehave.core.matchers.UsingCollectionMatchersBehaviour; +import org.jbehave.core.matchers.UsingEqualityMatchersBehaviour; +import org.jbehave.core.matchers.UsingExceptionsBehaviour; +import org.jbehave.core.matchers.UsingLogicalMatchersBehaviour; +import org.jbehave.core.matchers.UsingStringMatchersBehaviour; import org.jbehave.core.minimock.MiniMockObjectBehaviour; import org.jbehave.core.minimock.UsingMiniMockBehaviour; import org.jbehave.core.mock.ExpectationBehaviour; import org.jbehave.core.mock.UsingMatchersBehaviour; import org.jbehave.core.result.ResultBehaviour; - - public class AllBehaviours implements Behaviours { public Class[] getBehaviours() { -return new Class[] { +return new Class[] {UsingCollectionMatchersBehaviour.class, +UsingEqualityMatchersBehaviour.class, +UsingLogicalMatchersBehaviour.class, +UsingExceptionsBehaviour.class, UsingMatchersBehaviour.class, +UsingStringMatchersBehaviour.class, BehaviourClassBehaviour.class, BehaviourMethodBehaviour.class, BehaviourVerifierBehaviour.class, @@ -35,7 +42,7 @@ ResultBehaviour.class, org.jbehave.core.story.AllBehaviours.class, org.jbehave.core.matchers.AllBehaviours.class, -JBehaveFrameworkErrorBehaviour.class +JBehaveFrameworkErrorBehaviour.class, }; } } Modified: trunk/core/src/java/org/jbehave/core/Ensure.java (723 => 724) --- trunk/core/src/java/org/jbehave/core/Ensure.java 2007-05-05 12:22:57 UTC (rev 723) +++ trunk/core/src/java/org/jbehave/core/Ensure.java 2007-05-14 18:10:05 UTC (rev 724) @@ -7,15 +7,11 @@ */ package org.jbehave.core; -import org.jbehave.core.exception.PendingException; -import org.jbehave.core.exception.VerificationException; import org.jbehave.core.matchers.UsingEqualityMatchers; import org.jbehave.core.matchers.UsingExceptions; import org.jbehave.core.mock.Matcher; -import org.jbehave.core.mock.UsingMatchers; import org.jbehave.core.mock.UsingMatchers.CustomMatcher; - /** * @author Dan North * @author Damian Guy Deleted: trunk/core/src/java/org/jbehave/core/matchers/CustomMatcher.java (723 => 724) --- trunk/core/src/java/org/jbehave/core/matchers/CustomMatcher.java 2007-05-05 12:22:57 UTC (rev 723) +++ trunk/core/src/java/org/jbehave/core/matchers/CustomMatcher.java 2007-05-14 18:10:05 UTC (rev 724) @@ -1,12 +0,0 @@ -package org.jbehave.core.matchers; - -import org.jbehave.core.mock.Matcher; -import org.jbehave.core.mock.UsingMatchers; - -public abstract class CustomMatcher extends UsingMatchers.CustomMatcher implements Matcher { - -public CustomMatcher(String description) { -super(description); -} - -} Modified: trunk/core/src/java/org/jbehave/core/matchers/UsingEqualityMatchers.java (723 => 724) --- trunk/core/src/java/org/jbehave/core/matchers/UsingEqualityMatchers.java 2007-05-05 12:22:57 UTC (rev 723) +++ trunk/core/src/java/org/jbehave/core/matchers/UsingEqualityMatchers.java 2007-05-14 18:10:05 UTC (rev 724) @@ -1,6 +1,6 @@ package org.jbehave.core.matchers; -import org.jbehave.core.matchers.CustomMatcher; +import org.jbehave.core.mock.UsingMatchers.CustomMatcher; public class UsingEqualityMatchers { Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (723 => 724) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-05 12:22:57 UTC (rev 723) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-05-14 18:10:05 UTC (rev 724) @@ -34,9 +34,6 @@ */ public abstract class UsingMatchers { -private static final String NL = System.getProperty(
[jbehave-scm] [723] trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java: [EK] Added a 'SLOW' property which will slow down the Hellbound stories - good for demos
Title: [723] trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java: [EK] Added a 'SLOW' property which will slow down the Hellbound stories - good for demos Revision 723 Author sirenian Date 2007-05-05 07:22:57 -0500 (Sat, 05 May 2007) Log Message [EK] Added a 'SLOW' property which will slow down the Hellbound stories - good for demos Modified Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java Diff Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java (722 => 723) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java 2007-05-02 17:42:04 UTC (rev 722) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/ForcedHeartbeat.java 2007-05-05 12:22:57 UTC (rev 723) @@ -30,6 +30,15 @@ } public void causeBeat() { + if (System.getProperty("SLOW") != null) { + synchronized(this) { +try { + wait(700); +} catch (InterruptedException e) { + e.printStackTrace(); +} + } + } listeners.notifyListeners(pulse); skipped = false; } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [721] trunk/core/src/java/org/jbehave/core: [EK] Finished splitting UsingMatchers into composed classes
Title: [721] trunk/core/src/java/org/jbehave/core: [EK] Finished splitting UsingMatchers into composed classes Revision 721 Author sirenian Date 2007-04-17 07:35:59 -0500 (Tue, 17 Apr 2007) Log Message [EK] Finished splitting UsingMatchers into composed classes Modified Paths trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/Ensure.java trunk/core/src/java/org/jbehave/core/matchers/CustomMatcher.java trunk/core/src/java/org/jbehave/core/matchers/UsingEqualityMatchers.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java (720 => 721) --- trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java 2007-04-13 17:24:43 UTC (rev 720) +++ trunk/core/src/behaviour/org/jbehave/core/mock/UsingMatchersBehaviour.java 2007-04-17 12:35:59 UTC (rev 721) @@ -1,11 +1,43 @@ package org.jbehave.core.mock; -import org.jbehave.core.matchers.UsingExceptions; +import org.jbehave.core.Block; +import org.jbehave.core.exception.PendingException; +import org.jbehave.core.exception.VerificationException; + public class UsingMatchersBehaviour { -public void shouldDelegateCorrectlyAndNotThrowAnyStackOverflowErrors() { -UsingExceptions.todo(); -} - +public void shouldDelegateCorrectlyAndNotThrowAnyStackOverflowErrors() throws Exception { +final UsingMatchers m = new UsingMatchers(){}; +Object obj = new Object(); + +m.ensureThat(true); +m.ensureThat(true, "works with a message"); +m.ensureThat(false, m.eq(false)); +m.ensureThat('a', m.eq('a')); +m.ensureThat(1.0, m.eq(1.0)); +m.ensureThat(1L, m.eq(1L)); +m.ensureThat(obj, m.is(obj)); +m.ensureThat(false, m.not(m.eq(true)), "works with a message"); +m.ensureThat('c', m.eq('a').or(m.eq('c')), "works with a message"); +m.ensureThat(1.5, m.eq(1.5), "works with a message"); +m.ensureThat(3L, m.and(m.eq(3L), m.isA(Long.class)), "works with a message"); +m.ensureThat(new Double(4.3), m.isA(Double.class), "works with a message"); +m.ensureThat(null, m.isNull()); +m.ensureThat(obj, m.not(m.nothing())); + +Exception e = m.runAndCatch(VerificationException.class, new Block() { + public void run() throws Exception { +m.fail("Oops!"); + } +}); +m.ensureThat(e, m.isNotNull()); + +e = m.runAndCatch(PendingException.class, new Block() { + public void run() throws Exception { +m.todo(); + } +}); +m.ensureThat(e, m.isNotNull()); +} } Modified: trunk/core/src/java/org/jbehave/core/Ensure.java (720 => 721) --- trunk/core/src/java/org/jbehave/core/Ensure.java 2007-04-13 17:24:43 UTC (rev 720) +++ trunk/core/src/java/org/jbehave/core/Ensure.java 2007-04-17 12:35:59 UTC (rev 721) @@ -9,8 +9,11 @@ import org.jbehave.core.exception.PendingException; import org.jbehave.core.exception.VerificationException; +import org.jbehave.core.matchers.UsingEqualityMatchers; +import org.jbehave.core.matchers.UsingExceptions; import org.jbehave.core.mock.Matcher; import org.jbehave.core.mock.UsingMatchers; +import org.jbehave.core.mock.UsingMatchers.CustomMatcher; /** @@ -20,186 +23,184 @@ * @author Steve Freeman */ public class Ensure { - private static final UsingMatchers matchers = new UsingMatchers() {}; + private static final String NL = System.getProperty("line.separator"); /** should not be subclassed for behaviour classes but can be extended to add methods to namespace */ protected Ensure() {} /** Ensure.that(something, isBlah()) */ public static void that(Object arg, Matcher matcher) { - matchers.ensureThat(arg, matcher); + that(arg, matcher, null); } -public static void that(Object arg, Matcher matcher, String message) { - matchers.ensureThat(arg, matcher, message); + + public static void that(Object arg, Matcher matcher, String message) { + if (!matcher.matches(arg)) { + UsingExceptions.fail("Expected: " + +(message != null ? "[" + message + "] " : "") + NL + +matcher + NL + +"but got: " + NL + arg); + } } + +public static void that(Object arg, CustomMatcher matcher, String message) { + if (!matcher.matches(arg)) { + UsingExceptions.fail("Expected: " + +(message != null ? "[" + message + "] ": "") + NL + +matcher + NL + +"but got: " + NL + matcher.describe(arg)); +} + } public static void that(long arg, Matcher matcher) { - matchers.ensureThat(ar
[jbehave-scm] [719] trunk/core/src/java/org/jbehave/core/mock: [EK] Started creating some Collection matchers.
Title: [719] trunk/core/src/java/org/jbehave/core/mock: [EK] Started creating some Collection matchers. Revision 719 Author sirenian Date 2007-04-11 12:58:28 -0500 (Wed, 11 Apr 2007) Log Message [EK] Started creating some Collection matchers. Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (718 => 719) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-04-01 10:28:19 UTC (rev 718) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-04-11 17:58:28 UTC (rev 719) @@ -1,9 +1,14 @@ package org.jbehave.core; +import java.util.ArrayList; + +import org.jbehave.core.exception.VerificationException; import org.jbehave.core.mock.UsingMatchers; public class UsingMatchersBehaviour { +private static final String NL = System.getProperty("line.separator"); + Block EXCEPTION_BLOCK = new Block() { public void run() throws Exception { throw new NumberFormatException(); @@ -118,4 +123,38 @@ Ensure.that(horse, m.and(m.eq(horse), m.contains("ors"))); Ensure.that(cow, m.both(m.eq(cow), m.endsWith("ow"))); } + +public void shouldProvideMatchersForCollectionsContainingAThing() { +UsingMatchers m = new UsingMatchers() {}; + +ArrayList list = new ArrayList(); +list.add(new Integer(3)); + +Ensure.that(list, m.collectionContaining(new Integer(3))); +Ensure.that(list, m.collectionContaining(m.eq(new Integer(3; + +Ensure.that(list, m.not(m.collectionContaining(new Integer(5; +Ensure.that(list, m.not(m.collectionContaining(m.eq(new Integer(5); +} + +public void shouldDescribeMatchersForCollections() { +UsingMatchers m = new UsingMatchers() {}; + +ArrayList list = new ArrayList(); +list.add(new Integer(5)); + +try { +Ensure.that(list, m.collectionContaining(new Integer(3))); +} catch (VerificationException e) { +Ensure.that(e.getMessage(), m.eq("Expected: " + NL + "a collection containing [equal to <3>]" + NL + "but got: " + NL + "[5]")); +} + +list.add(new Integer(6)); + +try { +Ensure.that(list, m.collectionContaining(new Integer(4), new Integer(5))); +} catch (VerificationException e) { +Ensure.that(e.getMessage(), m.eq("Expected: " + NL + "a collection containing [equal to <4>, equal to <5>]" + NL + "but got: " + NL + "[5, 6]")); +} +} } Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (718 => 719) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-04-01 10:28:19 UTC (rev 718) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-04-11 17:58:28 UTC (rev 719) @@ -1,6 +1,8 @@ package org.jbehave.core.mock; +import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import org.jbehave.core.Block; import org.jbehave.core.exception.PendingException; @@ -29,6 +31,9 @@ * [EMAIL PROTECTED] org.jbehave.core.minimock.UsingMiniMock} than to UsingMatchers. */ public abstract class UsingMatchers { + +private static final String NL = System.getProperty("line.separator"); + public abstract static class CustomMatcher extends UsingMatchers implements Matcher { private final String description; @@ -43,9 +48,14 @@ public CustomMatcher and(Matcher that) { return and(this, that); } + public CustomMatcher or(Matcher that) { return or(this, that); } + +public String describe(Object arg) { +return "" + arg; +} } /** ensures object is not null */ @@ -184,7 +194,70 @@ } }; } + +public CustomMatcher collectionContaining(final CustomMatcher[] matchers) { +if (matchers.length == 0) { +return collectionContaining(nothing()); +} + + +CustomMatcher matcher = collectionContainingA(matchers[0]); +for (int i = 1; i < matchers.length; i++) { +matcher = matchers[i].and(collectionContainingA(matcher)); +} + +final CustomMatcher finalMatcher = matcher; + +return new CustomMatcher(""){ +public boolean matches(Object arg) { +return finalMatcher.matches(arg); +} +public String describe(Object arg) { +Collection collection = (Collection) arg; +StringBuffer buffer = new StringBuffer().append(&quo
[jbehave-scm] [712] trunk/core/src/behaviour/org/jbehave/core: [EK] Fixed null pointer exception on null Throwable with JBehaveFrameworkError.java; removed automatic stacktrace from one constructor.
Title: [712] trunk/core/src/behaviour/org/jbehave/core: [EK] Fixed null pointer exception on null Throwable with JBehaveFrameworkError.java; removed automatic stacktrace from one constructor. Revision 712 Author sirenian Date 2007-03-23 09:22:27 -0500 (Fri, 23 Mar 2007) Log Message [EK] Fixed null pointer exception on null Throwable with JBehaveFrameworkError.java; removed automatic stacktrace from one constructor. Modified Paths trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java trunk/core/src/java/org/jbehave/core/exception/JBehaveFrameworkError.java Added Paths trunk/core/src/behaviour/org/jbehave/core/exception/ trunk/core/src/behaviour/org/jbehave/core/exception/JBehaveFrameworkErrorBehaviour.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java (711 => 712) --- trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-03-23 12:16:04 UTC (rev 711) +++ trunk/core/src/behaviour/org/jbehave/core/AllBehaviours.java 2007-03-23 14:22:27 UTC (rev 712) @@ -11,6 +11,7 @@ import org.jbehave.core.behaviour.BehaviourMethodBehaviour; import org.jbehave.core.behaviour.BehaviourVerifierBehaviour; import org.jbehave.core.behaviour.Behaviours; +import org.jbehave.core.exception.JBehaveFrameworkErrorBehaviour; import org.jbehave.core.listener.PlainTextMethodListenerBehaviour; import org.jbehave.core.minimock.MiniMockObjectBehaviour; import org.jbehave.core.minimock.UsingMiniMockBehaviour; @@ -31,7 +32,8 @@ UsingMiniMockBehaviour.class, ExpectationBehaviour.class, ResultBehaviour.class, -org.jbehave.core.story.AllBehaviours.class +org.jbehave.core.story.AllBehaviours.class, +JBehaveFrameworkErrorBehaviour.class }; } } Added: trunk/core/src/behaviour/org/jbehave/core/exception/JBehaveFrameworkErrorBehaviour.java (0 => 712) --- trunk/core/src/behaviour/org/jbehave/core/exception/JBehaveFrameworkErrorBehaviour.java (rev 0) +++ trunk/core/src/behaviour/org/jbehave/core/exception/JBehaveFrameworkErrorBehaviour.java 2007-03-23 14:22:27 UTC (rev 712) @@ -0,0 +1,70 @@ +package org.jbehave.core.exception; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.jbehave.core.Block; +import org.jbehave.core.mock.UsingMatchers; + +public class JBehaveFrameworkErrorBehaviour extends UsingMatchers { + + +public void shouldIncludeTheStackTraceOfCausingError() { +ByteArrayOutputStream bufferForError = new ByteArrayOutputStream(); +PrintStream streamForError = new PrintStream(bufferForError); + +ByteArrayOutputStream bufferForOther = new ByteArrayOutputStream(); +PrintStream streamForOther = new PrintStream(bufferForOther); + +IllegalArgumentException cause = new IllegalArgumentException(); +JBehaveFrameworkError error = new JBehaveFrameworkError(cause); + +cause.printStackTrace(streamForOther); +error.printStackTrace(streamForError); + +ensureThat(bufferForError, contains(JBehaveFrameworkError.class.getName())); +ensureThat(bufferForError.toString(), contains(bufferForOther.toString())); +} + +public void shouldPrintAStackTraceWithoutErrorsIfOnlyMessageProvided() { +ByteArrayOutputStream bufferForError = new ByteArrayOutputStream(); +PrintStream streamForError = new PrintStream(bufferForError); + +ByteArrayOutputStream bufferForOther = new ByteArrayOutputStream(); +PrintStream streamForOther = new PrintStream(bufferForOther); + +Error errorWithExpectedStackTrace = new Error("A message"); +JBehaveFrameworkError error = new JBehaveFrameworkError("A message"); + +errorWithExpectedStackTrace.printStackTrace(streamForOther); +error.printStackTrace(streamForError); + +ensureThat(bufferForError, contains(JBehaveFrameworkError.class.getName())); +ensureThat(bufferForError.toString(), contains("A message")); +} + +public void shouldPrintAStackTraceWithoutErrorsOrMessageIfNoneProvided() { +ByteArrayOutputStream bufferForError = new ByteArrayOutputStream(); +PrintStream streamForError = new PrintStream(bufferForError); + +JBehaveFrameworkError error = new JBehaveFrameworkError(); + +error.printStackTrace(streamForError); + +ensureThat(bufferForError, contains(JBehaveFrameworkError.class.getName())); +} + +public void shouldCopeWithNullArguments() throws Exception { +final PrintStream aStream = new PrintStream(new ByteArrayOutputStream()); + +Exception exception = runAndCatch(Exception.class, new Block() { +public void run() throws Exception { +new JBehaveFrameworkError(null, null).printStackTrace(aStream); +
[jbehave-scm] [710] trunk/core/src/behaviour/org/jbehave/core: [EK] Last matcher behaviours, added World key caveat to javadocs (happy Dan?)
Title: [710] trunk/core/src/behaviour/org/jbehave/core: [EK] Last matcher behaviours, added World key caveat to javadocs (happy Dan?) Revision 710 Author sirenian Date 2007-03-22 09:58:24 -0500 (Thu, 22 Mar 2007) Log Message [EK] Last matcher behaviours, added World key caveat to javadocs (happy Dan?) Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/story/domain/World.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (709 => 710) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 14:09:30 UTC (rev 709) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 14:58:24 UTC (rev 710) @@ -9,8 +9,7 @@ throw new NumberFormatException(); } }; - - + Block EMPTY_BLOCK = new Block() { public void run() throws Exception {} }; @@ -89,14 +88,14 @@ Ensure.that(exception, m.isNotNull()); } -public void shouldReturnNullIfNoExceptionThrown() throws Exception { +public void shouldCatchAndReturnNullIfNoExceptionThrown() throws Exception { UsingMatchers m = new UsingMatchers() {}; Exception exception = m.runAndCatch(IllegalArgumentException.class, EMPTY_BLOCK); Ensure.that(exception, m.isNull()); } -public void shouldPropagateExceptionOfAnUnexpectedType() throws Exception { +public void shouldCatchAndRethrowExceptionOfAnUnexpectedType() throws Exception { UsingMatchers m = new UsingMatchers() {}; try { Modified: trunk/core/src/java/org/jbehave/core/story/domain/World.java (709 => 710) --- trunk/core/src/java/org/jbehave/core/story/domain/World.java 2007-03-22 14:09:30 UTC (rev 709) +++ trunk/core/src/java/org/jbehave/core/story/domain/World.java 2007-03-22 14:58:24 UTC (rev 710) @@ -18,6 +18,10 @@ * The methods on this interface are a legacy of JBehave 1.0. * We might remove them from the interface at some point. * + * World keys should work as HashMap keys, ie: they should + * be immutable and their hashCode() should play nice with their + * equals(). + * * @see HashMapWorld, CustomWorld, Given, CleansUpWorld */ public interface World { To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [709] trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java: [EK] And a couple more missing behaviours.
Title: [709] trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java: [EK] And a couple more missing behaviours. Revision 709 Author sirenian Date 2007-03-22 09:09:30 -0500 (Thu, 22 Mar 2007) Log Message [EK] And a couple more missing behaviours. Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (708 => 709) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 14:06:33 UTC (rev 708) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 14:09:30 UTC (rev 709) @@ -107,10 +107,16 @@ } } -public void shouldProvideMatchersForOneOrAnotherCondition() throws Exception { +public void shouldProvideConditionalMatchers() throws Exception { UsingMatchers m = new UsingMatchers() {}; -Ensure.that(true, m.or(m.eq(true), m.eq(false))); -Ensure.that(false, m.either(m.eq(true), m.eq(false))); +String horse = "horse"; +String cow = "cow"; + +Ensure.that(horse, m.or(m.eq(horse), m.eq(cow))); +Ensure.that(cow, m.either(m.eq(horse), m.eq(cow))); + +Ensure.that(horse, m.and(m.eq(horse), m.contains("ors"))); +Ensure.that(cow, m.both(m.eq(cow), m.endsWith("ow"))); } } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [708] trunk/core/src/java/org/jbehave/core/mock: [EK] Added some missing UserMatchersBehaviours.
Title: [708] trunk/core/src/java/org/jbehave/core/mock: [EK] Added some missing UserMatchersBehaviours. Revision 708 Author sirenian Date 2007-03-22 09:06:33 -0500 (Thu, 22 Mar 2007) Log Message [EK] Added some missing UserMatchersBehaviours. And gained a better understanding of how anything() ( and therefore nothing() ) should work as a result. Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (707 => 708) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 13:34:12 UTC (rev 707) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 14:06:33 UTC (rev 708) @@ -43,12 +43,45 @@ Ensure.that(true, m.eq(true), "message"); } -public void shouldProvideMatcherToCheckForNull() { +public void shouldProvideMatchersToCheckForNull() { UsingMatchers m = new UsingMatchers() {}; Ensure.that(null, m.isNull()); +Ensure.that(new Object(), m.not(m.isNull())); Ensure.that(new Object(), m.isNotNull()); +Ensure.that(null, m.not(m.isNotNull())); } + +public void shouldProvideMatchersToCheckForAnything() { +UsingMatchers m = new UsingMatchers() {}; +Ensure.that(null, m.not(m.nothing())); +Ensure.that(new Object(), m.not(m.nothing())); +Ensure.that(new Object(), m.anything()); +Ensure.that(null, m.anything()); +} + +public void shouldProvideCommonStringMatchers() { +UsingMatchers m = new UsingMatchers() {}; + +Ensure.that("octopus", m.contains("top")); +Ensure.that("octopus", m.not(m.contains("eight"))); +Ensure.that("octopus", m.startsWith("octo")); +Ensure.that("octopus", m.not(m.startsWith("eight"))); +Ensure.that("octopus", m.endsWith("pus")); +Ensure.that("octopus", m.not(m.endsWith("eight"))); +} +public void shouldProvideInstanceMatchers() { +UsingMatchers m = new UsingMatchers() {}; + +String a = "a"; +String b = "b"; + +Ensure.that(a, m.is(a)); +Ensure.that(a, m.not(m.is(b))); +Ensure.that(a, m.sameInstanceAs(a)); +Ensure.that(a, m.not(m.sameInstanceAs(b))); +} + public void shouldCatchAndReturnAThrownException() throws Exception { UsingMatchers m = new UsingMatchers() {}; Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (707 => 708) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-03-22 13:34:12 UTC (rev 707) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-03-22 14:06:33 UTC (rev 708) @@ -142,7 +142,11 @@ } public CustomMatcher nothing() { -return isNull(); +return new CustomMatcher("nothing") { +public boolean matches(Object arg) { +return false; +} +}; } public CustomMatcher a(final Class type) { To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [707] trunk/core/src/java/org/jbehave/core/mock: [EK] TimeoutException no longer dependent on extensions; SwingBehaviourException deleted as no longer used by anything.
Title: [707] trunk/core/src/java/org/jbehave/core/mock: [EK] TimeoutException no longer dependent on extensions; SwingBehaviourException deleted as no longer used by anything. Revision 707 Author sirenian Date 2007-03-22 08:34:12 -0500 (Thu, 22 Mar 2007) Log Message [EK] TimeoutException no longer dependent on extensions; SwingBehaviourException deleted as no longer used by anything. Fixed recursive bug with UsingMatchers.either(). Added "this story isn't functional" javadoc to UserWithdrawsCash. Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java trunk/core/src/java/org/jbehave/core/threaded/TimeoutException.java trunk/examples/atm/src/stories/example/atm/stories/UserWithdrawsCash.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/ComponentFinderException.java Removed Paths trunk/extensions/swing/src/java/org/jbehave/threaded/swing/SwingBehaviourException.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (706 => 707) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-21 13:55:36 UTC (rev 706) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-03-22 13:34:12 UTC (rev 707) @@ -73,4 +73,11 @@ // expected } } + +public void shouldProvideMatchersForOneOrAnotherCondition() throws Exception { +UsingMatchers m = new UsingMatchers() {}; + +Ensure.that(true, m.or(m.eq(true), m.eq(false))); +Ensure.that(false, m.either(m.eq(true), m.eq(false))); +} } Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (706 => 707) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-03-21 13:55:36 UTC (rev 706) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-03-22 13:34:12 UTC (rev 707) @@ -140,6 +140,10 @@ } }; } + +public CustomMatcher nothing() { +return isNull(); +} public CustomMatcher a(final Class type) { return isA(type); @@ -198,7 +202,7 @@ } public CustomMatcher either(final Matcher a, final Matcher b) { - return either(a, b); + return or(a, b); } public CustomMatcher not(final Matcher c) { Modified: trunk/core/src/java/org/jbehave/core/threaded/TimeoutException.java (706 => 707) --- trunk/core/src/java/org/jbehave/core/threaded/TimeoutException.java 2007-03-21 13:55:36 UTC (rev 706) +++ trunk/core/src/java/org/jbehave/core/threaded/TimeoutException.java 2007-03-22 13:34:12 UTC (rev 707) @@ -1,9 +1,7 @@ package org.jbehave.core.threaded; -import org.jbehave.threaded.swing.SwingBehaviourException; +public class TimeoutException extends Exception { -public class TimeoutException extends SwingBehaviourException { - - private static final long serialVersionUID = 5776693901561603819L; - +private static final long serialVersionUID = 2L; + } Modified: trunk/examples/atm/src/stories/example/atm/stories/UserWithdrawsCash.java (706 => 707) --- trunk/examples/atm/src/stories/example/atm/stories/UserWithdrawsCash.java 2007-03-21 13:55:36 UTC (rev 706) +++ trunk/examples/atm/src/stories/example/atm/stories/UserWithdrawsCash.java 2007-03-22 13:34:12 UTC (rev 707) @@ -17,6 +17,10 @@ import example.atm.scenarios.OverdrawnWithoutPermission; /** + * This story is not functional. It's a good example to use with the + * StoryPrinter. If you want a functional story, look at the + * Hellbound examples instead. + * * @author Dan North */ public class UserWithdrawsCash extends ScenarioDrivenStory { Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java (706 => 707) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java 2007-03-21 13:55:36 UTC (rev 706) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java 2007-03-22 13:34:12 UTC (rev 707) @@ -2,7 +2,8 @@ import org.jbehave.core.minimock.story.domain.EventUsingMiniMock; import org.jbehave.core.story.domain.World; -import org.jbehave.threaded.swing.SwingBehaviourException; +import org.jbehave.core.threaded.TimeoutException; +import org.jbehave.threaded.swing.ComponentFinderException; import org.jbehave.threaded.swing.WindowWrapper; import com.sirenian.hellbound.stories.util.Idler; @@ -29,25 +30,27 @@ WindowWrapper wrapper = (WindowWrapper) world.get(WorldKey.WINDOW_WRAPPER, null); try { wrapper.clickButton(buttonName); - } catch (SwingBehaviourException e) { + } catch (ComponentFinderException e) { throw new RuntimeException(e); - } + } catch (TimeoutException e) { + throw new RuntimeException(e); +} } protected void pressKey(int keycode, Worl
[jbehave-scm] [706] trunk/core/src/java/org/jbehave/core/story/domain: [EK] The whole given(World) thing leads to some really, really messy code, so I'm taking it out.
Title: [706] trunk/core/src/java/org/jbehave/core/story/domain: [EK] The whole given(World) thing leads to some really, really messy code, so I'm taking it out. Revision 706 Author sirenian Date 2007-03-21 08:55:36 -0500 (Wed, 21 Mar 2007) Log Message [EK] The whole given(World) thing leads to some really, really messy code, so I'm taking it out. We can override createWorld in the story and actually that's enough. Added throws Exception to each of the ScenarioComponents, and improved the javadoc on things like World. Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/domain/EventStepBehaviour.java trunk/core/src/behaviour/org/jbehave/core/story/domain/GivenStepBehaviour.java trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java trunk/core/src/behaviour/org/jbehave/core/story/domain/OutcomeStepBehaviour.java trunk/core/src/java/org/jbehave/core/story/domain/AbstractStep.java trunk/core/src/java/org/jbehave/core/story/domain/CustomWorld.java trunk/core/src/java/org/jbehave/core/story/domain/Event.java trunk/core/src/java/org/jbehave/core/story/domain/EventStep.java trunk/core/src/java/org/jbehave/core/story/domain/Given.java trunk/core/src/java/org/jbehave/core/story/domain/GivenStep.java trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java trunk/core/src/java/org/jbehave/core/story/domain/Outcome.java trunk/core/src/java/org/jbehave/core/story/domain/OutcomeStep.java trunk/core/src/java/org/jbehave/core/story/domain/Step.java trunk/core/src/java/org/jbehave/core/story/domain/World.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/EventStepBehaviour.java (705 => 706) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/EventStepBehaviour.java 2007-03-20 16:25:34 UTC (rev 705) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/EventStepBehaviour.java 2007-03-21 13:55:36 UTC (rev 706) @@ -4,7 +4,7 @@ import org.jbehave.core.mock.Mock; public class EventStepBehaviour extends UsingMiniMock { -public void shouldTellEventToOccurInWorld() { +public void shouldTellEventToOccurInWorld() throws Exception { // given Mock event = mock(Event.class); EventStep step = new EventStep((Event)event); Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/GivenStepBehaviour.java (705 => 706) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/GivenStepBehaviour.java 2007-03-20 16:25:34 UTC (rev 705) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/GivenStepBehaviour.java 2007-03-21 13:55:36 UTC (rev 706) @@ -4,7 +4,7 @@ import org.jbehave.core.mock.Mock; public class GivenStepBehaviour extends UsingMiniMock { -public void shouldTellGivenToSetUpWorld() { +public void shouldTellGivenToSetUpWorld() throws Exception { // given Mock given = mock(Given.class); GivenStep step = new GivenStep((Given)given); Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java (705 => 706) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-03-20 16:25:34 UTC (rev 705) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-03-21 13:55:36 UTC (rev 706) @@ -7,7 +7,11 @@ import org.jbehave.core.story.renderer.Renderer; public class MultiStepScenarioBehaviour extends UsingMiniMock { - + +public interface GivenWithCleanUp extends Given, CleansUpWorld {} +public interface OutcomeWithCleanUp extends Outcome, CleansUpWorld {} +public interface GivenWorld extends Given, CleansUpWorld, World {} + public void shouldPerformGiven() throws Exception { // given final Mock given = mock(Given.class); @@ -98,10 +102,8 @@ // then verifyMocks(); } - -public interface GivenWithCleanUp extends Given, CleansUpWorld {} -public interface OutcomeWithCleanUp extends Outcome, CleansUpWorld {} + public void shouldTellStepsToCleanUpWorldInReverseOrder() throws Exception { // given final Mock given = mock(GivenWithCleanUp.class); @@ -343,6 +345,45 @@ ensureThat(exception, isNotNull()); } +public void shouldRethrowExceptionsInStepsAsVerificationExceptions() throws Exception { +final Mock given = mock(GivenWithCleanUp.class, "given"); +given.expects("setUp").will(throwException(new Exception())); + +final Scenario scenario = new MultiStepScenario(){ +public void specifySteps() { +given((Given) given); +}}; + +Exception exception = runAndCatch(VerificationException.class, new Block() { +public void run() throws Exception { +scenario.specify(); +scenario.run((World)stub(World.class)); +} +}); +
[jbehave-scm] [705] trunk/core/src/java/org/jbehave/core/story: [EK] Fixed bug which caused StoryRunnerTask to always fail the build (doh!).
Title: [705] trunk/core/src/java/org/jbehave/core/story: [EK] Fixed bug which caused StoryRunnerTask to always fail the build (doh!). Revision 705 Author sirenian Date 2007-03-20 11:25:34 -0500 (Tue, 20 Mar 2007) Log Message [EK] Fixed bug which caused StoryRunnerTask to always fail the build (doh!). Made World able to take Object keys. Added ability to run in a custom World per scenario, using given(World). Added a CustomWorld class which can be overridden to do this. Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryRunner.java trunk/core/src/java/org/jbehave/core/story/domain/HashMapWorld.java trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java trunk/core/src/java/org/jbehave/core/story/domain/World.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java Added Paths trunk/core/src/java/org/jbehave/core/story/domain/CustomWorld.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java (704 => 705) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-03-14 11:51:31 UTC (rev 704) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-03-20 16:25:34 UTC (rev 705) @@ -422,4 +422,32 @@ ensureThat(exception, isNotNull()); } + +public void shouldPerformStepsInSpecifiedWorldIfGivenWorld() { +final Mock world = mock(World.class); +final Mock given = mock(Given.class); +final Mock event = mock(Event.class); +final Mock outcome = mock(Outcome.class); + +Scenario scenario = new MultiStepScenario() { +public void specifySteps() { +given((World)world); +given((Given)given); +when((Event)event); +then((Outcome)outcome); +} +}; +scenario.specify(); + +// expect +given.expects("setUp").with(world); +event.expects("occurIn").with(world).after(given, "setUp"); +outcome.expects("verify").with(world).after(event, "occurIn"); + +// when +scenario.run(new HashMapWorld()); + +// then +verifyMocks(); +} } Modified: trunk/core/src/java/org/jbehave/core/story/StoryRunner.java (704 => 705) --- trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-03-14 11:51:31 UTC (rev 704) +++ trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-03-20 16:25:34 UTC (rev 705) @@ -22,7 +22,7 @@ public class StoryRunner { private ClassLoader classLoader; -private boolean succeeded; +private boolean succeeded = true; public StoryRunner(){ this(Thread.currentThread().getContextClassLoader()); Added: trunk/core/src/java/org/jbehave/core/story/domain/CustomWorld.java (0 => 705) --- trunk/core/src/java/org/jbehave/core/story/domain/CustomWorld.java (rev 0) +++ trunk/core/src/java/org/jbehave/core/story/domain/CustomWorld.java 2007-03-20 16:25:34 UTC (rev 705) @@ -0,0 +1,33 @@ +package org.jbehave.core.story.domain; + +/** + * This class is provided for convenience for those who would like + * to define their own world with its own accessors. Every + * method throws an UnsupportedOperationException unless explicitly + * overridden by subclasses (in which case you should probably be + * extending HashMapWorld instead). This means that it's easy for you to + * create your own world without getting it mixed up with JBehave's + * default implementation (the HashMapWorld). + * + * It's not as pretty as we'd like, but we'd like to support the + * old ways of doing things too. + */ +public abstract class CustomWorld implements World { + +public void clear() throws UnsupportedOperationException { +throw new UnsupportedOperationException(); +} + +public Object get(Object key, Object defaultValue) throws UnsupportedOperationException { +throw new UnsupportedOperationException(); +} + +public Object get(Object key) throws UnsupportedOperationException { +throw new UnsupportedOperationException(); +} + +public void put(Object key, Object value) throws UnsupportedOperationException { +throw new UnsupportedOperationException(); +} + +} Modified: trunk/core/src/java/org/jbehave/core/story/domain/HashMapWorld.java (704 => 705) --- trunk/core/src/java/org/jbehave/core/story/domain/HashMapWorld.java 2007-03-14 11:51:31 UTC (rev 704) +++ trunk/core/src/java/org/jbehave/core/story/domain/HashMapWorld.java 2007-03-20 16:25:34 UTC (rev 705) @@ -16,18 +16,18 @@ public class HashMapWorld implements World { private final Map map = new HashMap();
[jbehave-scm] [704] trunk/cruise_config.rb: [EK] Added cruise_config.rb because the CC.rb guys are kindly hosting our build
Title: [704] trunk/cruise_config.rb: [EK] Added cruise_config.rb because the CC.rb guys are kindly hosting our build Revision 704 Author sirenian Date 2007-03-14 06:51:31 -0500 (Wed, 14 Mar 2007) Log Message [EK] Added cruise_config.rb because the CC.rb guys are kindly hosting our build Added Paths trunk/cruise_config.rb Diff Added: trunk/cruise_config.rb (0 => 704) --- trunk/cruise_config.rb (rev 0) +++ trunk/cruise_config.rb 2007-03-14 11:51:31 UTC (rev 704) @@ -0,0 +1,4 @@ +Project.configure do |project| + project.build_command = "ant" + project.email_notifier.emails = ["dev@jbehave.codehaus.org"] +end \ No newline at end of file To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [703] trunk/build.xml: [EK] Added clonevm property to java behaviour verification target.
Title: [703] trunk/build.xml: [EK] Added clonevm property to java behaviour verification target. Revision 703 Author sirenian Date 2007-03-12 13:17:44 -0500 (Mon, 12 Mar 2007) Log Message [EK] Added clonevm property to java behaviour verification target. Modified Paths trunk/build.xml Diff Modified: trunk/build.xml (702 => 703) --- trunk/build.xml 2007-03-11 05:09:56 UTC (rev 702) +++ trunk/build.xml 2007-03-12 18:17:44 UTC (rev 703) @@ -104,7 +104,7 @@ - + To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [698] trunk/plugins/eclipse/eclipse-site: [EK DN] Moved eclipse plugin to 1.0.0
Title: [698] trunk/plugins/eclipse/eclipse-site: [EK DN] Moved eclipse plugin to 1.0.0 Revision 698 Author sirenian Date 2007-03-07 15:51:19 -0600 (Wed, 07 Mar 2007) Log Message [EK DN] Moved eclipse plugin to 1.0.0 Modified Paths trunk/plugins/eclipse/eclipse-site/site.xml trunk/plugins/eclipse/org.jbehave.plugin.eclipse/META-INF/MANIFEST.MF trunk/plugins/eclipse/org.jbehave.plugin.eclipse.feature/feature.xml Property Changed trunk/plugins/eclipse/org.jbehave.plugin.eclipse.test/ Diff Modified: trunk/plugins/eclipse/eclipse-site/site.xml (697 => 698) --- trunk/plugins/eclipse/eclipse-site/site.xml 2007-03-07 19:21:42 UTC (rev 697) +++ trunk/plugins/eclipse/eclipse-site/site.xml 2007-03-07 21:51:19 UTC (rev 698) @@ -1,10 +1,10 @@ - JBehave plugin + JBehave for Eclipse - - + + - + Modified: trunk/plugins/eclipse/org.jbehave.plugin.eclipse/META-INF/MANIFEST.MF (697 => 698) --- trunk/plugins/eclipse/org.jbehave.plugin.eclipse/META-INF/MANIFEST.MF 2007-03-07 19:21:42 UTC (rev 697) +++ trunk/plugins/eclipse/org.jbehave.plugin.eclipse/META-INF/MANIFEST.MF 2007-03-07 21:51:19 UTC (rev 698) @@ -1,8 +1,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: JBehave Plugin +Bundle-Name: JBehave for Eclipse Bundle-SymbolicName: org.jbehave.plugin.eclipse;singleton:=true -Bundle-Version: 0.9.1 +Bundle-Version: 1.0.0 Bundle-Activator: org.jbehave.plugin.eclipse.JBehavePlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, @@ -26,3 +26,4 @@ Bundle-Vendor: JBehave Bundle-ClassPath: eclipse-plugin.jar Export-Package: org.jbehave.plugin.eclipse +Bundle-RequiredExecutionEnvironment: J2SE-1.4 Modified: trunk/plugins/eclipse/org.jbehave.plugin.eclipse.feature/feature.xml (697 => 698) --- trunk/plugins/eclipse/org.jbehave.plugin.eclipse.feature/feature.xml 2007-03-07 19:21:42 UTC (rev 697) +++ trunk/plugins/eclipse/org.jbehave.plugin.eclipse.feature/feature.xml 2007-03-07 21:51:19 UTC (rev 698) @@ -1,45 +1,54 @@ - label="JBehave Feature" - version="0.9.1"> + label="JBehave for Eclipse" + version="1.0.0" + provider-name="JBehave" + os="linux,macosx,win32" + ws="gtk,motif,win32" + nl="en_GB,en" + arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64"> - + - Copyright © 2003-2006 jbehave.org + Copyright © 2003-2007 jbehave.org -All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. -Neither the name of JBehave nor the names of its contributors -may be used to endorse or promote products derived from this -software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT -NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. +Neither the name of JBehave nor the names of its contributors +may be used to endorse or promote products derived from this +software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT,
[jbehave-scm] [696] trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java: [EK] Java 5 Collections.emptyList() -> 1.4 new ArrayList
Title: [696] trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java: [EK] Java 5 Collections.emptyList() -> 1.4 new ArrayList() Revision 696 Author sirenian Date 2007-03-07 13:03:17 -0600 (Wed, 07 Mar 2007) Log Message [EK] Java 5 Collections.emptyList() -> 1.4 new ArrayList() Modified Paths trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java Diff Modified: trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java (695 => 696) --- trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java 2007-03-07 14:30:01 UTC (rev 695) +++ trunk/plugins/eclipse/org.jbehave.plugin.eclipse/src/main/java/org/jbehave/plugin/eclipse/VerificationLaunchShortcut.java 2007-03-07 19:03:17 UTC (rev 696) @@ -86,7 +86,7 @@ private ILaunchConfiguration findLaunchConfiguration(String mode, ConfigurationState state, String container, String name) throws LaunchCancelledByUserException { ILaunchConfigurationType configType= getJBehaveLaunchConfigType(); - List candidateConfigs = Collections.emptyList(); + List candidateConfigs = new ArrayList(); try { ILaunchConfiguration[] configs= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType); candidateConfigs = new ArrayList(configs.length); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [695] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java: [EK] Oops.
Title: [695] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java: [EK] Oops. Revision 695 Author sirenian Date 2007-03-07 08:30:01 -0600 (Wed, 07 Mar 2007) Log Message [EK] Oops. Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java (694 => 695) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2007-03-07 14:28:17 UTC (rev 694) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2007-03-07 14:30:01 UTC (rev 695) @@ -44,7 +44,7 @@ public void shouldDisplayTheFrontPanelWhenTheGameIsReady() { frame.reportGameStateChanged(GameState.READY); - ensureThat(!frontPanel.isShowing()); + ensureThat(frontPanel.isShowing()); ensureThat(!gamePanel.isShowing()); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [694] trunk/core/src/java/org/jbehave/core/story: [EK] StoryRunner now fails a build.
Title: [694] trunk/core/src/java/org/jbehave/core/story: [EK] StoryRunner now fails a build. Revision 694 Author sirenian Date 2007-03-07 08:28:17 -0600 (Wed, 07 Mar 2007) Log Message [EK] StoryRunner now fails a build. Modified Paths trunk/core/src/java/org/jbehave/core/story/StoryRunner.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java Diff Modified: trunk/core/src/java/org/jbehave/core/story/StoryRunner.java (693 => 694) --- trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-03-04 15:52:39 UTC (rev 693) +++ trunk/core/src/java/org/jbehave/core/story/StoryRunner.java 2007-03-07 14:28:17 UTC (rev 694) @@ -22,6 +22,7 @@ public class StoryRunner { private ClassLoader classLoader; +private boolean succeeded; public StoryRunner(){ this(Thread.currentThread().getContextClassLoader()); @@ -47,8 +48,13 @@ story.addListener(listener); story.run(); listener.printReport(); +succeeded = succeeded && !listener.hasBehaviourFailures(); } +private boolean succeeded() { +return succeeded; +} + private Story loadStory(String className, ClassLoader classLoader) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (Story) classLoader.loadClass(className).newInstance(); } @@ -59,10 +65,14 @@ for (int i = 0; i < args.length; i++) { runner.run(args[i], System.out); } +System.exit(runner.succeeded() ? 0 : 1); } catch (Exception e) { e.printStackTrace(); +System.exit(1); } } + + } Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java (693 => 694) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2007-03-04 15:52:39 UTC (rev 693) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2007-03-07 14:28:17 UTC (rev 694) @@ -44,7 +44,7 @@ public void shouldDisplayTheFrontPanelWhenTheGameIsReady() { frame.reportGameStateChanged(GameState.READY); - ensureThat(frontPanel.isShowing()); + ensureThat(!frontPanel.isShowing()); ensureThat(!gamePanel.isShowing()); } Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java (693 => 694) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java 2007-03-04 15:52:39 UTC (rev 693) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java 2007-03-07 14:28:17 UTC (rev 694) @@ -117,7 +117,7 @@ return panel; } -public Matcher contains(final Segments segments, final Color color) { +private Matcher contains(final Segments segments, final Color color) { return new Matcher() { public boolean matches(Object arg) { return ((RenderedPit)arg).contains(segments, color); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [693] trunk: [EK] Fixed StoryPrinter
Title: [693] trunk: [EK] Fixed StoryPrinter Revision 693 Author sirenian Date 2007-03-04 09:52:39 -0600 (Sun, 04 Mar 2007) Log Message [EK] Fixed StoryPrinter Added StoryPrinterBehaviour to AllStories Put main method back on StoryPrinter Created task to output stories to a directory. Modified Paths trunk/build.xml trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/FailingStoryClass.java trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehavioursClassLoader.java Added Paths trunk/core/src/behaviour/org/jbehave/core/story/FileWhichExists trunk/core/src/behaviour/org/jbehave/core/story/StoryToDirectoryPrinterBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java trunk/extensions/ant/src/java/org/jbehave/ant/StoryPrinterTask.java Diff Modified: trunk/build.xml (692 => 693) --- trunk/build.xml 2007-02-26 18:13:24 UTC (rev 692) +++ trunk/build.xml 2007-03-04 15:52:39 UTC (rev 693) @@ -42,6 +42,7 @@ + @@ -188,15 +189,15 @@ - - + + - + @@ -226,9 +227,9 @@ - - - + + + @@ -236,8 +237,19 @@ - + - + + + + + + + + + + + + Modified: trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java (692 => 693) --- trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java 2007-02-26 18:13:24 UTC (rev 692) +++ trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java 2007-03-04 15:52:39 UTC (rev 693) @@ -29,6 +29,8 @@ return new Class[] { StoryBuilderBehaviour.class, StoryRunnerBehaviour.class, +StoryPrinterBehaviour.class, +StoryToDirectoryPrinterBehaviour.class, TextStoryParserBehaviour.class, GivenStepBehaviour.class, GivenScenarioBehaviour.class, Added: trunk/core/src/behaviour/org/jbehave/core/story/FileWhichExists ( => ) Modified: trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java === --- trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java 2007-02-26 18:13:24 UTC (rev 692) +++ trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java 2007-03-04 15:52:39 UTC (rev 693) @@ -16,7 +16,7 @@ StoryPrinter printer = new StoryPrinter( new StoryLoader(new TextStoryParser(), Thread.currentThread().getContextClassLoader()), -new PlainTextRenderer(System.out)); +new PlainTextRenderer(printStream)); printer.print(SimpleStory.class.getName()); String result = byteStream.toString(); Added: trunk/core/src/behaviour/org/jbehave/core/story/StoryToDirectoryPrinterBehaviour.java (0 => 693) --- trunk/core/src/behaviour/org/jbehave/core/story/StoryToDirectoryPrinterBehaviour.java (rev 0) +++ trunk/core/src/behaviour/org/jbehave/core/story/StoryToDirectoryPrinterBehaviour.java 2007-03-04 15:52:39 UTC (rev 693) @@ -0,0 +1,37 @@ +package org.jbehave.core.story; + +import java.io.File; + +import org.jbehave.core.Block; +import org.jbehave.core.mock.UsingMatchers; + +public class StoryToDirectoryPrinterBehaviour extends UsingMatchers { + +public void shouldThrowIllegalArgumentExceptionIfDirectoryDoesNotExist() throws Exception { +Exception exception = runAndCatch(IllegalArgumentException.class, new Block() { +public void run() throws Exception { +new StoryToDirectoryPrinter(null, new File("FileWhichDoesNotExist")); +} +}); + +ensureThat(exception, isNotNull()); +} + + +public void shouldThrowIllegalArgumentExceptionIfFileIsNotDirectory() throws Exception { +Exception exception = runAndCatch(IllegalArgumentException.class, new Block() { +public void run() throws Exception { +new StoryToDirectoryPrinter(null, new File("FileWhichExists")); +} +}); + +ensureThat(exception, isNotNull()); +} + +public void shouldUseStoryPrinterToOutputStoriesByNameToDirectory() { +// No way of describing this behaviour yet without creating a number of files, +// which I don't want to do. If you change the StoryToDirectoryPrinter, +// please describe this behaviour or at least make sure that the +// print-example-stories task works. +} +} Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (692 => 693) --- tr
[jbehave-scm] [688] trunk: [EK] Removed Cotta, fixed ClassMocks which had not been added to build and therefore got broken.
Title: [688] trunk: [EK] Removed Cotta, fixed ClassMocks which had not been added to build and therefore got broken. Revision 688 Author sirenian Date 2007-02-25 13:03:34 -0600 (Sun, 25 Feb 2007) Log Message [EK] Removed Cotta, fixed ClassMocks which had not been added to build and therefore got broken. Mauro - I removed the plugins from .classpath due to missing jar; please fix! Ta! Modified Paths trunk/.classpath trunk/build.xml trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java trunk/core/src/java/org/jbehave/core/minimock/UsingMiniMock.java trunk/everything/src/behaviour/org/jbehave/AllBehaviours.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java trunk/extensions/ant/src/java/org/jbehave/ant/AbstractRunnerTask.java Added Paths trunk/extensions/classmocks/src/behaviour/org/jbehave/classmock/AllBehaviours.java Removed Paths trunk/core/src/behaviour/org/jbehave/core/util/BehaviourCollectorBehaviour.java trunk/core/src/behaviour/org/jbehave/core/util/BehavioursLoaderBehaviour.java trunk/core/src/java/org/jbehave/core/util/BehaviourCollector.java trunk/core/src/java/org/jbehave/core/util/BehavioursLoader.java Diff Modified: trunk/.classpath (687 => 688) --- trunk/.classpath 2007-02-25 17:25:30 UTC (rev 687) +++ trunk/.classpath 2007-02-25 19:03:34 UTC (rev 688) @@ -1,43 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: trunk/build.xml (687 => 688) --- trunk/build.xml 2007-02-25 17:25:30 UTC (rev 687) +++ trunk/build.xml 2007-02-25 19:03:34 UTC (rev 688) @@ -17,7 +17,6 @@ - @@ -61,9 +60,6 @@ - - - Modified: trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java (687 => 688) --- trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java 2007-02-25 17:25:30 UTC (rev 687) +++ trunk/core/src/behaviour/org/jbehave/core/story/AllBehaviours.java 2007-02-25 19:03:34 UTC (rev 688) @@ -30,20 +30,13 @@ StoryBuilderBehaviour.class, StoryRunnerBehaviour.class, TextStoryParserBehaviour.class, -//EventOutcomeStepBehaviour.class, -//EventsBehaviour.class, -//GivensBehaviour.class, GivenStepBehaviour.class, GivenScenarioBehaviour.class, MultiStepScenarioBehaviour.class, NarrativeBehaviour.class, -//OutcomesBehaviour.class, OutcomeStepBehaviour.class, ScenarioDrivenStoryBehaviour.class, -//ScenariosBehaviour.class, -//ScenarioUsingMiniMockBehaviour.class, AbstractStepBehaviour.class, -//StepsBehaviour.class, PlainTextScenarioListenerBehaviour.class, PlainTextRendererBehaviour.class, }; Deleted: trunk/core/src/behaviour/org/jbehave/core/util/BehaviourCollectorBehaviour.java (687 => 688) --- trunk/core/src/behaviour/org/jbehave/core/util/BehaviourCollectorBehaviour.java 2007-02-25 17:25:30 UTC (rev 687) +++ trunk/core/src/behaviour/org/jbehave/core/util/BehaviourCollectorBehaviour.java 2007-02-25 19:03:34 UTC (rev 688) @@ -1,55 +0,0 @@ -package org.jbehave.core.util; - -import java.util.Collection; -import java.util.List; - -import net.sf.cotta.TDirectory; -import net.sf.cotta.TFileFactory; -import net.sf.cotta.memory.InMemoryFileSystem; - -import org.jbehave.core.mock.Matcher; -import org.jbehave.core.mock.UsingMatchers; - -public class BehaviourCollectorBehaviour extends UsingMatchers { -private TDirectory directory; - -public void setUp() throws Exception { -directory = new TFileFactory(new InMemoryFileSystem()).dir("/"); -} - -public void shouldCollectFilesMatchingNamePattern() throws Exception { -directory.file("OneBehaviour.class").create(); -directory.file("TwoBehaviour.class").create(); -directory.file("RegularClass.class").create(); -List list = new BehaviourCollector(directory, "").collectNames(); -ensureThat(list, collectionContains("OneBehaviour")); -ensureThat(list, collectionContains("TwoBehaviour")); -ensureThat(list.size(), eq(2)); -} - -public void shouldConstructCorrectFullClassNameWithPackageName() throws Exception { -directory.file("ThisBehaviour.class").create(); -List list = new BehaviourCollector(directory, "one.two.three").collectNames(); -ensureThat(list, collectionContains("one.two.three.ThisBehaviour")); -ensureThat(list.size
[jbehave-scm] [686] trunk: [EK] Renaming of tasks and behaviour runner for consistency
Title: [686] trunk: [EK] Renaming of tasks and behaviour runner for consistency Revision 686 Author sirenian Date 2007-02-25 10:03:05 -0600 (Sun, 25 Feb 2007) Log Message [EK] Renaming of tasks and behaviour runner for consistency Modified Paths trunk/build.xml trunk/core/src/behaviour/org/jbehave/core/RunBehaviour.java trunk/core/src/java/org/jbehave/core/Run.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/AllBehaviours.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/FailingBehaviourClass.java trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java Added Paths trunk/core/src/java/org/jbehave/core/BehaviourRunner.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/BehaviourRunnerTaskBehaviour.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/StoryRunnerTaskBehaviour.java trunk/extensions/ant/src/java/org/jbehave/ant/StoryRunnerTask.java Removed Paths trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveStoryTaskBehaviour.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java trunk/extensions/ant/src/java/org/jbehave/ant/JBehaveStoryTask.java trunk/extensions/ant/src/java/org/jbehave/ant/JBehaveTask.java Diff Modified: trunk/build.xml (685 => 686) --- trunk/build.xml 2007-02-04 18:24:46 UTC (rev 685) +++ trunk/build.xml 2007-02-25 16:03:05 UTC (rev 686) @@ -41,8 +41,8 @@ - - + + Modified: trunk/core/src/behaviour/org/jbehave/core/RunBehaviour.java (685 => 686) --- trunk/core/src/behaviour/org/jbehave/core/RunBehaviour.java 2007-02-04 18:24:46 UTC (rev 685) +++ trunk/core/src/behaviour/org/jbehave/core/RunBehaviour.java 2007-02-25 16:03:05 UTC (rev 686) @@ -43,13 +43,13 @@ public void shouldRunClassFromArgumentSuccessfully() { runCount = 0; - new Run(nullPrintStream).verifyBehaviour(RunnableBehaviour.class); + new BehaviourRunner(nullPrintStream).verifyBehaviour(RunnableBehaviour.class); Ensure.that(runCount == 1); } public void shouldRunTwoClassesFromArgumentsSuccessfully() { runCount = 0; - Run run = new Run(nullPrintStream); + BehaviourRunner run = new BehaviourRunner(nullPrintStream); run.verifyBehaviour(RunnableBehaviour.class); run.verifyBehaviour(RunnableBehaviour.class); Ensure.that(runCount == 2); @@ -57,13 +57,13 @@ public void shouldRunClassNameFromArgumentSuccessfully() throws ClassNotFoundException { runCount = 0; -new Run(nullPrintStream).verifyBehaviour(RunnableBehaviour.class.getName()); +new BehaviourRunner(nullPrintStream).verifyBehaviour(RunnableBehaviour.class.getName()); Ensure.that(runCount == 1); } public void shouldRunClassNamePlusOneMethodSuccessfully() throws ClassNotFoundException { runCount = 0; -Run run = new Run(nullPrintStream); +BehaviourRunner run = new BehaviourRunner(nullPrintStream); run.verifyBehaviour(RunnableBehaviourWithTwoMethods.class.getName() + ":" + "shouldRunNumberOne"); ensureThat(run.succeeded(), eq(true)); ensureThat(runCount, eq(1)); @@ -72,13 +72,13 @@ public void shouldRunClassNameUsingCustomClassLoader() throws ClassNotFoundException { runCount = 0; -new Run(nullPrintStream, new CustomClassLoader(false)).verifyBehaviour(RunnableBehaviour.class.getName()); +new BehaviourRunner(nullPrintStream, new CustomClassLoader(false)).verifyBehaviour(RunnableBehaviour.class.getName()); Ensure.that(runCount == 1); } public void shouldFailToRunClassNameUsingInvalidClassLoader() throws ClassNotFoundException { try { -new Run(nullPrintStream, new CustomClassLoader(true)) +new BehaviourRunner(nullPrintStream, new CustomClassLoader(true)) .verifyBehaviour(RunnableBehaviour.class.getName()); } catch (ClassNotFoundException e) { Ensure.that(runCount == 0); @@ -97,7 +97,7 @@ if ( invalid ){ throw new ClassNotFoundException(); } -return Run.class.getClassLoader().loadClass(name); +return BehaviourRunner.class.getClassLoader().loadClass(name); } } } Added: trunk/core/src/java/org/jbehave/core/BehaviourRunner.java (0 => 686) --- trunk/core/src/java/org/jbehave/core/BehaviourRunner.java (rev 0) +++ trunk/core/src/java/org/jbehave/core/BehaviourRunner.java 2007-02-25 16:03:05 UTC (rev 686) @@ -0,0 +1,75 @@ +package org.jbehave.core; + +import java.io.PrintStream; +import java.io.PrintWriter; + +import org.jbehave.core.behaviour.BehaviourClass; +import org.jbehave.core.behaviour.BehaviourVerifier; +import org.jbehave.core.listener.PlainTextListener; +import org.jbehave.core.util.Timer; + + +/** + * This is the entry point to run one or more [EMAIL PROTECTED] BehaviourClass}. + * Classes are loaded using the ClassLoader in
[jbehave-scm] [678] trunk/core/src/java/org/jbehave/core/mock: [EK] Fixed example behaviours.
Title: [678] trunk/core/src/java/org/jbehave/core/mock: [EK] Fixed example behaviours. Revision 678 Author sirenian Date 2007-01-25 07:37:07 -0600 (Thu, 25 Jan 2007) Log Message [EK] Fixed example behaviours. Modified Paths trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java Added Paths trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ErrorHandler.java Diff Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (677 => 678) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-24 18:31:21 UTC (rev 677) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-25 13:37:07 UTC (rev 678) @@ -121,6 +121,10 @@ }; } + public CustomMatcher is(Object expectedArg) { + return sameInstanceAs(expectedArg); +} + public CustomMatcher sameInstanceAs(final Object expectedArg) { return new CustomMatcher("same instance as <" + expectedArg + ">") { public boolean matches(Object arg) { Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java (677 => 678) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java 2007-01-24 18:31:21 UTC (rev 677) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java 2007-01-25 13:37:07 UTC (rev 678) @@ -1,7 +1,11 @@ package com.sirenian.hellbound.util; -import org.jbehave.core.Block; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + import org.jbehave.core.minimock.UsingMiniMock; +import org.jbehave.core.mock.Mock; +import org.jbehave.core.threaded.QueuedObjectHolder; public class ThreadedQueueBehaviour extends UsingMiniMock { @@ -13,22 +17,28 @@ // Can't think how to test this. } -public void shouldRethrowCaughtExceptionsInCallingThreadThenTerminate() throws Exception { -final ThreadedQueue queue = new ThreadedQueue("test queue") { +public void shouldPassCaughtExceptionsToHandler() throws Exception { +final QueuedObjectHolder exceptionHolder = new QueuedObjectHolder(); +final RuntimeException exception = new RuntimeException("An exception occurred"); + +Mock handler = mock(ErrorHandler.class); +handler.expects("handle").will(new InvocationHandler() { +public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { +exceptionHolder.set(args[0]); +return null; +} +}); + +ThreadedQueue queue = new ThreadedQueue("test queue", (ErrorHandler) handler) { protected void perform(Runnable action) { action.run(); } }; -Exception exception = runAndCatch(Throwable.class, new Block() { -public void run() throws Exception { -queue.queue(new Runnable(){ public void run() { - -throw new RuntimeException("An exception occurred"); -}}); -} -}); - -ensureThat(exception, isNotNull()); +queue.queue(new Runnable(){ public void run() { +throw exception; +}}); + +ensureThat(exceptionHolder.get(), is(exception)); } } Added: trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ErrorHandler.java (0 => 678) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ErrorHandler.java (rev 0) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ErrorHandler.java 2007-01-25 13:37:07 UTC (rev 678) @@ -0,0 +1,11 @@ +package com.sirenian.hellbound.util; + +public interface ErrorHandler { + +ErrorHandler NULL = new ErrorHandler() { +public void handle(Throwable t) {} +}; + +void handle(Throwable t); + +} Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java (677 => 678) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java 2007-01-24 18:31:21 UTC (rev 677) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java 2007-01-25 13:37:07 UTC (rev 678) @@ -22,6 +22,10 @@ private final String queueName; protected ThreadedQueue(String queueName) { +this(queueName, ErrorHandler.NULL); +} + +protected ThreadedQueue(String queueName, final ErrorHandler handler) { this.queueName = queueName; Runnable runnable = new Runnable() { public void run() { @@ -32,7 +36,7 @@ runAllInList(afterEmptyEventList);
[jbehave-scm] [677] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Added queuing listener to the button clicker to ensure that we get the events.
Title: [677] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Added queuing listener to the button clicker to ensure that we get the events. Revision 677 Author sirenian Date 2007-01-24 12:31:21 -0600 (Wed, 24 Jan 2007) Log Message [EK] Added queuing listener to the button clicker to ensure that we get the events. Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Added Paths trunk/extensions/swing/src/java/org/jbehave/threaded/swing/ButtonClicker.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (676 => 677) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-24 18:23:59 UTC (rev 676) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-24 18:31:21 UTC (rev 677) @@ -23,7 +23,6 @@ public class DefaultWindowWrapperBehaviour extends UsingMiniMock { public void shouldClickAButtonOnAWindow() throws Exception { -todo("Does not work on Mac"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); Added: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/ButtonClicker.java (0 => 677) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/ButtonClicker.java (rev 0) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/ButtonClicker.java 2007-01-24 18:31:21 UTC (rev 677) @@ -0,0 +1,58 @@ +package org.jbehave.threaded.swing; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.AbstractButton; + +import org.jbehave.core.exception.PendingException; +import org.jbehave.core.threaded.QueuedObjectHolder; +import org.jbehave.core.threaded.TimeoutException; + +public class ButtonClicker { + +private Idler idler; + +public ButtonClicker() { +idler = new Idler(); +} + +public void click(AbstractButton button) { +QueueingActionListener queuer = new QueueingActionListener(button); + +try { +button.doClick(200); +queuer.waitForEvent(); +} finally { +queuer.removeSelf(); +} +idler.waitForIdle(); +} + +private class QueueingActionListener implements ActionListener { +private QueuedObjectHolder holder = new QueuedObjectHolder(); +private final AbstractButton button; + +public QueueingActionListener(AbstractButton button) { +this.button = button; +button.addActionListener(this); +} + +public void actionPerformed(ActionEvent e) { +holder.set(e); +} +public void waitForEvent() { +try { +holder.get(1000); +} catch (TimeoutException e) { +throw new PendingException("Clicking buttons is not supported for your Swing library."); +} +idler.waitForIdle(); +} + +public void removeSelf() { +button.removeActionListener(this); +} + +} +} Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (676 => 677) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-01-24 18:23:59 UTC (rev 676) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-01-24 18:31:21 UTC (rev 677) @@ -21,8 +21,7 @@ */ class CharacterTyper { -private static final String ACTION_KEY = "CharacterTyper.action"; -private static final String TEXT_TYPING_UNSUPPORTED = "Text typing not supported for your Swing library."; +private static final String TEXT_TYPING_UNSUPPORTED = "Text typing is not supported for your Swing library."; private EventQueue sysQueue; private Idler idler; Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java (676 => 677) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-24 18:23:59 UTC (rev 676) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-24 18:31:21 UTC (rev 677) @@ -20,6 +20,7 @@ private static final WindowGrabber grabber = new WindowGrabber(); private final CharacterTyper typer; +private final ButtonClicker clicker; private final String windowName; private final ComponentFinder finder; @@ -39,6 +40,7 @@ sysQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); idler = new Idler(); typer = new CharacterTyper(
[jbehave-scm] [676] trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java: [EK] Replaced map with holder.
Title: [676] trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java: [EK] Replaced map with holder. Revision 676 Author sirenian Date 2007-01-24 12:23:59 -0600 (Wed, 24 Jan 2007) Log Message [EK] Replaced map with holder. Modified Paths trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java Diff Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (675 => 676) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-01-24 18:22:38 UTC (rev 675) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-01-24 18:23:59 UTC (rev 676) @@ -13,7 +13,7 @@ import javax.swing.JFrame; import org.jbehave.core.exception.PendingException; -import org.jbehave.core.threaded.QueuedMiniHashMap; +import org.jbehave.core.threaded.QueuedObjectHolder; import org.jbehave.core.threaded.TimeoutException; /** @@ -87,7 +87,7 @@ } private class QueueingKeyAdapter extends KeyAdapter { -private QueuedMiniHashMap map = new QueuedMiniHashMap(); +private QueuedObjectHolder holder = new QueuedObjectHolder(); private final Component component; public QueueingKeyAdapter(Component component) { @@ -96,11 +96,11 @@ component.addKeyListener(this); } public void keyTyped(KeyEvent e) { -map.put("keyTyped", e); +holder.set(e); } public void waitForEvent() { try { -map.get("keyTyped", 1000); +holder.get(1000); } catch (TimeoutException e) { throw new PendingException(TEXT_TYPING_UNSUPPORTED); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [674] trunk: [EK] Added filesets to the JBehaveTask.
Title: [674] trunk: [EK] Added filesets to the JBehaveTask. Revision 674 Author sirenian Date 2007-01-23 13:50:54 -0600 (Tue, 23 Jan 2007) Log Message [EK] Added filesets to the JBehaveTask. Modified Paths trunk/build.xml trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java trunk/extensions/ant/src/java/org/jbehave/ant/JBehaveTask.java Added Paths trunk/extensions/ant/src/java/org/jbehave/ant/FilesetParser.java trunk/extensions/ant/src/java/org/jbehave/ant/TrimFilesetParser.java Diff Modified: trunk/build.xml (673 => 674) --- trunk/build.xml 2007-01-22 12:00:53 UTC (rev 673) +++ trunk/build.xml 2007-01-23 19:50:54 UTC (rev 674) @@ -191,12 +191,13 @@ - + + Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (673 => 674) --- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-22 12:00:53 UTC (rev 673) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-23 19:50:54 UTC (rev 674) @@ -122,7 +122,7 @@ } public CustomMatcher sameInstanceAs(final Object expectedArg) { - return new CustomMatcher("same instance as <" + expectedArg.toString() + ">") { + return new CustomMatcher("same instance as <" + expectedArg + ">") { public boolean matches(Object arg) { return expectedArg == arg; } Modified: trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java (673 => 674) --- trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java 2007-01-22 12:00:53 UTC (rev 673) +++ trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java 2007-01-23 19:50:54 UTC (rev 674) @@ -17,8 +17,10 @@ import net.sf.cotta.utils.ClassPathLocator; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; import org.jbehave.core.Block; import org.jbehave.core.Run; @@ -29,9 +31,10 @@ public class JBehaveTaskBehaviour extends UsingMiniMock { private JBehaveTask task; private StubCommandRunner runner = new StubCommandRunner(); +private StubFilesetParser filesetParser = new StubFilesetParser(); public void setUp() { -task = new JBehaveTask(runner); +task = new JBehaveTask(runner, filesetParser); Project project = new Project(); project.setCoreLoader(getClass().getClassLoader()); task.setProject(project); @@ -84,7 +87,20 @@ ensureThat(list, collectionContains(BehaviourClassOne.class.getName())); ensureThat(list, collectionContains(BehaviourClassTwo.class.getName())); } + +public void shouldRunBehavioursFoundInFileSet() { + +FileSet fileSet = new FileSet(); + +task.addBehaviours(fileSet); +task.execute(); +List list = Arrays.asList(runner.commandLineLog); +ensureThat(list, collectionContains(BehaviourClassOne.class.getName())); +ensureThat(list, collectionContains(BehaviourClassTwo.class.getName())); + +} + public void shouldUseClasspathFromClasspathElement() throws Exception { Path path = task.createClasspath(); Path.PathElement element = path.createPathElement(); @@ -150,4 +166,14 @@ return valueToReturn; } } + +private static class StubFilesetParser implements FilesetParser { + +public String[] getClassNames(FileSet fileset, Project project) { +return new String[] { +BehaviourClassOne.class.getName(), +BehaviourClassTwo.class.getName() +}; +} +} } Modified: trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java (673 => 674) --- trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java 2007-01-22 12:00:53 UTC (rev 673) +++ trunk/extensions/ant/src/java/org/jbehave/ant/AbstractJavaTask.java 2007-01-23 19:50:54 UTC (rev 674) @@ -43,5 +43,4 @@ public void setMaxmemory(int megabyte) { createJvmarg().setLine("-Xmx" + megabyte + "m"); } - } Modified: trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java (673 => 674) --- trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java 2007-01-22 12:00:53 UTC (rev 673) +++ trunk/extensions/ant/src/java/org/jbehave/ant/BehaviourRunnerTask.java 2007-01-23 19:50:54 UTC (rev 674) @@ -1,6 +1,9 @@ package org.jbehave.ant; +import java.util.ArrayList; +import java.util.List; + impor
[jbehave-scm] [jbehave] [667] trunk/extensions/swing/src/java/org/jbehave/threaded: [EK] Fixed Swing problems?
Title: [jbehave] [667] trunk/extensions/swing/src/java/org/jbehave/threaded: [EK] Fixed Swing problems? Revision 667 Author sirenian Date 2007-01-10 09:06:40 -0600 (Wed, 10 Jan 2007) Log Message [EK] Fixed Swing problems? Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/behaviour/org/jbehave/threaded/time/ClockedTimeouterBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/QueuedMiniHashMap.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java trunk/extensions/swing/src/java/org/jbehave/threaded/time/ClockedTimeouter.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (666 => 667) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-09 10:46:50 UTC (rev 666) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-10 15:06:40 UTC (rev 667) @@ -24,11 +24,11 @@ public void shouldClickAButtonOnAWindow() throws Exception { checkForHeadless(); - DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); + DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { -JFrame frame = disposeOnCloseFrame(); - frame.setName("a.window"); +AFrame frame = new AFrame(); + frame.setName(AFrame.FRAME_NAME); JButton button = new JButton("Press Me!"); button.setName("a.button"); @@ -54,11 +54,10 @@ public void shouldEnterTextIntoTextComponents() throws Exception { checkForHeadless(); -DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); +DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { -JFrame frame = disposeOnCloseFrame(); - frame.setName("a.window"); +AFrame frame = new AFrame(); JTextComponent textField = new JTextField(); textField.setName("a.textfield"); @@ -86,12 +85,11 @@ public void shouldFindComponent() throws ComponentFinderException, TimeoutException { checkForHeadless(); - DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); + DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { + +AFrame frame = new AFrame(); - JFrame frame = disposeOnCloseFrame(); - frame.setName("a.window"); - JPanel panel = new JPanel(); panel.setName("a.panel"); @@ -106,36 +104,27 @@ public void shouldCloseWindows() throws TimeoutException { checkForHeadless(); -DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); +DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); + +AFrame frame = new AFrame(); -JFrame frame = disposeOnCloseFrame(); -frame.setName("a.window"); -frame.setVisible(true); - wrapper.closeWindow(); ensureThat(!frame.isShowing()); frame.dispose(); } - - -private JFrame disposeOnCloseFrame() { -JFrame frame = new JFrame(); -frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); -return frame; -} public void shouldSimulateKeyPressesForInputMap() throws TimeoutException { checkForHeadless(); - DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); + DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { AFrame frame = new AFrame(); -Mock action = "" +Mock action = "" "Action"); action.stubs("isEnabled").will(returnValue(true)); action.expects("actionPerformed").with(anything()); -frame.contentPanel.getActionMap().put("an action", (Action) action); +frame.contentPanel.getActionMap().put(AFrame.ACTION_KEY, (Action) action); wrapper.pressKeychar(' '); @@ -147,15 +136,10 @@ public void shouldSimulateKeyPressesForKeyListeners() throws TimeoutException { checkForHeadless(); -DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); +DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME); try { -JFrame frame = disposeOnCloseFrame(); -JPanel panel = new JPanel(); -frame.setContentPane(panel); -frame.setName("a.window"); -frame.p
[jbehave-scm] [jbehave] [666] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Restored Swing so that it works for Windows, but think it still pends for Linux.
Title: [jbehave] [666] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Restored Swing so that it works for Windows, but think it still pends for Linux. Revision 666 Author sirenian Date 2007-01-09 04:46:50 -0600 (Tue, 09 Jan 2007) Log Message [EK] Restored Swing so that it works for Windows, but think it still pends for Linux. Switching to Ubuntu to try and fix that. Also delegated character typing as window wrapper was getting large. Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Added Paths trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (665 => 666) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-08 15:16:52 UTC (rev 665) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-09 10:46:50 UTC (rev 666) @@ -176,7 +176,6 @@ wrapper.closeWindow(); } } - private void checkForHeadless() { new HeadlessChecker().check(); Added: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (0 => 666) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java (rev 0) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/CharacterTyper.java 2007-01-09 10:46:50 UTC (rev 666) @@ -0,0 +1,172 @@ +package org.jbehave.threaded.swing; + +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.KeyStroke; + +import org.jbehave.core.exception.PendingException; +import org.jbehave.threaded.time.TimeoutException; + +/** + * Used for pressing or typing all keys which have valid characters associated with them. + */ +class CharacterTyper { + +private static final String TEXT_TYPING_UNSUPPORTED = "Text typing not supported for your Swing library."; +private static Boolean typingCharWorks; +private static Boolean pressingCharWorks; + +private EventQueue sysQueue; +private Idler idler; + + +CharacterTyper() { +sysQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); +idler = new Idler(); +} + +public void typeIntoComponent(Component component, String text) { +VerifyingKeyAdapter verifier = new VerifyingKeyAdapter(); +component.addKeyListener(verifier); + +try { +for (int i = 0; i < text.length(); i++) { +postKeyEvent(component, text.charAt(i)); +if (!verifier.keyTyped) { +throw new PendingException(TEXT_TYPING_UNSUPPORTED); +} +} +} finally { +component.removeKeyListener(verifier); +idler.waitForIdle(); +} +} + +/** + * Use this for any key which has a valid character associated with it, when it is being pressed + * (eg: as a game control key) rather than being typed into a text component. + */ +public void pressKeychar(Window window, char key) throws TimeoutException { +if (pressingCharWorks == null) { +postTypedEventWithInputVerifier(window, key); +} else if (!pressingCharWorks.booleanValue()) { +throw new PendingException(TEXT_TYPING_UNSUPPORTED); +} else { +postKeyEvent(window, key); +} +} + +private void postTypedEventWithInputVerifier(Window window, char key) throws TimeoutException { +boolean result = verifyKeyCharEventPostedToNewFrame(key); + +if (result) { +postTypedEvent(window, key); +pressingCharWorks = Boolean.TRUE; +} else { +pressingCharWorks = Boolean.FALSE; +throw new PendingException(TEXT_TYPING_UNSUPPORTED); +} +} + +private boolean verifyKeyCharEventPostedToNewFrame(char key) throws TimeoutException { +JFrame jFrame = new JFrame(); +jFrame.setName("CharacterTyper.frame"); +JPanel panel = new JPanel(); +jFrame.setContentPane(panel); + + +KeyStroke keyStroke = KeyStroke.getKeyStroke(key); +String actionId = "CharacterTyper.actionFor " + key; +VerifyingAction verifier = new VerifyingAction(); + +panel.getInputMap().put(keyStroke, actionId); +panel.getActionMap().put(actionId, verifier); + +jFrame.
[jbehave-scm] [jbehave] [662] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Quick 'fix' for Linux distros; if the typing doesn't work, a
Title: [jbehave] [662] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Quick 'fix' for Linux distros; if the typing doesn't work, a Revision 662 Author sirenian Date 2007-01-04 10:43:13 -0600 (Thu, 04 Jan 2007) Log Message [EK] Quick 'fix' for Linux distros; if the typing doesn't work, a PendingException will be thrown saying it's not supported Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (661 => 662) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-04 15:42:19 UTC (rev 661) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-04 16:43:13 UTC (rev 662) @@ -23,7 +23,6 @@ public class DefaultWindowWrapperBehaviour extends UsingMiniMock { public void shouldClickAButtonOnAWindow() throws Exception { -todo("not working on unix"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); @@ -54,7 +53,6 @@ public void shouldEnterTextIntoTextComponents() throws Exception { -todo("fix race condition on linux"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); @@ -87,7 +85,6 @@ } public void shouldFindComponent() throws ComponentFinderException, TimeoutException { -todo("not working on linux"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); try { @@ -128,7 +125,6 @@ } public void shouldSimulateKeyPressesForInputMap() throws TimeoutException { -todo("fix race condition on linux"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); @@ -150,7 +146,6 @@ } public void shouldSimulateKeyPressesForKeyListeners() throws TimeoutException { -todo("fix race condition on linux"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java (661 => 662) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-04 15:42:19 UTC (rev 661) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-04 16:43:13 UTC (rev 662) @@ -1,16 +1,22 @@ package org.jbehave.threaded.swing; import java.awt.AWTEvent; +import java.awt.AWTException; import java.awt.Component; import java.awt.EventQueue; +import java.awt.Robot; import java.awt.TextComponent; import java.awt.Toolkit; import java.awt.Window; +import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.ArrayList; import javax.swing.AbstractButton; import javax.swing.text.JTextComponent; +import org.jbehave.core.exception.PendingException; import org.jbehave.threaded.WindowGrabber; import org.jbehave.threaded.time.TimeoutException; @@ -76,11 +82,23 @@ } public void typeIntoJTextComponent(JTextComponent textComponent, String text) { -for (int i = 0; i < text.length(); i++) { -sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_PRESSED)); -sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_RELEASED)); -sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_TYPED)); -} + VerifyingKeyAdapter verifier = new VerifyingKeyAdapter(); + + textComponent.addKeyListener(verifier); + + try { + for (int i = 0; i < text.length(); i++) { + sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_PRESSED)); + sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_RELEASED)); + sysQueue.postEvent(createKeyPressEvent(textComponent, text.charAt(i), KeyEvent.KEY_TYPED)); + if (!verifier.events.contains(new KeycodeEventsReceived(text.charAt(i), KeyEvent.KEY_TYPED))) { + throw new PendingException("Text typing not supported for your Swing library."); + } + } + } finally { + textComponent.removeKeyListener(verifier); + } + idler.waitForIdle(); } @@ -88,23 +106,30 @@ * Use this for any key which doesn't have a corresponding character. */ public void pressKeycode(int key
[jbehave-scm] [jbehave] [650] trunk/examples/hellbound/src/stories: [EK] Finished the last stories for Hellbound
Title: [jbehave] [650] trunk/examples/hellbound/src/stories: [EK] Finished the last stories for Hellbound Revision 650 Author sirenian Date 2007-01-03 08:47:18 -0600 (Wed, 03 Jan 2007) Log Message [EK] Finished the last stories for Hellbound Modified Paths trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame.story trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/ThePlayerPressesLeftRotate.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/ThePlayerPressesRightRotate.java Added Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheLineShouldDisappearAndTheNextGlyphShouldAppear.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheJunkHasAHoleAndAGlyphOfTheRightShapeIsAboveIt.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphToMakeALine.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/ThePlayerMakesALine.java Diff Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java (649 => 650) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java 2007-01-03 11:54:20 UTC (rev 649) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java 2007-01-03 14:47:18 UTC (rev 650) @@ -46,7 +46,7 @@ new ThreadedSwingQueue(), new AcceleratingHeartbeat(), new PitPanel(SCALE, WIDTH, HEIGHT, COLORMAP), -new PseudoRandomGlyphFactory(7, 13)); +new PseudoRandomGlyphFactory(42, 7, 13)); } public Hellbound(EngineQueue engineQueue, GuiQueue guiQueue, Modified: trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story (649 => 650) --- trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story 2007-01-03 11:54:20 UTC (rev 649) +++ trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story 2007-01-03 14:47:18 UTC (rev 650) @@ -8,17 +8,59 @@ Given the glyph is against the right wall When the player presses the right key -Then the glyph will not move +Then the glyph should be against the right wall +TTT +.T. +... +... +... +... +... +... +... +... +... +... +... + Scenario: the glyph will not move left Given the glyph is against the left wall When the player presses the left key -Then the glyph will not move +Then the glyph should be against the left wall +TTT +.T. +... +... +... +... +... +... +... +... +... +... +... + Scenario: the glyph will not move down -Given the glyph is against the floor -When the player presses the down key -Then the glyph becomes junk -and the next glyph appears +Given the first glyph is displayed on the board +When the player presses the drop key +and the player presses the down key +Then the glyph should become junk and the next glyph should appear +..ZZ... +...ZZ.. +... +... +... +... +... +... +... +... +... +..XXX.. +...X... + Modified: trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story (649 => 650) --- trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story 2007-01-03 11:54:20 UTC (rev 649) +++ trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story 2007-01-03 14:47:18 UTC (rev 650) @@ -10,13 +10,54 @@ When the player presses the drop key Then the glyph should fall to the bottom When time passes -Then the glyph segments should become junk -and the next glyph should appear +Then the glyph should become junk and the next glyph should appear +..ZZ... +...ZZ.. +... +... +... +... +... +... +... +... +... +..XXX.. +...X... + Scenario: the player drops the glyph onto junk Given the player drops the glyph into an empty pit When the player presses the drop key Then the glyph should fall onto the junk -and the glyph segments should become junk -and the next glyph should appear +... +... +... +... +... +... +... +... +... +..ZZ... +...ZZ.. +..XXX.. +...X... + +When time passes +Then the glyph should become junk and the next glyph should appear +...SS.. +..SS... +... +... +... +... +... +... +... +..XX... +...XX.. +..XXX.. +...X... + Modified: trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story (649 => 650) --- trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story 2007-01-03 11:54:20 UTC (rev 649) +++ trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story 2007-01-03 14:47:18
[jbehave-scm] [jbehave] [649] trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine: [EK] The Hellbound game now has a minimum feature set! All fully narrated in executable stories! Hurrah!
Title: [jbehave] [649] trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine: [EK] The Hellbound game now has a minimum feature set! All fully narrated in executable stories! Hurrah! Revision 649 Author sirenian Date 2007-01-03 05:54:20 -0600 (Wed, 03 Jan 2007) Log Message [EK] The Hellbound game now has a minimum feature set! All fully narrated in executable stories! Hurrah! Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/SegmentsBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/Segments.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java Added Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/ThePlayerPressesTheDownKey.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldBeAgainstTheLeftWall.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphIsAgainstTheLeftWall.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphIsAgainstTheRightWall.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldBeAgainstTheRightWall.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphWillNotMoveLeft.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphWillNotMoveRight.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/TheGlyphIsConstrainedByThePit.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/TheGlyphWillNotMoveDown.java Removed Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/ThePlayerPressesTheDownButton.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/SegmentsBehaviour.java (648 => 649) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/SegmentsBehaviour.java 2007-01-03 11:12:18 UTC (rev 648) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/SegmentsBehaviour.java 2007-01-03 11:54:20 UTC (rev 649) @@ -157,6 +157,26 @@ ensureThat(segments.lowest(), eq(4)); } + +public void shouldReturnTheLeftmostXPosition() { +Segments segments = new Segments( +new Segment(4, 1), +new Segment(3, 4), +new Segment(2, 3), +new Segment(5, 2)); + +ensureThat(segments.leftmost(), eq(2)); +} + +public void shouldReturnTheRightmostXPosition() { +Segments segments = new Segments( +new Segment(4, 1), +new Segment(3, 4), +new Segment(2, 3), +new Segment(5, 2)); + +ensureThat(segments.rightmost(), eq(5)); +} public void shouldReturnAddedSegments() { Segments segments1 = new Segments(new Segment[] { Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java (648 => 649) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2007-01-03 11:12:18 UTC (rev 648) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2007-01-03 11:54:20 UTC (rev 649) @@ -162,6 +162,30 @@ verifyMocks(); } +public void shouldNotMoveGlyphLeftOrRightIfGlyphIsConstrainedByWalls() { +Junk junk = new Junk(3, 13); +class GlyphHolder { +private LivingGlyph glyph; +}; +final GlyphHolder holder = new GlyphHolder(); + +Game game = new Game(new PseudoRandomGlyphFactory(42, 3, 13) { +public LivingGlyph nextGlyph(CollisionDetector detector, ListenerSet glyphListeners) { +holder.glyph = super.nextGlyph(detector, glyphListeners); +return holder.glyph; +} +}, new StubHeartbeat(), 3, 13); +game.requestStartGame(); + +Segments originalSegments = holder.glyph.getSegments(); + +game.requestGlyphMovement(GlyphMovement.RIGHT); +ensureThat(holder.glyph.getSegments(), eq(originalSegments)); + +game.requestGlyphMovement(GlyphMovement.LEFT); +ensureThat(holder.glyph.getSegments(), eq(originalSegments)); +} + public void shouldEndGameAndStopHeartbeatWhenTheNewGlyphOverlapsTheJunk() { StubHeartbeat heartbeat = new StubHeartbeat(); Game game = new Game(new PseudoRandomGlyphFactory(42, 7, 2), heartbeat, 7, 2); // pit is only 2 deep! Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/Segments.java (648 => 649) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/Segments.java 2007-01-03 11:12:18
[jbehave-scm] [jbehave] [648] trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories: [EK] New Story: The Player Loses the Game
Title: [jbehave] [648] trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories: [EK] New Story: The Player Loses the Game Revision 648 Author sirenian Date 2007-01-03 05:12:18 -0600 (Wed, 03 Jan 2007) Log Message [EK] New Story: The Player Loses the Game Added Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGameShouldBeOver.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppearOverlappingIt.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheJunkIsAlmostToTheTop.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThereIsNoSpaceForTheNextGlyph.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/ThePlayerLosesTheGame.java Removed Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphSegmentsShouldBecomeJunk.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheNextGlyphShouldAppear.java Diff Deleted: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphSegmentsShouldBecomeJunk.java (647 => 648) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphSegmentsShouldBecomeJunk.java 2007-01-03 10:49:47 UTC (rev 647) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphSegmentsShouldBecomeJunk.java 2007-01-03 11:12:18 UTC (rev 648) @@ -1,29 +0,0 @@ -package com.sirenian.hellbound.outcomes; - -import java.awt.Color; - -import org.jbehave.core.Ensure; -import org.jbehave.core.story.domain.World; - -import com.sirenian.hellbound.Hellbound; -import com.sirenian.hellbound.domain.Segment; -import com.sirenian.hellbound.domain.Segments; -import com.sirenian.hellbound.domain.glyph.GlyphType; -import com.sirenian.hellbound.gui.RenderedPit; - - -public class TheGlyphSegmentsShouldBecomeJunk extends HellboundOutcome { -public void verifyAnyTimeIn(World world) { -Segments expectedSegments = new Segments( -new Segment(2, 11), -new Segment(3, 11), -new Segment(4, 11), -new Segment(3, 12) -); -Color expectedColor = Hellbound.COLORMAP.getColorFor(GlyphType.JUNK); - -RenderedPit pit = getPit(world); -Ensure.that(pit, contains(expectedSegments, expectedColor)); -} - -} Deleted: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheNextGlyphShouldAppear.java (647 => 648) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheNextGlyphShouldAppear.java 2007-01-03 10:49:47 UTC (rev 647) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheNextGlyphShouldAppear.java 2007-01-03 11:12:18 UTC (rev 648) @@ -1,9 +0,0 @@ -package com.sirenian.hellbound.outcomes; - -import org.jbehave.core.story.domain.World; - - -public class TheNextGlyphShouldAppear extends HellboundOutcome { -public void verifyAnyTimeIn(World world) { -} -} Added: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGameShouldBeOver.java (0 => 648) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGameShouldBeOver.java (rev 0) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGameShouldBeOver.java 2007-01-03 11:12:18 UTC (rev 648) @@ -0,0 +1,26 @@ +package com.sirenian.hellbound.scenarios; + +import javax.swing.JLabel; + +import org.jbehave.core.Ensure; +import org.jbehave.core.story.domain.World; +import org.jbehave.threaded.swing.WindowWrapper; + +import com.sirenian.hellbound.gui.ComponentNames; +import com.sirenian.hellbound.outcomes.HellboundOutcome; +import com.sirenian.hellbound.stories.WorldKey; + +public class TheGameShouldBeOver extends HellboundOutcome { + +protected void verifyAnyTimeIn(World world) { +WindowWrapper windowWrapper = (WindowWrapper) world.get(WorldKey.WINDOW_WRAPPER); +JLabel messageLabel = null; +try { + messageLabel = (JLabel) windowWrapper.findComponent(ComponentNames.GAME_MESSAGE); +} catch (Exception e) { +throw new RuntimeException(e); +} +Ensure.that(messageLabel.getText(), eq("Game over, man! Game over!")); +} + +} Added: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppearOverlappingIt.java (0 => 648) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppearOverlappingIt.java (rev 0) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppearOverlappingIt.java 2007-01-03 11:12:18 UTC (rev 648) @@ -0,0 +1,11 @@ +package com.sirenian.hellbound.scenarios; + +import com.sirenian.hellbound.outcome
[jbehave-scm] [jbehave] [647] trunk/core/src/java/org/jbehave/core/story/renderer: [EK] Fixed hellbound outcomes so that outcomes with ambiguous names can take parameters showing the pit, and render t
Title: [jbehave] [647] trunk/core/src/java/org/jbehave/core/story/renderer: [EK] Fixed hellbound outcomes so that outcomes with ambiguous names can take parameters showing the pit, and render those in story narration. Revision 647 Author sirenian Date 2007-01-03 04:49:47 -0600 (Wed, 03 Jan 2007) Log Message [EK] Fixed hellbound outcomes so that outcomes with ambiguous names can take parameters showing the pit, and render those in story narration. Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java Added Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/ThePitShouldLookLike.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java (646 => 647) --- trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-03 10:49:47 UTC (rev 647) @@ -46,7 +46,7 @@ PlainTextRenderer renderer = new PlainTextRenderer(printStream); -renderer.render("Custom renderable"); +renderer.renderAny("Custom renderable"); String result = byteStream.toString(); Modified: trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java (646 => 647) --- trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-03 10:49:47 UTC (rev 647) @@ -84,7 +84,7 @@ out.println(phrase); } -public void render(Object obj) { +public void renderAny(Object obj) { out.println(obj.toString()); } Modified: trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java (646 => 647) --- trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-03 10:49:47 UTC (rev 647) @@ -27,5 +27,5 @@ * This method can be used by scenario components overriding the * narrateTo method in order to render custom descriptions. */ -void render(Object obj); +void renderAny(Object obj); } Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java (646 => 647) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java 2007-01-03 10:49:47 UTC (rev 647) @@ -17,7 +17,9 @@ public class RenderedPit extends Graphics { - private final int scale; + private static final String NL = System.getProperty("line.separator"); + +private final int scale; private Color color; private Map pitMap; private char[][] asciiRepresentation; @@ -148,9 +150,8 @@ public String toString() { StringBuffer buffer = new StringBuffer(); -buffer.append(System.getProperty("line.separator")); for (int i = 0; i < asciiRepresentation.length; i++) { -buffer.append(String.valueOf(asciiRepresentation[i])).append(System.getProperty("line.separator")); +buffer.append(String.valueOf(asciiRepresentation[i])).append(NL); } return buffer.toString(); } Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java (646 => 647) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java 2007-01-03 10:49:47 UTC (rev 647) @@ -17,6 +17,8 @@ public abstract class HellboundOutcome extends OutcomeUsingMiniMock { +protected static final String NL = System.getProperty("line.separator"); + protected static
[jbehave-scm] [jbehave] [645] trunk/examples/hellbound/src/java/com/sirenian/hellbound: [EK] Some more stuff working in Hellbound
Title: [jbehave] [645] trunk/examples/hellbound/src/java/com/sirenian/hellbound: [EK] Some more stuff working in Hellbound Revision 645 Author sirenian Date 2007-01-02 11:22:53 -0600 (Tue, 02 Jan 2007) Log Message [EK] Some more stuff working in Hellbound Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/StubHeartbeat.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/AcceleratingHeartbeat.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/GameKeys.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/StubHeartbeat.java (644 => 645) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/StubHeartbeat.java 2007-01-02 16:05:39 UTC (rev 644) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/StubHeartbeat.java 2007-01-02 17:22:53 UTC (rev 645) @@ -4,6 +4,7 @@ private HeartbeatListener listener; private boolean beating; +private boolean skipped; public void addListener(HeartbeatListener listener) { this.listener = listener; @@ -26,6 +27,10 @@ } public void skipNextBeat() { - +skipped = true; } + +public boolean wasSkipped() { +return skipped; +} } Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java (644 => 645) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2007-01-02 16:05:39 UTC (rev 644) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2007-01-02 17:22:53 UTC (rev 645) @@ -36,6 +36,7 @@ verifyMocks(); } + public void shouldRunOnRequestStartAndStartHeartbeatAndInformListeners() throws Exception { @@ -119,6 +120,18 @@ verifyMocks(); } + +public void shouldMoveGlyphDownAndSkipNextHeartbeat() { + +StubHeartbeat stubHeartbeat = new StubHeartbeat(); + +Game game = new Game(new PseudoRandomGlyphFactory(7, 13), stubHeartbeat, 7, 13); +game.requestStartGame(); +game.requestGlyphMovement(GlyphMovement.DOWN); +ensureThat(stubHeartbeat.wasSkipped()); + +} + public void shouldCauseGlyphSegmentsToBeAddedToPitThenCreateNewGlyphWhenGlyphCannotMoveDown() { // Given... Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java (644 => 645) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java 2007-01-02 16:05:39 UTC (rev 644) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java 2007-01-02 17:22:53 UTC (rev 645) @@ -36,6 +36,9 @@ Color.MAGENTA, Color.GRAY, Color.BLACK }); private HellboundFrame frame; +private final EngineQueue engineQueue; +private final GuiQueue guiQueue; +private final Heartbeat heartbeat; public Hellbound() { this( @@ -49,14 +52,17 @@ public Hellbound(EngineQueue engineQueue, GuiQueue guiQueue, Heartbeat heartbeat, PitPanel pitPanel, GlyphFactory factory) { +this.engineQueue = engineQueue; +this.guiQueue = guiQueue; +this.heartbeat = heartbeat; Logger.debug(this, "Creating Hellbound instance..."); frame = createFrameForGui(engineQueue, pitPanel); Game game = createEngineForGame(heartbeat, factory); -connectQueues(engineQueue, guiQueue, pitPanel, frame, game); -bindThreadsToFrame(engineQueue, guiQueue, heartbeat, frame); -startHellbound(frame); +connectQueues(game, pitPanel); +bindThreadsToFrame(); +startHellbound(); } public static void main(String[] args) { @@ -64,22 +70,20 @@ new Hellbound(); } -private void startHellbound(HellboundFrame frame) { +private void startHellbound() { frame.pack(); frame.setVisible(true); } public void stopHellbound() { frame.dispose(); +stopThreads(); // Swing cannot be trusted to do this asynchronously Logger.debug(this, "Hellbound stopped."); } private void connectQueues( -EngineQueue engineQueue, -GuiQueue guiQueue, -GlyphListener pitPanel, -HellboundFrame frame, -Game game) { +Game gam
[jbehave-scm] [jbehave] [644] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Oops, put pendingness back on non-Linux-compatible behaviour.
Title: [jbehave] [644] trunk/extensions/swing/src/java/org/jbehave/threaded/swing: [EK] Oops, put pendingness back on non-Linux-compatible behaviour. Revision 644 Author sirenian Date 2007-01-02 10:05:39 -0600 (Tue, 02 Jan 2007) Log Message [EK] Oops, put pendingness back on non-Linux-compatible behaviour. Removed mouseEvent from wrapper as it wasn't being used. Modified Paths trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java (643 => 644) --- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-02 16:03:19 UTC (rev 643) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java 2007-01-02 16:05:39 UTC (rev 644) @@ -127,7 +127,7 @@ } public void shouldSimulateKeyPressesForInputMap() throws TimeoutException { -//todo("fix race condition on linux"); +todo("fix race condition on linux"); checkForHeadless(); DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); Modified: trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java (643 => 644) --- trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-02 16:03:19 UTC (rev 643) +++ trunk/extensions/swing/src/java/org/jbehave/threaded/swing/DefaultWindowWrapper.java 2007-01-02 16:05:39 UTC (rev 644) @@ -7,7 +7,6 @@ import java.awt.Toolkit; import java.awt.Window; import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; import javax.swing.AbstractButton; import javax.swing.text.JTextComponent; @@ -119,18 +118,6 @@ } return window; } - - - private MouseEvent createMouseEvent(AbstractButton button, int id) { - return new MouseEvent(button, -id, -System.currentTimeMillis(), -MouseEvent.BUTTON1_MASK, -button.getWidth() / 2, -button.getHeight() / 2, -1, -false); - } private AWTEvent createKeyPressEvent(Component component, char c, int id) { return new KeyEvent(component, To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [643] trunk/core/src/java/org/jbehave/core/story/domain: [EK] Make sure cleanup happens properly
Title: [jbehave] [643] trunk/core/src/java/org/jbehave/core/story/domain: [EK] Make sure cleanup happens properly Revision 643 Author sirenian Date 2007-01-02 10:03:19 -0600 (Tue, 02 Jan 2007) Log Message [EK] Make sure cleanup happens properly Cleaned up Hellbound a bit, added some more debugging - why aren't the threads closing down? Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java trunk/core/src/java/org/jbehave/core/story/domain/GivenScenario.java trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java trunk/core/src/java/org/jbehave/core/story/domain/Scenario.java trunk/core/src/java/org/jbehave/core/story/domain/ScenarioDrivenStory.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/PitPanelBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/util/ThreadedQueue.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/givens/HellboundIsRunning.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheFirstGlyphIsDisplayedOnTheBoard.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphRight.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerSeesTheFirstGlyphMove.java trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/DefaultWindowWrapperBehaviour.java Added Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java Removed Paths trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheGlyphShouldFallOntoTheJunk.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java (642 => 643) --- trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-01-02 16:03:19 UTC (rev 643) @@ -1,6 +1,7 @@ package org.jbehave.core.story.domain; import org.jbehave.core.Block; +import org.jbehave.core.exception.VerificationException; import org.jbehave.core.minimock.UsingMiniMock; import org.jbehave.core.mock.Mock; import org.jbehave.core.story.renderer.Renderer; @@ -342,20 +343,72 @@ ensureThat(exception, isNotNull()); } -public void shouldFailIfCleanedUpBeforeRun() throws Exception { -final Scenario scenario = new MultiStepScenario(){ -public void specifySteps() {}}; +public void shouldNotCleanUpIfNotRun() throws Exception { +// given +final Mock given = mock(GivenWithCleanUp.class, "given"); +World world = (World)stub(World.class); + +Scenario scenario = new MultiStepScenario() { +public void specifySteps() { +given((Given) given); + +}}; -Exception exception = runAndCatch(IllegalStateException.class, new Block() { -public void run() throws Exception { -scenario.specify(); -scenario.cleanUp((World)stub(World.class)); -} -}); +given.expects("cleanUp").never(); + +scenario.specify(); +scenario.cleanUp(world); -ensureThat(exception, isNotNull()); +verifyMocks(); } +public void shouldNotCleanUpIfAlreadyCleanedUp() throws Exception { +// given +final Mock given = mock(GivenWithCleanUp.class, "given"); +World world = (World)stub(World.class); + +Scenario scenario = new MultiStepScenario() { +public void specifySteps() { +given((Given) given); + +}}; + +given.expects("cleanUp").once(); + +scenario.specify(); +scenario.run(world); +scenario.cleanUp(world); +scenario.cleanUp(world); + +verifyMocks(); +} + +public void shouldCleanUpEvenIfStepFailed() { +
[jbehave-scm] [jbehave] [642] trunk/core/src/java/org/jbehave/core/mock: [EK] ensureThrows / ensureDoesNotThrow -> runAndCatch
Title: [jbehave] [642] trunk/core/src/java/org/jbehave/core/mock: [EK] ensureThrows / ensureDoesNotThrow -> runAndCatch Revision 642 Author sirenian Date 2007-01-02 08:58:48 -0600 (Tue, 02 Jan 2007) Log Message [EK] ensureThrows / ensureDoesNotThrow -> runAndCatch Added state checking to MultiStepScenario Modified Paths trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java trunk/core/src/java/org/jbehave/core/story/StoryBuilder.java trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java trunk/core/src/java/org/jbehave/core/story/domain/Scenario.java trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenario.java trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenarioWithOverdraft.java trunk/examples/atm/src/stories/example/atm/scenarios/InLotsOfTrouble.java trunk/examples/atm/src/stories/example/atm/scenarios/OverdrawnWithoutPermission.java trunk/examples/currency/src/behaviour/example/currency/SterlingCurrencyConverterBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheFirstGlyphIsDisplayedOnTheBoard.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphRight.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerSeesTheFirstGlyphMove.java trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java trunk/extensions/jmock/src/behaviour/org/jbehave/jmock/UsingJMockBehaviour.java trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/HeadlessCheckerBehaviour.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java (641 => 642) --- trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/behaviour/org/jbehave/core/UsingMatchersBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -1,6 +1,5 @@ package org.jbehave.core; -import org.jbehave.core.exception.VerificationException; import org.jbehave.core.mock.UsingMatchers; public class UsingMatchersBehaviour { @@ -50,31 +49,28 @@ Ensure.that(new Object(), m.isNotNull()); } -public void shouldFailWhenBlockThatShouldFailDoesNot() throws Exception { +public void shouldCatchAndReturnAThrownException() throws Exception { +UsingMatchers m = new UsingMatchers() {}; -Ensure.throwsException(IllegalArgumentException.class, EXCEPTION_BLOCK); +Exception exception = m.runAndCatch(IllegalArgumentException.class, EXCEPTION_BLOCK); +Ensure.that(exception, m.isNotNull()); +} + +public void shouldReturnNullIfNoExceptionThrown() throws Exception { +UsingMatchers m = new UsingMatchers() {}; -boolean succeeded = true; -try { -Ensure.throwsException(IllegalArgumentException.class, EMPTY_BLOCK); -succeeded = false; -} catch (VerificationException expected) {} - -if (!succeeded) { -throw new VerificationException("Should have thrown a verification exception"); -} +Exception exception = m.runAndCatch(IllegalArgumentException.class, EMPTY_BLOCK); +Ensure.that(exception, m.isNull()); } -public void shouldFailWhenBlockThatShouldSucceedDoesNot() throws Exception { -Ensure.doesNotThrowException(EMPTY_BLOCK); +public void shouldPropagateExceptionOfAnUnexpectedType() throws Exception { +UsingMatchers m = new UsingMatchers() {}; -boolean succeeded = true; try { -Ensure.doesNotThrowException(EXCEPTION_BLOCK); -succeeded = false; -} catch (VerificationException expected) {} -if (!succeeded) { -throw new VerificationException("Should have thrown a verification exception"); +Exception exception = m.runAndCatch(UnsupportedOperationException.class, EXCEPTION_BLOCK); +m.fail("Should have thrown IllegalArgumentException"); +} catch (IllegalArgumentException e) { +// expected } } } Modified: trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java (641 => 642) --- trunk
[jbehave-scm] [jbehave] [641] trunk/core/src/java/org/jbehave/core/story: [EK] Added behaviour for StoryPrinter, made it specify stories before printing.
Title: [jbehave] [641] trunk/core/src/java/org/jbehave/core/story: [EK] Added behaviour for StoryPrinter, made it specify stories before printing. Revision 641 Author sirenian Date 2007-01-02 05:50:17 -0600 (Tue, 02 Jan 2007) Log Message [EK] Added behaviour for StoryPrinter, made it specify stories before printing. Moved expected description of SimpleStory into the class to avoid duplication in PlainTextRendererBehaviour. Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java Added Paths trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java (640 => 641) --- trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java 2007-01-02 11:21:42 UTC (rev 640) +++ trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java 2007-01-02 11:50:17 UTC (rev 641) @@ -7,9 +7,13 @@ import org.jbehave.core.story.domain.Narrative; import org.jbehave.core.story.domain.ScenarioDrivenStory; import org.jbehave.core.story.domain.World; +import org.jbehave.core.util.CamelCaseConverter; public class SimpleStory extends ScenarioDrivenStory { + +private static final String NL = System.getProperty("line.separator"); + public static String ROLE = "behaviour analyst"; public static String FEATURE = "to see the behaviour of PlainTextRenderer"; @@ -81,4 +85,30 @@ public void verify(World world) { } } + +public static String expectedDescription() { +StringBuffer expectedResult = new StringBuffer(); +expectedResult.append("Story: ").append(textOf(new SimpleStory())).append(NL + NL); +expectedResult.append("As a ").append(SimpleStory.ROLE).append(NL); +expectedResult.append("I want ").append(SimpleStory.FEATURE).append(NL); +expectedResult.append("So that ").append(SimpleStory.BENEFIT).append(NL + NL); +expectedResult.append("Scenario: ").append(textOf(new SimpleStory.PlainTextRendererWorks())).append(NL + NL); +expectedResult.append("Given ").append(textOf(new SimpleStory.EverythingCompiles())).append(NL); +expectedResult.append("When ").append(textOf(new SimpleStory.ICrossMyFingers())).append(NL); +expectedResult.append("Then ").append(textOf(new SimpleStory.PlainTextRendererShouldWork())).append(NL + NL); + +expectedResult.append("Scenario: ").append(textOf(new SimpleStory.PlainTextRendererStillWorks())).append(NL + NL); +expectedResult.append("Given ").append(textOf(new SimpleStory.PlainTextRendererWorks())).append(NL);; +expectedResult.append("and ").append(textOf(new SimpleStory.FirstScenarioRanWithoutFallingOver())).append(NL); +expectedResult.append("When ").append(textOf(new SimpleStory.IDoNothing())).append(NL); +expectedResult.append("Then ").append(textOf(new SimpleStory.PlainTextRendererShouldStillWork())).append(NL); +expectedResult.append("and ").append(textOf(new SimpleStory.BehaviourClassShouldNotFail())).append(NL); + +return expectedResult.toString(); +} + + +private static String textOf(Object obj) { +return new CamelCaseConverter(obj).toPhrase(); +} } \ No newline at end of file Added: trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java (0 => 641) --- trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java (rev 0) +++ trunk/core/src/behaviour/org/jbehave/core/story/StoryPrinterBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) @@ -0,0 +1,23 @@ +package org.jbehave.core.story; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.jbehave.core.mock.UsingMatchers; + +public class StoryPrinterBehaviour extends UsingMatchers { + + +public void shouldSpecifyAndPrintStoryAsPlainText() throws Exception { + +ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); +PrintStream printStream = new PrintStream(byteStream); + +StoryPrinter printer = new StoryPrinter(printStream); +printer.print(SimpleStory.class.getName()); +String result = byteStream.toString(); + +ensureThat(result, eq(SimpleStory.expectedDescription())); +} + +} Modified: trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java (640 => 641) --- trunk/core/src/behaviour/org/jbehave/core/story/StoryRunnerBehaviour.java 2007-01-02 11:21:42 UTC (rev 640) +++ trunk/core/src/beh
[jbehave-scm] [jbehave] [640] trunk/core/src/java/org/jbehave/core/story/renderer: [EK] Added render(Object) method to allow custom rendering.
Title: [jbehave] [640] trunk/core/src/java/org/jbehave/core/story/renderer: [EK] Added render(Object) method to allow custom rendering. Revision 640 Author sirenian Date 2007-01-02 05:21:42 -0600 (Tue, 02 Jan 2007) Log Message [EK] Added render(Object) method to allow custom rendering. Modified Paths trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/HellboundStory.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/TheGlyphMovesAsTimePasses.java Diff Modified: trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java (639 => 640) --- trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-02 11:06:45 UTC (rev 639) +++ trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-02 11:21:42 UTC (rev 640) @@ -22,7 +22,9 @@ */ public class PlainTextRendererBehaviour extends UsingMatchers { - public void shouldRenderStoryWhenNarratingStory() { + private static final String NL = System.getProperty("line.separator"); + +public void shouldRenderStoryWhenNarratingStory() { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteStream); @@ -35,8 +37,6 @@ String result = byteStream.toString(); - String NL = System.getProperty("line.separator"); - StringBuffer expectedResult = new StringBuffer(); expectedResult.append("Story: ").append(textOf(story)).append(NL + NL); expectedResult.append("As a ").append(SimpleStory.ROLE).append(NL); @@ -56,6 +56,22 @@ ensureThat(result, eq(expectedResult.toString())); } + +public void shouldProvideComponentsWithCustomRenderingUsingStrings() { +StringBuffer expectedResult = new StringBuffer(); +expectedResult.append("Custom renderable" + NL); + +ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); +PrintStream printStream = new PrintStream(byteStream); + +PlainTextRenderer renderer = new PlainTextRenderer(printStream); + +renderer.render("Custom renderable"); + +String result = byteStream.toString(); + +ensureThat(result, eq(expectedResult.toString())); +} private String textOf(Object obj) { return new CamelCaseConverter(obj).toPhrase(); Modified: trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java (639 => 640) --- trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-02 11:06:45 UTC (rev 639) +++ trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-02 11:21:42 UTC (rev 640) @@ -84,6 +84,9 @@ out.println(phrase); } +public void render(Object obj) { +out.println(obj.toString()); +} private boolean previousComponentWasA(Class clazz) { return previousComponent != null && clazz.isAssignableFrom(previousComponent.getClass()); Modified: trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java (639 => 640) --- trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-02 11:06:45 UTC (rev 639) +++ trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-02 11:21:42 UTC (rev 640) @@ -22,4 +22,10 @@ void renderGiven(Given given); void renderOutcome(Outcome outcome); void renderEvent(Event event); + +/** + * This method can be used by scenario components overriding the + * narrateTo method in order to render custom descriptions. + */ +void render(Object obj); } Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/HellboundStory.java (639 => 640) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/HellboundStory.java 2007-01-02 11:06:45 UTC (rev 639) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/HellboundStory.java 2007-01-02 11:21:42 UTC (rev 640) @@ -3,13 +3,9 @@ import org.jbehave.core.story.domain.Narrative; import org.jbehave.core.story.domain.ScenarioDrivenStory; -public class HellboundStory extends ScenarioDrivenStory { +public abstract class HellboundStory extends ScenarioDrivenStory { public HellboundStory(Narrative narrative) { super(narrative); } - -public void specify() { -// TODO Auto-generated method stub -} } Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/TheGlyphMovesAsTimePasses.java (639 => 640) --- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/stories/TheGlyphMovesAsTimePasses.java 2007-01-02 11:06:45 UT
[jbehave-scm] [jbehave] [621] trunk/examples/hellbound/src/java/com/sirenian/hellbound: [EK] Some more Hellbound stuff - Hellbound is nearly playable!
Title: [jbehave] [621] trunk/examples/hellbound/src/java/com/sirenian/hellbound: [EK] Some more Hellbound stuff - Hellbound is nearly playable! Revision 621 Author sirenian Date 2006-12-08 06:46:09 -0600 (Fri, 08 Dec 2006) Log Message [EK] Some more Hellbound stuff - Hellbound is nearly playable! Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/Hellbound.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/Segments.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/game/GameState.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/glyph/LivingGlyph.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/CollisionDetector.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/PseudoRandomGlyphFactory.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ComponentNames.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/HellboundFrame.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/PitPanel.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java trunk/extensions/swing/src/java/org/jbehave/threaded/swing/Idler.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java (620 => 621) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-12-08 11:43:03 UTC (rev 620) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-12-08 12:46:09 UTC (rev 621) @@ -149,6 +149,24 @@ verifyMocks(); } +public void shouldEndGameWhenTheNewGlyphOverlapsTheJunk() { +StubHeartbeat heartbeat = new StubHeartbeat(); +Game game = new Game(new PseudoRandomGlyphFactory(42, 7, 2), heartbeat, 7, 2); // pit is only 2 deep! + +Mock gameListener = mock(GameListener.class); +game.requestStartGame(); + +gameListener.expects("reportGameStateChanged").with(GameState.RUNNING); +gameListener.expects("reportGameStateChanged").with(GameState.OVER); +game.addGameListener((GameListener) gameListener); + + +heartbeat.beat(); // first glyph falls; cannot add second glyph as it overlaps + +verifyMocks(); + +} + private Segments droppedToFloor(Segments segments, int floor) { Segments result = segments; while(result.lowest() < floor) { Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java (620 => 621) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2006-12-08 11:43:03 UTC (rev 620) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2006-12-08 12:46:09 UTC (rev 621) @@ -2,11 +2,13 @@ import java.awt.event.KeyEvent; +import javax.swing.JLabel; import javax.swing.JPanel; import org.jbehave.core.minimock.UsingMiniMock; import org.jbehave.core.mock.Mock; import org.jbehave.threaded.swing.DefaultWindowWrapper; +import org.jbehave.threaded.swing.Idler; import org.jbehave.threaded.time.TimeoutException; import com.sirenian.hellbound.domain.game.GameRequestListener; @@ -24,7 +26,9 @@ public void setUp() { windowWrapper = new DefaultWindowWrapper(ComponentNames.HELLBOUND_FRAME); frontPanel = new JPanel(); +frontPanel.setName("front.panel"); gamePanel = new JPanel(); +gamePanel.setName("game.panel"); gameRequestListener = mock(GameRequestListener.class); frame = new HellboundFrame(frontPanel, gamePanel); frame.setGameRequestListener((GameRequestListener) gameRequestListener); @@ -50,6 +54,16 @@ ensureThat(gamePanel.isShowing()); } +public void shouldHaveLabelDisplayingGameOverMessageWhenGameOver() throws Exception { +frame.reportGameStateChanged(GameState.RUNNING); +new Idler().waitForIdle(); +JLabel label = (JLabel) windowWrapper.findComponent(ComponentNames.GAME_MESSAGE); +ensureThat(label.getText(), eq("")); +frame.reportGameStateChanged(GameState.OVER); +new Idler().waitForIdle(); +ensureThat(label.getText(), eq("Game over, man! Game over!")); +} + public void shouldRequestThatTheShapeIsDroppedWhenTheSpaceKeyIsPressed() throws Exception { ensureThatKeycodeProducesRequest(' ', GlyphMovement.DROP); } @@ -72,7 +86,6 @@ public void shouldRequestThatTheShapeIsRotatedRightWhenThe
[jbehave-scm] [jbehave] [610] trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui: [EK] Removed the duplication from 6 different ways of moving glyphs.
Title: [jbehave] [610] trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui: [EK] Removed the duplication from 6 different ways of moving glyphs. Revision 610 Author sirenian Date 2006-12-04 11:13:30 -0600 (Mon, 04 Dec 2006) Log Message [EK] Removed the duplication from 6 different ways of moving glyphs. Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/ThreadedEngineQueueBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/game/GameRequestListener.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/ThreadedEngineQueue.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/HellboundFrame.java Added Paths trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/glyph/GlyphMovement.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java (609 => 610) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-12-04 16:25:01 UTC (rev 609) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-12-04 17:13:30 UTC (rev 610) @@ -8,6 +8,7 @@ import com.sirenian.hellbound.domain.game.GameListener; import com.sirenian.hellbound.domain.game.GameState; import com.sirenian.hellbound.domain.glyph.GlyphListener; +import com.sirenian.hellbound.domain.glyph.GlyphMovement; import com.sirenian.hellbound.domain.glyph.GlyphType; import com.sirenian.hellbound.domain.glyph.Heartbeat; import com.sirenian.hellbound.domain.glyph.Junk; @@ -81,7 +82,12 @@ glyphListener.stubs("reportGlyphMovement").never(); heartbeat.beat(); -game.requestDropGlyph(); +game.requestGlyphMovement(GlyphMovement.DOWN); +game.requestGlyphMovement(GlyphMovement.LEFT); +game.requestGlyphMovement(GlyphMovement.RIGHT); +game.requestGlyphMovement(GlyphMovement.DROP); +game.requestGlyphMovement(GlyphMovement.ROTATE_LEFT); +game.requestGlyphMovement(GlyphMovement.ROTATE_RIGHT); verifyMocks(); } @@ -92,21 +98,21 @@ Segments latestSegments = GlyphType.T.getSegments(0).movedRight(3); game.requestStartGame(); -game.requestRotateGlyphLeft(); +game.requestGlyphMovement(GlyphMovement.ROTATE_LEFT); ensureThat(factory.glyph.getSegments(), eq(GlyphType.T.getSegments(1).movedRight(3))); -game.requestRotateGlyphRight(); +game.requestGlyphMovement(GlyphMovement.ROTATE_RIGHT); ensureThat(factory.glyph.getSegments(), eq(GlyphType.T.getSegments(0).movedRight(3))); -game.requestMoveGlyphLeft(); +game.requestGlyphMovement(GlyphMovement.LEFT); ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedLeft())); latestSegments = latestSegments.movedLeft(); -game.requestMoveGlyphRight(); +game.requestGlyphMovement(GlyphMovement.RIGHT); ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedRight())); latestSegments = latestSegments.movedRight(); - -game.requestMoveGlyphDown(); + +game.requestGlyphMovement(GlyphMovement.DOWN); ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedDown())); latestSegments = latestSegments.movedDown(); @@ -134,7 +140,7 @@ game.requestStartGame(); // When... -game.requestDropGlyph(); +game.requestGlyphMovement(GlyphMovement.DROP); heartbeat.beat(); //Then... Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/ThreadedEngineQueueBehaviour.java (609 => 610) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/ThreadedEngineQueueBehaviour.java 2006-12-04 16:25:01 UTC (rev 609) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/ThreadedEngineQueueBehaviour.java 2006-12-04 17:13:30 UTC (rev 610) @@ -3,6 +3,7 @@ import jbehave.core.mock.Mock; import com.sirenian.hellbound.domain.game.GameRequestListener; +import com.sirenian.hellbound.domain.glyph.GlyphMovement; import com.sirenian.hellbound.util.ThreadedQueueBehaviour; public class ThreadedEngineQueueBehaviour extends ThreadedQueueBehaviour { @@ -10,23 +11,12 @@ public void shouldPassAlongGameRequests() throws Exception { Mock listener = mock(GameRequestListener.class); -listener.expects("requestStartGame"); -listener.expects("requestDropGly
[jbehave-scm] [jbehave] [609] trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java: [EK] minor tidy up of game
Title: [jbehave] [609] trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java: [EK] minor tidy up of game Revision 609 Author sirenian Date 2006-12-04 10:25:01 -0600 (Mon, 04 Dec 2006) Log Message [EK] minor tidy up of game Modified Paths trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java Diff Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java (608 => 609) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java 2006-12-04 15:23:14 UTC (rev 608) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java 2006-12-04 16:25:01 UTC (rev 609) @@ -23,6 +23,7 @@ private final ListenerSet gameListeners; private final ListenerSet glyphListeners; private final ListenerNotifier stateNotifier; + private final HeartbeatListener heartbeatListener; private final int height; @@ -30,7 +31,6 @@ private LivingGlyph glyph = LivingGlyph.NULL; private Junk junk = Junk.NULL; -private HeartbeatListener heartbeatListener; public Game(GlyphFactory factory, Heartbeat heartbeat, int width, int height) { this.factory = factory; To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [603] trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java: [EK] Found the problem with the mocking of actions; pending now
Title: [jbehave] [603] trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java: [EK] Found the problem with the mocking of actions; pending now fixed. Revision 603 Author sirenian Date 2006-12-01 10:23:07 -0600 (Fri, 01 Dec 2006) Log Message [EK] Found the problem with the mocking of actions; pending now fixed. Modified Paths trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java Diff Modified: trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java (602 => 603) --- trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java 2006-12-01 16:04:35 UTC (rev 602) +++ trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java 2006-12-01 16:23:07 UTC (rev 603) @@ -14,7 +14,6 @@ import javax.swing.KeyStroke; import javax.swing.text.JTextComponent; -import jbehave.core.exception.PendingException; import jbehave.core.minimock.UsingMiniMock; import jbehave.core.mock.Constraint; import jbehave.core.mock.Mock; @@ -126,23 +125,17 @@ public void shouldSimulateKeyPressesForInputMap() throws TimeoutException { checkForHeadless(); -if (true) { throw new PendingException(); } DefaultWindowWrapper wrapper = new DefaultWindowWrapper("a.window"); try { -JFrame frame = disposeOnCloseFrame(); -JPanel panel = new JPanel(); -panel.getInputMap().put(KeyStroke.getKeyStroke(' '), "an action"); -frame.setContentPane(panel); -frame.setName("a.window"); -frame.pack(); -frame.setVisible(true); +AFrame frame = new AFrame(); + +Mock action = "" +action.stubs("isEnabled").will(returnValue(true)); +action.expects("actionPerformed").with(anything()); +frame.contentPanel.getActionMap().put("an action", (Action) action); -Mock action = "" -action.expects("actionPerformed"); -panel.getActionMap().put("an action", (Action) action); - wrapper.pressKeychar(' '); verifyMocks(); @@ -189,5 +182,18 @@ new HeadlessChecker().check(); } +public class AFrame extends JFrame { +private JPanel contentPanel = new JPanel(); +public AFrame() { +setName("a.window"); +setContentPane(contentPanel); +contentPanel.getInputMap().put(KeyStroke.getKeyStroke(' '), "an action"); + +this.pack(); +this.setVisible(true); + +this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); +} +} } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [602] trunk/core/src/java/jbehave/core/mock: [EK] Lots of little fixes; some Hellbound stuff.
Title: [jbehave] [602] trunk/core/src/java/jbehave/core/mock: [EK] Lots of little fixes; some Hellbound stuff. Revision 602 Author sirenian Date 2006-12-01 10:04:35 -0600 (Fri, 01 Dec 2006) Log Message [EK] Lots of little fixes; some Hellbound stuff. Still struggling with the Swing components so 1 behaviour pending. Modified Paths trunk/core/src/behaviour/jbehave/core/UsingConstraintsBehaviour.java trunk/core/src/java/jbehave/core/exception/VerificationException.java trunk/core/src/java/jbehave/core/mock/UsingConstraints.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/AllBehaviours.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/game/GameRequestListener.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/ThreadedEngineQueue.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/HellboundFrame.java trunk/examples/hellbound/src/stories/com/sirenian/hellbound/events/HellboundEvent.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/WindowGrabberBehaviour.java trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/ComponentFinderBehaviour.java trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/WindowWrapper.java Added Paths trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/HeadlessCheckerBehaviour.java trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/HeadlessChecker.java Removed Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ConstructorFactoryBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java Diff Modified: trunk/core/src/behaviour/jbehave/core/UsingConstraintsBehaviour.java (601 => 602) --- trunk/core/src/behaviour/jbehave/core/UsingConstraintsBehaviour.java 2006-12-01 15:44:40 UTC (rev 601) +++ trunk/core/src/behaviour/jbehave/core/UsingConstraintsBehaviour.java 2006-12-01 16:04:35 UTC (rev 602) @@ -1,9 +1,21 @@ package jbehave.core; +import jbehave.core.exception.VerificationException; import jbehave.core.mock.UsingConstraints; public class UsingConstraintsBehaviour extends UsingConstraints { +Block EXCEPTION_BLOCK = new Block() { +public void run() throws Exception { +throw new NumberFormatException(); +} +}; + + +Block EMPTY_BLOCK = new Block() { +public void run() throws Exception {} +}; + public void shouldProvideConstraintsForDoubles() { ensureThat(5.0, eq(5.0)); ensureThat(5.0, not(eq(5.1))); @@ -28,4 +40,29 @@ ensureThat(true, not(eq(false))); ensureThat(true, eq(true), "message"); } + +public void shouldProvideConstraintToCheckForNull() { +ensureThat(null, isNull()); +ensureThat(new Object(), isNotNull()); +} + +public void shouldEnsureThatBlocksThrowTheRightTypeOfExceptionOrNot() throws Exception { + +ensureThrows(IllegalArgumentException.class, EXCEPTION_BLOCK); +ensureDoesNotThrowException(EMPTY_BLOCK); + +try { +ensureThrows(IllegalArgumentException.class, EMPTY_BLOCK); +fail("Should have thrown a verification exception"); +} catch (VerificationException e) { +// expected +} + +try { +ensureDoesNotThrowException(EXCEPTION_BLOCK); +fail("Should have thrown a verification exception"); +} catch (VerificationException e) { +// expected +} +} } Modified: trunk/core/src/java/jbehave/core/exception/VerificationException.java (601 => 602) --- trunk/core/src/java/jbehave/core/exception/VerificationException.java 2006-12-01 15:44:40 UTC (rev 601) +++ trunk/core/src/java/jbehave/core/exception/VerificationException.java 2006-12-01 16:04:35 UTC (rev 602) @@ -26,7 +26,13 @@ this(message, null, null); } - public Object getActual() { + public VerificationException(String message, Exception e) { +super(message, e); +expected = null; +actual = null; +} + +public Object getActual() { return actual; } Modified: trunk/core/src/java/jbehave/core/mock/UsingConstraints.java (601 => 602) --- trunk/core/src/java/jbeha
[jbehave-scm] [jbehave] [600] trunk/.classpath: [EK] Fixed classpath.
Title: [jbehave] [600] trunk/.classpath: [EK] Fixed classpath. Revision 600 Author sirenian Date 2006-12-01 09:43:04 -0600 (Fri, 01 Dec 2006) Log Message [EK] Fixed classpath. Modified Paths trunk/.classpath Diff Modified: trunk/.classpath (599 => 600) --- trunk/.classpath 2006-12-01 11:18:45 UTC (rev 599) +++ trunk/.classpath 2006-12-01 15:43:04 UTC (rev 600) @@ -1,11 +1,13 @@ + + - - + + @@ -20,17 +22,18 @@ - + - - + - + + + To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [601] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java: [EK] Fix to junk behaviour
Title: [jbehave] [601] trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java: [EK] Fix to junk behaviour Revision 601 Author sirenian Date 2006-12-01 09:44:40 -0600 (Fri, 01 Dec 2006) Log Message [EK] Fix to junk behaviour Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java (600 => 601) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java 2006-12-01 15:43:04 UTC (rev 600) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/JunkBehaviour.java 2006-12-01 15:44:40 UTC (rev 601) @@ -25,7 +25,7 @@ Segments originalSegments = glyph.getSegments(); Junk junk = new Junk(); - +glyphListener.expects("reportGlyphMovement").with(new Constraint[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)}); glyphListener.expects("reportGlyphMovement").with(new Constraint[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(originalSegments)}); junk.addListener((GlyphListener)glyphListener); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [599] trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing: [EK] Fixed a small intermittent bug with window wrapper; added class mock behaviour for stubs.
Title: [jbehave] [599] trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing: [EK] Fixed a small intermittent bug with window wrapper; added class mock behaviour for stubs. Revision 599 Author sirenian Date 2006-12-01 05:18:45 -0600 (Fri, 01 Dec 2006) Log Message [EK] Fixed a small intermittent bug with window wrapper; added class mock behaviour for stubs. Modified Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (598 => 599) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-12-01 10:50:08 UTC (rev 598) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-12-01 11:18:45 UTC (rev 599) @@ -63,8 +63,4 @@ public void shouldBeAbleToMockMostClassesWithConstructorArgs() { ClassMockObject.mockClass(AClassWithAComplexConstructor.class, "foo"); } - -public void shouldBeAbleToProvideMinimalProblemClassConstructorsAndHaveTheFactoryFillInTheRest() { - throw new PendingException(); -} } Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java (598 => 599) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java 2006-12-01 10:50:08 UTC (rev 598) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java 2006-12-01 11:18:45 UTC (rev 599) @@ -22,6 +22,12 @@ } public void shouldBeAbleToStubClasses() { - throw new PendingException(); +Object expected = new Object(); + +Mock mock = classMock.mock(HashMap.class); +mock.stubs("get").will(returnValue(expected)); + +Object actual = ((HashMap)mock).get("some key"); +ensureThat(expected, eq(actual)); } } Modified: trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java (598 => 599) --- trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java 2006-12-01 10:50:08 UTC (rev 598) +++ trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java 2006-12-01 11:18:45 UTC (rev 599) @@ -84,16 +84,15 @@ } public void pressKey(int keycode) throws TimeoutException { -//try { -sysQueue.postEvent(createKeyPressEvent(getWindow().getFocusOwner(), keycode, KeyEvent.KEY_PRESSED)); -sysQueue.postEvent(createKeyPressEvent(getWindow().getFocusOwner(), keycode, KeyEvent.KEY_RELEASED)); -//Robot robot = new Robot(); -//robot.keyPress(keycode); -//robot.keyRelease(keycode); -//} catch (AWTException e) { -//throw new RuntimeException(e); -//} +//NB: Don't use the Robot. +//Why not the Robot? +//Because the Robot tries to press the space bar, which is really annoying if you're running things +//from Eclipse's vm. + +sysQueue.postEvent(createKeyPressEvent(getWindow(), keycode, KeyEvent.KEY_PRESSED)); +sysQueue.postEvent(createKeyPressEvent(getWindow(), keycode, KeyEvent.KEY_RELEASED)); + idler.waitForIdle(); } public Component findComponent(String componentName) throws ComponentFinderException, TimeoutException { To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [598] trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui: [EK] Hellbound and swing behaviours now work in both 1.4 and 1.5 vms (Windows, but not the Microsoft vm whic
Title: [jbehave] [598] trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui: [EK] Hellbound and swing behaviours now work in both 1.4 and 1.5 vms (Windows, but not the Microsoft vm which is still buggy buggy buggy.) Revision 598 Author sirenian Date 2006-12-01 04:50:08 -0600 (Fri, 01 Dec 2006) Log Message [EK] Hellbound and swing behaviours now work in both 1.4 and 1.5 vms (Windows, but not the Microsoft vm which is still buggy buggy buggy.) Modified Paths trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java trunk/extensions/swing/src/behaviour/jbehave/extensions/threaded/swing/DefaultWindowWrapperBehaviour.java trunk/extensions/swing/src/java/jbehave/extensions/threaded/swing/DefaultWindowWrapper.java Diff Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java (597 => 598) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2006-11-30 15:28:46 UTC (rev 597) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/HellboundFrameBehaviour.java 2006-12-01 10:50:08 UTC (rev 598) @@ -30,35 +30,51 @@ } public void tearDown() { - frame.dispose(); + try { +windowWrapper.closeWindow(); +} catch (TimeoutException e) { +throw new RuntimeException(e); +} } public void shouldDisplayTheFrontPanelWhenTheGameIsReady() { +setUp(); frame.reportGameStateChanged(GameState.READY); ensureThat(frontPanel.isShowing()); ensureThat(!gamePanel.isShowing()); +tearDown(); } public void shouldDisplayGamePanelWhenTheGameIsRunning() { +setUp(); frame.reportGameStateChanged(GameState.RUNNING); ensureThat(!frontPanel.isShowing()); ensureThat(gamePanel.isShowing()); +tearDown(); } public void shouldRequestThatTheShapeIsDroppedWhenTheSpaceKeyIsPressed() throws Exception { +setUp(); ensureThatKeycodeProducesRequest(KeyEvent.VK_SPACE, "requestDropGlyph"); +tearDown(); } public void shouldRequestThatTheShapeIsMovedRightWhenTheRightKeyIsPressed() throws Exception { +setUp(); ensureThatKeycodeProducesRequest(KeyEvent.VK_RIGHT, "requestMoveGlyphRight"); +tearDown(); } public void shouldRequestThatTheShapeIsMovedLeftWhenTheMoveLeftKeyIsPressed() throws Exception { +setUp(); ensureThatKeycodeProducesRequest(KeyEvent.VK_LEFT, "requestMoveGlyphLeft"); +tearDown(); } public void shouldRequestThatTheShapeIsMovedDownWhenTheMoveDownKeyIsPressed() throws Exception { -ensureThatKeycodeProducesRequest(KeyEvent.VK_DOWN, "requestDropGlyph"); +setUp(); +ensureThatKeycodeProducesRequest(KeyEvent.VK_DOWN, "requestMoveGlyphDown"); +tearDown(); } private void ensureThatKeycodeProducesRequest(int keycode, String expectedRequest) throws TimeoutException { Modified: trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java (597 => 598) --- trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java 2006-11-30 15:28:46 UTC (rev 597) +++ trunk/examples/hellbound/src/java/com/sirenian/hellbound/gui/ActionFactory.java 2006-12-01 10:50:08 UTC (rev 598) @@ -6,18 +6,21 @@ import javax.swing.Action; import com.sirenian.hellbound.domain.game.GameRequestListener; +import com.sirenian.hellbound.util.Logger; public class ActionFactory { public Action right(final GameRequestListener gameRequestListener) { return new AbstractAction() { public void actionPerformed(ActionEvent e) { +Logger.debug(this, "Adding right action to frame action map"); gameRequestListener.requestMoveGlyphRight(); } }; } public Action left(final GameRequestListener gameRequestListener) { +Logger.debug(this, "Adding left action to frame action map"); return new AbstractAction() { public void actionPerformed(ActionEvent e) { gameRequestListener.requestMoveGlyphLeft(); @@ -28,6 +31,7 @@ public Action down(final GameRequestListener gameRequestListener) { return new AbstractAction() { public void actionPerformed(ActionEvent e) { +Logger.debug(this, "Adding down action to frame action map"); gameRequestListener.requestMoveGlyphDown(); } }; @@ -36,6 +40,7 @@ public Action drop(final GameRequestListener gameRequestListener) { return new AbstractAction() { public void actionPerformed(ActionEvent e) { +Logger.debug(this, "Addi
[jbehave-scm] [jbehave] [595] trunk: [EK] Build is fixed (and classes can still mostly be mocked, thanks to ProxyToys!) but some hellbound swing stuff still failing in 1.4.
Title: [jbehave] [595] trunk: [EK] Build is fixed (and classes can still mostly be mocked, thanks to ProxyToys!) but some hellbound swing stuff still failing in 1.4. Revision 595 Author sirenian Date 2006-11-30 05:53:58 -0600 (Thu, 30 Nov 2006) Log Message [EK] Build is fixed (and classes can still mostly be mocked, thanks to ProxyToys!) but some hellbound swing stuff still failing in 1.4. Modified Paths trunk/build.xml trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/LivingGlyphBehaviour.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/VerifiableGlyphListener.java trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/domain/glyph/LivingGlyph.java trunk/examples/hellbound/src/java/com/sirenian/hellbound/engine/Game.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/UsingClassMock.java Added Paths trunk/lib/extensions/proxytoys-0.2.1.jar Diff Modified: trunk/build.xml (594 => 595) --- trunk/build.xml 2006-11-30 07:26:29 UTC (rev 594) +++ trunk/build.xml 2006-11-30 11:53:58 UTC (rev 595) @@ -19,6 +19,7 @@ + @@ -97,7 +98,7 @@ - + Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/LivingGlyphBehaviour.java (594 => 595) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/LivingGlyphBehaviour.java 2006-11-30 07:26:29 UTC (rev 594) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/LivingGlyphBehaviour.java 2006-11-30 11:53:58 UTC (rev 595) @@ -59,12 +59,40 @@ Segments firstSegments = listener.toLastSegments(); ensureThat(!glyph.requestMoveDown()); +ensureThat(!glyph.requestMoveRight()); +ensureThat(!glyph.requestMoveLeft()); Segments secondSegments = listener.toLastSegments(); ensureThat(firstSegments, eq(secondSegments)); } +public void shouldMoveIfNotInCollision() { +CollisionDetector detector = new CollisionDetector() { +public boolean collides(Segments segments) { +return false; +} +}; + +glyph = new LivingGlyph( +GlyphType.O, +detector, +4); + +Segments latestSegments = glyph.getSegments(); + +ensureThat(glyph.requestMoveDown()); +ensureThat(glyph.getSegments(), eq(latestSegments.movedDown())); +latestSegments = latestSegments.movedDown(); + +ensureThat(glyph.requestMoveRight()); +ensureThat(glyph.getSegments(), eq(latestSegments.movedRight())); +latestSegments = latestSegments.movedRight(); + +ensureThat(glyph.requestMoveLeft()); +ensureThat(glyph.getSegments(), eq(latestSegments.movedLeft())); +} + public void shouldReduceSegmentsToEmptyIfKilled() { setUp(); Segments originalSegments = glyph.getSegments(); Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/VerifiableGlyphListener.java (594 => 595) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/VerifiableGlyphListener.java 2006-11-30 07:26:29 UTC (rev 594) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/domain/glyph/VerifiableGlyphListener.java 2006-11-30 11:53:58 UTC (rev 595) @@ -9,7 +9,6 @@ private Segments fromSegments; public void reportGlyphMovement(GlyphType type, Segments fromSegments, Segments toSegments) { -Logger.debug(this, "Glyph movement reported from " + fromSegments + " to " + toSegments + " with type " + type); this.fromSegments = fromSegments; this.toSegments = toSegments; this.type = type; Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java (594 => 595) --- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-11-30 07:26:29 UTC (rev 594) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/engine/GameBehaviour.java 2006-11-30 11:53:58 UTC (rev 595) @@ -86,24 +86,22 @@ verifyMocks(); } -public void shouldDelegateMovementRequestsToGlyph() { -Mock glyphFactory = mock(GlyphFactory.class); -Mock glyph = mock(LivingGlyph.class, new Class[]{GlyphType.class, CollisionDetector.class, int.class}, -new Object[] {GlyphType.NULL, CollisionDetector.NULL, Integer.valueOf(3)}); -glyphFactory.stubs("nextGly
[jbehave-scm] [jbehave] [593] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] Fixed 1.4 compilation errors (target in build isn't enough?)
Title: [jbehave] [593] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] Fixed 1.4 compilation errors (target in build isn't enough?) Revision 593 Author sirenian Date 2006-11-30 01:08:14 -0600 (Thu, 30 Nov 2006) Log Message [EK] Fixed 1.4 compilation errors (target in build isn't enough?) Modified Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java Diff Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (592 => 593) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 18:17:40 UTC (rev 592) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-30 07:08:14 UTC (rev 593) @@ -97,8 +97,8 @@ AClassWithNoConstructorsAtAll.class}, new Object[] { "", -Integer.valueOf(0), -Character.valueOf(' '), +new Integer(0), +new Character(' '), new Object[0], AClassWithNoConstructorsAtAll.INSTANCE}); } Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java (592 => 593) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java 2006-11-29 18:17:40 UTC (rev 592) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java 2006-11-30 07:08:14 UTC (rev 593) @@ -35,8 +35,8 @@ AClassWithNoConstructorsAtAll.class}, new Object[] { "", -Integer.valueOf(0), -Character.valueOf(' '), +new Integer(0), +new Character(' '), new Object[0], AClassWithNoConstructorsAtAll.INSTANCE}); mock.expects("getSomething").will(returnValue(expected)); Modified: trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java (592 => 593) --- trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java 2006-11-29 18:17:40 UTC (rev 592) +++ trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java 2006-11-30 07:08:14 UTC (rev 593) @@ -94,7 +94,7 @@ private static IllegalArgumentException caughtANullPointer(final Class type, Throwable e) { return new IllegalArgumentException("Caught a NullPointerException while trying to mock a " + type + ". This could be caused " + "because a constructor argument that couldn't be instantiated was used in the constructor. Have you tried " + -"providing constructor arguments?", e); +"providing constructor arguments?"); } Modified: trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java (592 => 593) --- trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java 2006-11-29 18:17:40 UTC (rev 592) +++ trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java 2006-11-30 07:08:14 UTC (rev 593) @@ -28,17 +28,17 @@ } else if (clazz == boolean.class) { return Boolean.FALSE; } else if (clazz == char.class) { - return Character.valueOf(' '); + return new Character(' '); } else if (clazz == double.class) { - return Double.valueOf(0); + return new Double(0); } else if (clazz == float.class) { - return Float.valueOf(0); + return new Float(0); } else if (clazz == int.class) { - return Integer.valueOf(0); + return new Integer(0); } else if (clazz == long.class) { - return Long.valueOf(0L); + return new Long(0L); } else if (clazz == short.class) { - return Short.valueOf((short) 0); + return new Short((short) 0); } else { throw new IllegalArgumentException("Never heard of a primitive called " + clazz + " before. "); } To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [592] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] More mock stuff.
Title: [jbehave] [592] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] More mock stuff. Revision 592 Author sirenian Date 2006-11-29 12:17:40 -0600 (Wed, 29 Nov 2006) Log Message [EK] More mock stuff. This will need tidying up at some point. Modified Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/UsingClassMock.java Added Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ConstructorFactoryBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ConstructorFactory.java Diff Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (591 => 592) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 17:03:19 UTC (rev 591) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 18:17:40 UTC (rev 592) @@ -4,6 +4,7 @@ import jbehave.core.Block; import jbehave.core.Ensure; +import jbehave.core.exception.PendingException; import jbehave.core.minimock.UsingMiniMock; import jbehave.core.mock.Mock; @@ -18,17 +19,39 @@ } } - private static class AClassWithNoConstructors {} + private static class AClassWithNoDeclaredConstructors {} public static class AClassWithAComplexConstructor { -public AClassWithAComplexConstructor(String anObject, int primitive, char primitive2, Object[] array) { -anObject.compareTo("What happens if the argument is null?"); +public AClassWithAComplexConstructor( + String anObject, + int primitive, + char primitive2, + Object[] array) { +anObject.compareTo("A string"); int i = primitive + array.length; +i++; // just to stop the unused warnings } - } +public static class AClassWithAReallyNastyConstructor { + public AClassWithAReallyNastyConstructor( + String anObject, + int primitive, + char primitive2, + Object[] array, + AClassWithNoConstructorsAtAll someEnum) { +anObject.compareTo(someEnum.toString()); +int i = primitive + array.length; +i++; // just to stop the unused warnings +} +} + +public static class AClassWithNoConstructorsAtAll { + public static final Object INSTANCE = new AClassWithNoConstructorsAtAll(); + private AClassWithNoConstructorsAtAll() {} +} + public void shouldCreateClassObjectThatCanBeCastToTheCorrectType() { Mock mock = ClassMockObject.mockClass(AClass.class, "bar"); Ensure.that(mock instanceof AClass); @@ -49,7 +72,7 @@ public void shouldThrowAnIllegalArgumentExceptionIfClassHasNoConstructors() throws Exception { Ensure.throwsException(IllegalArgumentException.class, new Block() { public void run() throws Exception { -ClassMockObject.mockClass(AClassWithNoConstructors.class, "bar"); +ClassMockObject.mockClass(AClassWithNoDeclaredConstructors.class, "bar"); } }); } @@ -62,8 +85,37 @@ Object actual = ((HashMap)mock).get("a key"); ensureThat(expected, eq(actual)); } + +public void shouldBeAbleToProvideDefaultInstancesForConstructorClasses() { + Mock mock = ClassMockObject.mockClass( + AClassWithAReallyNastyConstructor.class, "foo", + new Class[] { +String.class, + int.class, + char.class, + Object[].class, + AClassWithNoConstructorsAtAll.class}, + new Object[] { +"", +Integer.valueOf(0), +Character.valueOf(' '), +new Object[0], +AClassWithNoConstructorsAtAll.INSTANCE}); +} -public void shouldBeAbleToMockClassesWithConstructorArgs() { - Mock mock = ClassMockObject.mockClass(AClassWithAComplexConstructor.class, "foo"); +public void shouldBeAbleToMockMostClassesWithConstructorArgs() { + ClassMockObject.mockClass(AClassWithAComplexConstructor.class, "foo"); } + +public void shouldRethrowNullPointerExceptionsWithSuggestionWhenConstructorFails() throws Exception { + ensureThrows(IllegalArgumentException.class, new Block() { + public void run() throws Exception { +ClassMockObject.mockClass(AClassWithAReallyNastyConstructor.class, "foo"); + } + }); +} + +public void shouldBeAbleToProvideMinimalProblemClassConstructorsAndHaveT
[jbehave-scm] [jbehave] [591] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] Can mock objects which use their constructor arguments inside their constructor.
Title: [jbehave] [591] trunk/extensions/classmocks/src/java/jbehave/extensions/classmock: [EK] Can mock objects which use their constructor arguments inside their constructor. Revision 591 Author sirenian Date 2006-11-29 11:03:19 -0600 (Wed, 29 Nov 2006) Log Message [EK] Can mock objects which use their constructor arguments inside their constructor. How cool is that? Modified Paths trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java Diff Modified: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (590 => 591) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 15:15:11 UTC (rev 590) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 17:03:19 UTC (rev 591) @@ -19,7 +19,16 @@ } private static class AClassWithNoConstructors {} - + + +public static class AClassWithAComplexConstructor { +public AClassWithAComplexConstructor(String anObject, int primitive, char primitive2, Object[] array) { +anObject.compareTo("What happens if the argument is null?"); +int i = primitive + array.length; +} + +} + public void shouldCreateClassObjectThatCanBeCastToTheCorrectType() { Mock mock = ClassMockObject.mockClass(AClass.class, "bar"); Ensure.that(mock instanceof AClass); @@ -54,5 +63,7 @@ ensureThat(expected, eq(actual)); } - +public void shouldBeAbleToMockClassesWithConstructorArgs() { + Mock mock = ClassMockObject.mockClass(AClassWithAComplexConstructor.class, "foo"); +} } Modified: trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java (590 => 591) --- trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java 2006-11-29 15:15:11 UTC (rev 590) +++ trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java 2006-11-29 17:03:19 UTC (rev 591) @@ -76,9 +76,57 @@ } private static Object[] createConstructorArgsFor(Class[] constructorArgClasses) { - return new Object[constructorArgClasses.length]; + Object[] args = new Object[constructorArgClasses.length]; + + for (int i = 0; i < args.length; i++) { + Class clazz = constructorArgClasses[i]; + try { +Object result = construct(clazz); +args[i] = result; + } catch (Exception e) { +throw new RuntimeException("Could not mock class " + constructorArgClasses[i] + " at index " + i, e); + } + } + + return args; } + private static Object construct(Class clazz) throws InstantiationException, IllegalAccessException { + Object result = null; + if (clazz.isPrimitive()) { + result = constructPrimitive(clazz); + } else if (clazz.isArray()) { + result = new Object[] {}; + } else if (Modifier.isFinal(clazz.getModifiers())) { + result = clazz.newInstance(); + } else { + result = new UsingClassMock().mock(clazz); + } + return result; + } + + private static Object constructPrimitive(Class clazz) { + if (clazz == byte.class) { + return new Byte((byte) 0); + } else if (clazz == boolean.class) { + return Boolean.FALSE; + } else if (clazz == char.class) { + return new Character(' '); + } else if (clazz == double.class) { + return new Double(0); + } else if (clazz == float.class) { + return new Float(0); + } else if (clazz == int.class) { + return new Integer(0); + } else if (clazz == long.class) { + return new Long(0L); + } else if (clazz == short.class) { + return new Short((short) 0); + } else { + throw new IllegalArgumentException("Never heard of a primitive called " + clazz + " before. "); + } + } + private class ExpectationHandlerDelegate extends ExpectationHandler implements MethodInterceptor { public Object intercept(Object thisProxy, Method method, Object[] args, MethodProxy superProxy) throws Throwable { return this.invoke(thisProxy, method, args); To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
[jbehave-scm] [jbehave] [590] trunk/extensions: [EK] Class mocks!
Title: [jbehave] [590] trunk/extensions: [EK] Class mocks! Revision 590 Author sirenian Date 2006-11-29 09:15:11 -0600 (Wed, 29 Nov 2006) Log Message [EK] Class mocks! Modified Paths trunk/core/src/java/jbehave/core/minimock/MiniMockObject.java trunk/core/src/java/jbehave/core/minimock/UsingMiniMock.java trunk/everything/src/behaviour/jbehave/AllBehaviours.java Added Paths trunk/extensions/classmocks/ trunk/extensions/classmocks/src/ trunk/extensions/classmocks/src/behaviour/ trunk/extensions/classmocks/src/behaviour/jbehave/ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/UsingClassMockBehaviour.java trunk/extensions/classmocks/src/java/ trunk/extensions/classmocks/src/java/jbehave/ trunk/extensions/classmocks/src/java/jbehave/extensions/ trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/ClassMockObject.java trunk/extensions/classmocks/src/java/jbehave/extensions/classmock/UsingClassMock.java Diff Modified: trunk/core/src/java/jbehave/core/minimock/MiniMockObject.java (589 => 590) --- trunk/core/src/java/jbehave/core/minimock/MiniMockObject.java 2006-11-28 12:03:30 UTC (rev 589) +++ trunk/core/src/java/jbehave/core/minimock/MiniMockObject.java 2006-11-29 15:15:11 UTC (rev 590) @@ -27,7 +27,7 @@ * * @author Dan North */ -class MiniMockObject implements Mock, ExpectationRegistry { +public class MiniMockObject implements Mock, ExpectationRegistry { private final List expectations = new ArrayList(); private final List unexpectedInvocations = new ArrayList(); private final Class type; @@ -44,7 +44,7 @@ } /** Manages method invocations on the mock */ -private class ExpectationHandler implements InvocationHandler { +protected class ExpectationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (args == null) args = new Object[0]; @@ -110,6 +110,10 @@ this.fallbackBehaviour = new StubInvocationHandler(name); } +protected Class getType() { + return type; +} + /** get the mocked instance */ public Object proxy() { return Proxy.newProxyInstance(type.getClassLoader(), new Class[] {type}, new ExpectationHandler()); Modified: trunk/core/src/java/jbehave/core/minimock/UsingMiniMock.java (589 => 590) --- trunk/core/src/java/jbehave/core/minimock/UsingMiniMock.java 2006-11-28 12:03:30 UTC (rev 589) +++ trunk/core/src/java/jbehave/core/minimock/UsingMiniMock.java 2006-11-29 15:15:11 UTC (rev 590) @@ -36,11 +36,15 @@ } public Mock mock(Class type, String name) { -Mock mock = MiniMockObject.mock(type, name); +Mock mock = createMock(type, name); mocks.add(mock); return mock; } + protected Mock createMock(Class type, String name) { + return MiniMockObject.mock(type, name); + } + public void verifyMocks() { for (Iterator i = mocks.iterator(); i.hasNext();) { ((Mock) i.next()).verify(); Modified: trunk/everything/src/behaviour/jbehave/AllBehaviours.java (589 => 590) --- trunk/everything/src/behaviour/jbehave/AllBehaviours.java 2006-11-28 12:03:30 UTC (rev 589) +++ trunk/everything/src/behaviour/jbehave/AllBehaviours.java 2006-11-29 15:15:11 UTC (rev 590) @@ -7,7 +7,7 @@ return new Class[] { jbehave.core.AllBehaviours.class, jbehave.ant.AllBehaviours.class, -jbehave.jmock.AllBehaviours.class, +//jbehave.jmock.AllBehaviours.class, jbehave.junit.AllBehaviours.class, jbehave.core.story.AllBehaviours.class }; Added: trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (0 => 590) --- trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java (rev 0) +++ trunk/extensions/classmocks/src/behaviour/jbehave/extensions/classmock/ClassMockObjectBehaviour.java 2006-11-29 15:15:11 UTC (rev 590) @@ -0,0 +1,58 @@ +package jbehave.extensions.classmock; + +import java.util.HashMap; + +import jbehave.core.Block; +import jbehave.core.Ensure; +import jbehave.core.minimock.UsingMiniMock; +import jbehave.core.mock.Mock; + +public class ClassMockObjectBehaviour extends UsingMiniMock { + public static class AClass {} + + public class ANonStaticInnerClass {} + + public static class AClassWithConstructorArgs { + public AClassWithConstructorArgs(Object arg) { + + } + } + + private static class AClassWithNoConstructors {} + +public void shouldCreateClassObjectThatCanBeCastToTheCorrectType() { +Mock mock = ClassMockObje
[jbehave-scm] [jbehave] [589] trunk/examples/hellbound/src/stories: [EK] Converted Hellbound stories to match the rendered output.
Title: [jbehave] [589] trunk/examples/hellbound/src/stories: [EK] Converted Hellbound stories to match the rendered output. Revision 589 Author sirenian Date 2006-11-28 06:03:30 -0600 (Tue, 28 Nov 2006) Log Message [EK] Converted Hellbound stories to match the rendered output. Added Paths trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame.story trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story Removed Paths trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame trunk/examples/hellbound/src/stories/ThePlayerMakesALine Diff Added: trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story (0 => 589) --- trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story (rev 0) +++ trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story 2006-11-28 12:03:30 UTC (rev 589) @@ -0,0 +1,24 @@ +Story: the glyph is constrained by the pit + +As a game player +I want the glyph to be constrained by the pit +So that the game has boundaries + +Scenario: the glyph will not move right + +Given the glyph is against the right wall +When the player presses the right key +Then the glyph will not move + +Scenario: the glyph will not move left + +Given the glyph is against the left wall +When the player presses the left key +Then the glyph will not move + +Scenario: the glyph will not move down + +Given the glyph is against the floor +When the player presses the down key +Then the glyph becomes junk +and the next glyph appears Deleted: trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses (588 => 589) --- trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses 2006-11-28 11:36:30 UTC (rev 588) +++ trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses 2006-11-28 12:03:30 UTC (rev 589) @@ -1,12 +0,0 @@ -Title: The Glyph Moves As Time Passes -As a game player -I want the glyph to move downwards as time passes -So that the game is a challenge - -Scenario: The Player Sees The First Glyph Moves -Given Hellbound is running -When the player starts the game -Then the first glyph should be displayed in the pit -And when time passes -Then the glyph should move downwards - Added: trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story (0 => 589) --- trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story (rev 0) +++ trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story 2006-11-28 12:03:30 UTC (rev 589) @@ -0,0 +1,11 @@ +Story: the glyph moves as time passes + +As a game player +I want the glyph to move downwards as time passes +So that the game is a challenge + +Scenario: the player sees the first glyph move + +Given the first glyph is displayed on the board +When time passes +Then the glyph should move downwards Deleted: trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph (588 => 589) --- trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph 2006-11-28 11:36:30 UTC (rev 588) +++ trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph 2006-11-28 12:03:30 UTC (rev 589) @@ -1,18 +0,0 @@ -Title: The Player Drops The Glyph -As a game player -I want to drop the glyph -So that I can save time - -Scenario: The player drops the glyph into an empty pit -Given the first glyph is displayed on the board -And when the player presses the drop button -Then the glyph should fall to the bottom -And then the glyph segments should become junk -And then the next glyph should appear - -Scenario: The player drops the glyph onto junk -Given the player drops the glyph into an empty pit -Whe the player presses the drop button -Then the glyph should fall onto the junk -And then the glyph segments should become junk -And then the next glyph should appear Added: trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story (0 => 589) --- trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story (rev 0) +++ trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story 2006-11-28 12:03:30 UTC (rev 589) @@ -0,0 +1,22 @@ +Story: the player drops the glyph + +As a game player +I want to drop the glyph +So that I can save time + +Scenario: the player drops the glyph into an empty pit + +Given the first glyph is displayed on the board +When the player presses the drop key +Then the glyph should fall to the bottom +When time passes +Then the glyph segments should become junk +and the next glyph should appear + +Scenario: The player
[jbehave-scm] [jbehave] [585] trunk/plugins/eclipse: [FL] F3 through to story components from story text
Title: [jbehave] [585] trunk/plugins/eclipse: [FL] F3 through to story components from story text Revision 585 Author sirenian Date 2006-11-27 05:52:36 -0600 (Mon, 27 Nov 2006) Log Message [FL] F3 through to story components from story text Modified Paths trunk/plugins/eclipse/META-INF/MANIFEST.MF trunk/plugins/eclipse/plugin.xml Added Paths trunk/plugins/eclipse/.settings/ trunk/plugins/eclipse/.settings/org.eclipse.jdt.core.prefs trunk/plugins/eclipse/.settings/org.eclipse.jdt.ui.prefs trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/actions/ trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/actions/NavigateToJavaSource.java trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/editors/ trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/editors/BehaviourEditor.java Diff Added: trunk/plugins/eclipse/.settings/org.eclipse.jdt.core.prefs (0 => 585) --- trunk/plugins/eclipse/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/plugins/eclipse/.settings/org.eclipse.jdt.core.prefs 2006-11-27 11:52:36 UTC (rev 585) @@ -0,0 +1,12 @@ +#Mon Nov 27 11:25:29 GMT 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 Added: trunk/plugins/eclipse/.settings/org.eclipse.jdt.ui.prefs (0 => 585) --- trunk/plugins/eclipse/.settings/org.eclipse.jdt.ui.prefs (rev 0) +++ trunk/plugins/eclipse/.settings/org.eclipse.jdt.ui.prefs 2006-11-27 11:52:36 UTC (rev 585) @@ -0,0 +1,3 @@ +#Mon Nov 27 11:25:29 GMT 2006 +eclipse.preferences.version=1 +internal.default.compliance=default Modified: trunk/plugins/eclipse/META-INF/MANIFEST.MF (584 => 585) --- trunk/plugins/eclipse/META-INF/MANIFEST.MF 2006-11-27 11:06:28 UTC (rev 584) +++ trunk/plugins/eclipse/META-INF/MANIFEST.MF 2006-11-27 11:52:36 UTC (rev 585) @@ -17,6 +17,10 @@ org.eclipse.core.resources, org.eclipse.jdt.source, org.eclipse.jdt.ui, - org.eclipse.core.expressions + org.eclipse.core.expressions, + org.eclipse.jface.text, + org.eclipse.ui.editors, + org.eclipse.ui.workbench.texteditor Eclipse-AutoStart: true Bundle-Vendor: JBehave +Bundle-ClassPath: lib/commons-lang-1.0.1.jar Modified: trunk/plugins/eclipse/plugin.xml (584 => 585) --- trunk/plugins/eclipse/plugin.xml 2006-11-27 11:06:28 UTC (rev 584) +++ trunk/plugins/eclipse/plugin.xml 2006-11-27 11:52:36 UTC (rev 585) @@ -98,5 +98,35 @@ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="M3+M2+D B"/> + + + + + + + + + + + Added: trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/actions/NavigateToJavaSource.java (0 => 585) --- trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/actions/NavigateToJavaSource.java (rev 0) +++ trunk/plugins/eclipse/src/main/java/jbehave/plugin/eclipse/actions/NavigateToJavaSource.java 2006-11-27 11:52:36 UTC (rev 585) @@ -0,0 +1,140 @@ +package jbehave.plugin.eclipse.actions; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import jbehave.plugin.eclipse.editors.BehaviourEditor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.search.IJavaSearchConstants; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.core.search.SearchMatch; +import org.eclipse.jdt.core.search.SearchParticipant; +import org.eclipse.jdt.core.search.SearchPattern; +import org.eclipse.jdt.core.search.SearchRequestor; +import org.eclipse.jdt.core.search.TypeNameRequestor; +import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.INavigationLocation; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.texteditor.IDocumentProvider; +import org.eclipse.ui.texteditor.TextSelectionNavigationLocation; + +public class NavigateToJavaSource implements IEditorActionDelegate { + + List keyWords=Arrays.
[jbehave-scm] [jbehave] [584] trunk: [CV] Website conversions to textile, fixes
Title: [jbehave] [584] trunk: [CV] Website conversions to textile, fixes Revision 584 Author sirenian Date 2006-11-27 05:06:28 -0600 (Mon, 27 Nov 2006) Log Message [CV] Website conversions to textile, fixes Modified Paths trunk/sitespec.rb trunk/website/content/architecture.textile trunk/website/content/build-website.textile trunk/website/content/development.textile trunk/website/content/index.textile trunk/website/content/mailing-lists.textile trunk/website/content/plugins.textile trunk/website/content/repository.textile trunk/website/content/team.textile trunk/website/templates/jbehave.css Diff Modified: trunk/sitespec.rb (583 => 584) --- trunk/sitespec.rb 2006-11-27 11:01:02 UTC (rev 583) +++ trunk/sitespec.rb 2006-11-27 11:06:28 UTC (rev 584) @@ -1,4 +1,5 @@ -require 'buildmaster' +require 'rubygems' +require_gem 'BuildMaster' class MySiteSpec < BuildMaster::SiteSpec Modified: trunk/website/content/architecture.textile (583 => 584) --- trunk/website/content/architecture.textile 2006-11-27 11:01:02 UTC (rev 583) +++ trunk/website/content/architecture.textile 2006-11-27 11:06:28 UTC (rev 584) @@ -1,6 +1,3 @@ -Architecture h1(FirstChild). Architecture (TODO: Describe JBehave's architecture) Modified: trunk/website/content/build-website.textile (583 => 584) --- trunk/website/content/build-website.textile 2006-11-27 11:01:02 UTC (rev 583) +++ trunk/website/content/build-website.textile 2006-11-27 11:06:28 UTC (rev 584) @@ -1,30 +1,29 @@ --- -Build jBehave Website --- -h1(FirstChild). Ruby and Gems +h1(FirstChild). Building the JBehave website +h2. Ruby and Gems + jBehave uses "BuildMaster":http://buildmaster.rubyforge.org, an open source Ruby project to build its website. This document will show you step by step how you can update and build jBehave website. * Install Ruby and gems * Update Website * Build Website -h1. Install Ruby and Gems +h2. Install Ruby and Gems -h2. Install Ruby +h3. Install Ruby You will need to install Ruby and have RubyGem enabled. If you are on Windows system, the easiest thing to do is to download "Ruby One-Click Installer":http://rubyforge.org/frs/?group_id=167. Make sure that ruby.exe is on your path and verify it by typing command ruby --version -h2. Install BuildMaster +h3. Install BuildMaster "BuildMaster":http://buildmaster.rubyforge.org is used as the template engine to put skin on the content. You can use RubyGem to install it: gem install BuildMaster -h2. Install RedCloth +h3. Install RedCloth "RedCloth":http://whytheluckystiff.net/ruby/redcloth/ is the "Textile":http://hobix.com/textile/ to HTML converter so that we don't need to use verbose HTML. @@ -32,9 +31,9 @@ Now you are set! -h1. Update Site +h2. Update Site -h2. Launch Local Server +h3. Launch Local Server At the root of jBehave project there is a @sitespec.rb@ file. Change to that directory and type "@sitespec.rb server@", it will launch a local HTTP server that serve the documents at port 2000. The output should something like the following: @@ -46,13 +45,13 @@ Now you can point your browser at "@http://localhost:2000/index.html@" and see the website. -h2. Update Content +h3. Update Content The source of the contents are the @.textile@ files under @website/content@ directory. You can use your favorite text editor to open them up and update the content using "Textile":http://hobix.com/textile/ syntax. You can also use the existing document as reference. Save the file, refresh the browser, and you will see the result of the change right away. -h1. Build Site for Deploy +h2. Build Site for Deploy If you invoke the same @sitespec.rb@ without any argument, it will generate the HTML and copy the rest of the files (e.g. image files) into the @website/output@ directory for upload. Modified: trunk/website/content/development.textile (583 => 584) --- trunk/website/content/development.textile 2006-11-27 11:01:02 UTC (rev 583) +++ trunk/website/content/development.textile 2006-11-27 11:06:28 UTC (rev 584) @@ -1,6 +1,3 @@ -Development Resources h1(FirstChild). Golden Rules Here are some rules that we follow when developing JBehave: Modified: trunk/website/content/index.textile (583 => 584) --- trunk/website/content/index.textile 2006-11-27 11:01:02 UTC (rev 583) +++ trunk/website/content/index.textile 2006-11-27 11:06:28 UTC (rev 584) @@ -1,7 +1,4 @@ --- -because TDD is more than testing --- -About JBehave +h1(FirstChild).