- 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/core/src/behaviour/org/jbehave/core/story/SimpleStory.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/behaviour/org/jbehave/core/story/SimpleStory.java 2007-01-02 14:58:48 UTC (rev 642) @@ -34,7 +34,7 @@ } public static class PlainTextRendererWorks extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new EverythingCompiles()); when(new ICrossMyFingers()); then(new PlainTextRendererShouldWork()); @@ -42,7 +42,7 @@ } public static class PlainTextRendererStillWorks extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new PlainTextRendererWorks()); given(new FirstScenarioRanWithoutFallingOver()); when(new IDoNothing());
Modified: trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java (641 => 642)
--- trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/behaviour/org/jbehave/core/story/domain/MultiStepScenarioBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -1,5 +1,6 @@ package org.jbehave.core.story.domain; +import org.jbehave.core.Block; import org.jbehave.core.minimock.UsingMiniMock; import org.jbehave.core.mock.Mock; import org.jbehave.core.story.renderer.Renderer; @@ -10,7 +11,7 @@ // given final Mock given = mock(Given.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given) given); } }; @@ -31,7 +32,7 @@ // given final Mock event = mock(Event.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { when((Event)event); } }; @@ -52,7 +53,7 @@ // given final Mock outcome = mock(Outcome.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { then((Outcome)outcome); } }; @@ -77,7 +78,7 @@ World world = new HashMapWorld(); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -108,7 +109,7 @@ World world = new HashMapWorld(); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -123,6 +124,7 @@ // when scenario.run(world); + scenario.cleanUp(world); // then verifyMocks(); @@ -136,7 +138,7 @@ Mock renderer = mock(Renderer.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -169,7 +171,7 @@ outcome.expects("containsMocks").will(returnValue(true)); // has mocks Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -197,7 +199,7 @@ outcome.expects("containsMocks").never(); // so third step not checked Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -225,7 +227,7 @@ outcome.expects("containsMocks").will(returnValue(false)); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given)given); when((Event)event); then((Outcome)outcome); @@ -250,7 +252,7 @@ World world = (World)stub(World.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { given((Given) given1); given((Given) given2); when((Event) event); @@ -280,7 +282,7 @@ World world = (World)stub(World.class); Scenario scenario = new MultiStepScenario() { - public void specify() { + public void specifySteps() { when((Event) event); then((Outcome) outcome); } @@ -298,4 +300,73 @@ // then verifyMocks(); } + + public void shouldSpecifyScenarioWhenAddingAsAGiven() { + final Mock scenario = mock(Scenario.class); + World world = (World)stub(World.class); + scenario.expects("specify"); + + Scenario parentScenario = new MultiStepScenario() { + public void specifySteps() { + given((Scenario)scenario); + } + }; + parentScenario.specify(); + + verifyMocks(); + } + + public void shouldThrowIllegalStateExceptionIfRunBeforeSpecified() throws Exception { + final Scenario scenario = new MultiStepScenario(){ + public void specifySteps() {}}; + + Exception exception = runAndCatch(IllegalStateException.class, new Block() { + public void run() throws Exception { + scenario.run((World)stub(World.class)); + } + }); + + ensureThat(exception, isNotNull()); + } + + public void shouldThrowIllegalStateExceptionIfNarratedBeforeSpecified() throws Exception { + final Scenario scenario = new MultiStepScenario(){ + public void specifySteps() {}}; + + Exception exception = runAndCatch(IllegalStateException.class, new Block() { + public void run() throws Exception { + scenario.narrateTo((Renderer)stub(Renderer.class)); + } + }); + + ensureThat(exception, isNotNull()); + } + + public void shouldFailIfCleanedUpBeforeRun() throws Exception { + final Scenario scenario = new MultiStepScenario(){ + public void specifySteps() {}}; + + Exception exception = runAndCatch(IllegalStateException.class, new Block() { + public void run() throws Exception { + scenario.specify(); + scenario.cleanUp((World)stub(World.class)); + } + }); + + ensureThat(exception, isNotNull()); + } + + public void shouldFailIfSpecifiedTwice() throws Exception { + final Scenario scenario = new MultiStepScenario(){ + public void specifySteps() {}}; + + Exception exception = runAndCatch(IllegalStateException.class, new Block() { + public void run() throws Exception { + scenario.specify(); + scenario.specify(); + } + }); + + ensureThat(exception, isNotNull()); + } }
Modified: trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java (641 => 642)
--- trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/java/org/jbehave/core/mock/UsingMatchers.java 2007-01-02 14:58:48 UTC (rev 642) @@ -253,30 +253,21 @@ ensureThat(arg, matcher, null); } - public void ensureThrows(Class exceptionType, Block block) throws Exception { - try { - block.run(); - fail("Should have thrown " + exceptionType.getName()); - } - catch (Exception e) { - if (!exceptionType.isAssignableFrom(e.getClass())) { - fail("Got exception of wrong type", exceptionType.getName(), e.getClass().getName()); - } - } - } - /** - * This allows checks for eg: PendingExceptions, or anything else which would ordinarily - * count as a pass. It can also be used for emphasis, or where an exception should - * be interpreted as a misbehaviour rather than an error. + * @return a caught exception assignable from the given type, or null if no such exception was caught */ - public void ensureDoesNotThrowException(Block block) throws Exception { + public Exception runAndCatch(Class exceptionType, Block block) throws Exception { try { block.run(); } catch (Exception e) { - fail("Should not have thrown exception", e); + if (exceptionType.isAssignableFrom(e.getClass())) { + return e; + } else { + throw e; + } } + return null; } /** ensure(...) without matchers */
Modified: trunk/core/src/java/org/jbehave/core/story/StoryBuilder.java (641 => 642)
--- trunk/core/src/java/org/jbehave/core/story/StoryBuilder.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/java/org/jbehave/core/story/StoryBuilder.java 2007-01-02 14:58:48 UTC (rev 642) @@ -53,7 +53,7 @@ private Scenario scenario(final ScenarioDetails details, String storyName) { return new MultiStepScenario() { - public void specify() { + public void specifySteps() { // given for (Iterator i = details.context.givens.iterator(); i.hasNext();) { BasicDetails given = (BasicDetails)i.next();
Modified: trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java (641 => 642)
--- trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java 2007-01-02 14:58:48 UTC (rev 642) @@ -57,23 +57,41 @@ * @author <a href="" PROTECTED]">Elizabeth Keogh</a> */ public abstract class MultiStepScenario implements Scenario { + + private static final String UNSPECIFIED = "Unspecified"; + private static final String SPECIFIED = "Specified"; + private static final String RUN = "Run"; + private List steps = new ArrayList(); - - public abstract void specify(); + private String state; - public void run(World world) { - perform(world); - cleanUp(world); + public MultiStepScenario() { + state = UNSPECIFIED; } - public void perform(World world) { + public final void specify() { + checkState(UNSPECIFIED); + specifySteps(); + state = SPECIFIED; + } + + protected abstract void specifySteps(); + + public void run(World world) { + checkState(SPECIFIED); for (Iterator i = steps.iterator(); i.hasNext();) { Step step = (Step) i.next(); step.perform(world); } + state = RUN; } + private void checkState(String expected) { + if (state != expected) { throw new IllegalStateException("Current state is " + state + ", should be " + expected); } + } + public void cleanUp(World world) { + checkState(RUN); for (ListIterator i = steps.listIterator(steps.size()); i.hasPrevious();) { Object step = i.previous(); if (step instanceof CleansUpWorld) { @@ -83,6 +101,7 @@ } public void narrateTo(Renderer renderer) { + checkState(SPECIFIED); renderer.renderScenario(this); for (Iterator i = steps.iterator(); i.hasNext();) { ((Step)i.next()).narrateTo(renderer); @@ -104,19 +123,21 @@ } protected void given(Given given) { - steps.add(new GivenStep(given)); + AbstractStep step = new GivenStep(given); + addStep(step); } protected void given(Scenario scenario) { - steps.add(new GivenStep(new GivenScenario(scenario))); + scenario.specify(); + addStep(new GivenStep(new GivenScenario(scenario))); } protected void when(Event event) { - steps.add(new EventStep(event)); + addStep(new EventStep(event)); } protected void then(final Outcome outcome) { - steps.add(new OutcomeStep(outcome)); + addStep(new OutcomeStep(outcome)); if (outcome instanceof OutcomeWithExpectations) { injectAfterGivens(new AbstractStep(outcome) { public void perform(World world) { @@ -139,4 +160,9 @@ // if we get here, there weren't any givens steps.add(0, step); } + + + private void addStep(AbstractStep step) { + steps.add(step); + } }
Modified: trunk/core/src/java/org/jbehave/core/story/domain/Scenario.java (641 => 642)
--- trunk/core/src/java/org/jbehave/core/story/domain/Scenario.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/core/src/java/org/jbehave/core/story/domain/Scenario.java 2007-01-02 14:58:48 UTC (rev 642) @@ -30,7 +30,21 @@ * @see MultiStepScenario */ public interface Scenario extends Renderable, CleansUpWorld { - void specify(); - void run(World world); - boolean containsMocks(); + + /** + * @throws IllegalStateException if the scenario is already specified. + */ + void specify() throws IllegalStateException; + + /** + * @throws IllegalStateException if the scenario has not been specified. + */ + void run(World world) throws IllegalStateException; + + /** + * @throws IllegalStateException if the scenario has not been run. + */ + void cleanUp(World world) throws IllegalStateException; + + boolean containsMocks() throws IllegalStateException; } \ No newline at end of file
Modified: trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenario.java (641 => 642)
--- trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenario.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenario.java 2007-01-02 14:58:48 UTC (rev 642) @@ -10,7 +10,7 @@ public class HappyScenario extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new AccountIsInCredit()); when(new UserRequestsCash()); then(new ATMShouldDispenseCash());
Modified: trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenarioWithOverdraft.java (641 => 642)
--- trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenarioWithOverdraft.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/atm/src/stories/example/atm/scenarios/HappyScenarioWithOverdraft.java 2007-01-02 14:58:48 UTC (rev 642) @@ -10,7 +10,7 @@ public class HappyScenarioWithOverdraft extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new AccountHasOverdraftPermission()); when(new UserRequestsCash()); then(new ATMShouldDispenseCash());
Modified: trunk/examples/atm/src/stories/example/atm/scenarios/InLotsOfTrouble.java (641 => 642)
--- trunk/examples/atm/src/stories/example/atm/scenarios/InLotsOfTrouble.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/atm/src/stories/example/atm/scenarios/InLotsOfTrouble.java 2007-01-02 14:58:48 UTC (rev 642) @@ -9,7 +9,7 @@ public class InLotsOfTrouble extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new AccountIsOverOverdraftLimit()); when(new UserRequestsCash()); then(new ATMShouldRefuseCash());
Modified: trunk/examples/atm/src/stories/example/atm/scenarios/OverdrawnWithoutPermission.java (641 => 642)
--- trunk/examples/atm/src/stories/example/atm/scenarios/OverdrawnWithoutPermission.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/atm/src/stories/example/atm/scenarios/OverdrawnWithoutPermission.java 2007-01-02 14:58:48 UTC (rev 642) @@ -9,7 +9,7 @@ public class OverdrawnWithoutPermission extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new HappyScenarioWithOverdraft()); given(new AccountHasNegativeBalanceWithoutPermission()); when(new UserRequestsCash());
Modified: trunk/examples/currency/src/behaviour/example/currency/SterlingCurrencyConverterBehaviour.java (641 => 642)
--- trunk/examples/currency/src/behaviour/example/currency/SterlingCurrencyConverterBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/currency/src/behaviour/example/currency/SterlingCurrencyConverterBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -53,11 +53,12 @@ public void shouldNotConvertFromNegativeSterlingAmounts() throws Exception { // expects exchangeRateServiceMock.stubs("retrieveRate").will(returnValue(new ExchangeRate(1.85, 0.54))); - ensureThrows(InvalidAmountException.class, new Block() { + Exception exception = runAndCatch(InvalidAmountException.class, new Block() { public void run() throws Exception { sterlingConverter.convertFromSterling(-1, Currency.USD); } }); + ensureThat(exception, isNotNull()); } public void shouldConvertFromEUR() throws Exception { @@ -75,7 +76,7 @@ public void shouldNotConvertFromNegativeAmounts() throws Exception { //expects exchangeRateServiceMock.stubs("retrieveRate").will(returnValue(new ExchangeRate(1.85, 0.54))); - ensureThrows(InvalidAmountException.class, new Block() { + Exception exception = runAndCatch(InvalidAmountException.class, new Block() { public void run() throws Exception { sterlingConverter.convertToSterling(-3, Currency.EUR); }
Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java (641 => 642)
--- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/util/ThreadedQueueBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -20,10 +20,12 @@ } }; - ensureThrows(Throwable.class, new Block() { + Exception exception = runAndCatch(Throwable.class, new Block() { public void run() throws Exception { queue.queue(new Runnable(){ public void run() {}}); } }); + + ensureThat(exception, isNotNull()); } }
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheFirstGlyphIsDisplayedOnTheBoard.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheFirstGlyphIsDisplayedOnTheBoard.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/TheFirstGlyphIsDisplayedOnTheBoard.java 2007-01-02 14:58:48 UTC (rev 642) @@ -8,7 +8,7 @@ public class TheFirstGlyphIsDisplayedOnTheBoard extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new HellboundIsRunning()); when(new ThePlayerStartsTheGame()); then(new TheGlyphShouldBeCentredAtTheTopOfThePit());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java 2007-01-02 14:58:48 UTC (rev 642) @@ -10,7 +10,7 @@ public class ThePlayerDropsTheGlyphIntoAnEmptyPit extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new ThePlayerPressesTheDropKey()); then(new TheGlyphShouldFallToTheBottom());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java 2007-01-02 14:58:48 UTC (rev 642) @@ -8,7 +8,7 @@ public class ThePlayerDropsTheGlyphOntoJunk extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new ThePlayerDropsTheGlyphIntoAnEmptyPit()); when(new ThePlayerPressesTheDropKey()); then(new TheGlyphShouldFallOntoTheJunk());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerMovesTheGlyph.java 2007-01-02 14:58:48 UTC (rev 642) @@ -12,7 +12,7 @@ public class ThePlayerMovesTheGlyph extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new ThePlayerPressesTheRightKey()); then(new TheGlyphShouldMoveRight());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphLeft.java 2007-01-02 14:58:48 UTC (rev 642) @@ -10,7 +10,7 @@ public class ThePlayerRotatesTheGlyphLeft extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new ThePlayerPressesLeftRotate());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphRight.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphRight.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerRotatesTheGlyphRight.java 2007-01-02 14:58:48 UTC (rev 642) @@ -10,7 +10,7 @@ public class ThePlayerRotatesTheGlyphRight extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new ThePlayerPressesRightRotate()); then(new TheGlyphTurnsToThreeQuarters());
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerSeesTheFirstGlyphMove.java (641 => 642)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerSeesTheFirstGlyphMove.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerSeesTheFirstGlyphMove.java 2007-01-02 14:58:48 UTC (rev 642) @@ -7,7 +7,7 @@ public class ThePlayerSeesTheFirstGlyphMove extends MultiStepScenario { - public void specify() { + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new TimePasses()); then(new TheGlyphShouldMoveDownwards());
Modified: trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java (641 => 642)
--- trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/extensions/ant/src/behaviour/org/jbehave/ant/JBehaveTaskBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -110,11 +110,12 @@ task.createVerify().setName(behaviourClassName); runner.valueToReturn = 1; - ensureThrows(BuildException.class, new Block() { + Exception exception = runAndCatch(BuildException.class, new Block() { public void run() throws Exception { task.execute(); } }); + ensureThat(exception, isNotNull()); }
Modified: trunk/extensions/jmock/src/behaviour/org/jbehave/jmock/UsingJMockBehaviour.java (641 => 642)
--- trunk/extensions/jmock/src/behaviour/org/jbehave/jmock/UsingJMockBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/extensions/jmock/src/behaviour/org/jbehave/jmock/UsingJMockBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -105,11 +105,13 @@ final UsingJMock instance = new HasMockThatFailsVerify(); // when... - ensureThrows(VerificationException.class, new Block() { + Exception exception = runAndCatch(VerificationException.class, new Block() { public void run() throws Exception { instance.verifyMocks(); } }); + + ensureThat(exception, isNotNull()); } public static interface AnInterface {}
Modified: trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/HeadlessCheckerBehaviour.java (641 => 642)
--- trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/HeadlessCheckerBehaviour.java 2007-01-02 11:50:17 UTC (rev 641) +++ trunk/extensions/swing/src/behaviour/org/jbehave/threaded/swing/HeadlessCheckerBehaviour.java 2007-01-02 14:58:48 UTC (rev 642) @@ -19,7 +19,7 @@ final HeadlessChecker headlessChecker = new HeadlessChecker(); - ensureThrowsExceptionOnHeadless(headlessChecker); + ensureThrowsPendingExceptionOnHeadless(headlessChecker); ensureDoesNotThrowExceptionWhenNotHeadless(headlessChecker); resetOriginalHeadlessMode(); @@ -27,20 +27,22 @@ private void ensureDoesNotThrowExceptionWhenNotHeadless(final HeadlessChecker headlessChecker) throws Exception { System.getProperties().remove("java.awt.headless"); - ensureDoesNotThrowException(new Block() { + Exception exception = runAndCatch(Exception.class, new Block() { public void run() throws Exception { headlessChecker.check(); } }); + ensureThat(exception, isNull()); } - private void ensureThrowsExceptionOnHeadless(final HeadlessChecker headlessChecker) throws Exception { - System.setProperty("java.awt.headless", "true"); - ensureThrows(PendingException.class, new Block() { + private void ensureThrowsPendingExceptionOnHeadless(final HeadlessChecker headlessChecker) throws Exception { + System.getProperties().put("java.awt.headless", "true"); + Exception exception = runAndCatch(PendingException.class, new Block() { public void run() throws Exception { headlessChecker.check(); } }); + ensureThat(exception, isNotNull()); } private void resetOriginalHeadlessMode() {
To unsubscribe from this list please visit:
