- Revision
- 605
- Author
- tastapod
- Date
- 2006-12-01 14:03:40 -0600 (Fri, 01 Dec 2006)
Log Message
[dn] tidying up AllBehaviours classes
Modified Paths
- trunk/core/src/behaviour/jbehave/core/AllBehaviours.java
- trunk/core/src/behaviour/jbehave/core/listener/PlainTextListenerBehaviourSupport.java
- trunk/core/src/behaviour/jbehave/core/listener/PlainTextMethodListenerBehaviour.java
- trunk/core/src/behaviour/jbehave/core/story/AllBehaviours.java
- trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextScenarioListenerBehaviour.java
- trunk/core/src/behaviour/jbehave/core/util/BehavioursLoaderBehaviour.java
- trunk/core/src/java/jbehave/core/mock/UsingConstraints.java
Added Paths
Removed Paths
Diff
Modified: trunk/core/src/behaviour/jbehave/core/AllBehaviours.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/AllBehaviours.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/AllBehaviours.java 2006-12-01 20:03:40 UTC (rev 605) @@ -16,7 +16,6 @@ import jbehave.core.minimock.UsingMiniMockBehaviour; import jbehave.core.mock.ExpectationBehaviour; import jbehave.core.result.ResultBehaviour; -import jbehave.core.story.listener.PlainTextListenerBehaviour; public class AllBehaviours implements Behaviours { @@ -30,9 +29,7 @@ MiniMockObjectBehaviour.class, UsingMiniMockBehaviour.class, ExpectationBehaviour.class, - ExpectationBehaviour.class, ResultBehaviour.class, - ResultBehaviour.class, jbehave.core.story.AllBehaviours.class }; }
Added: trunk/core/src/behaviour/jbehave/core/listener/PendingResult.java (0 => 605)
--- trunk/core/src/behaviour/jbehave/core/listener/PendingResult.java (rev 0) +++ trunk/core/src/behaviour/jbehave/core/listener/PendingResult.java 2006-12-01 20:03:40 UTC (rev 605) @@ -0,0 +1,11 @@ +package jbehave.core.listener; + +import jbehave.core.behaviour.BehaviourMethod; +import jbehave.core.exception.PendingException; +import jbehave.core.result.BehaviourMethodResult; + +class PendingResult extends BehaviourMethodResult { + public PendingResult(BehaviourMethod behaviourMethod) { + super(behaviourMethod, new PendingException()); + } +}
Modified: trunk/core/src/behaviour/jbehave/core/listener/PlainTextListenerBehaviourSupport.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/listener/PlainTextListenerBehaviourSupport.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/listener/PlainTextListenerBehaviourSupport.java 2006-12-01 20:03:40 UTC (rev 605) @@ -73,11 +73,6 @@ ensureThat(writer, contains(Result.PENDING)); } - protected void verifyOutputContains(String expected) { - String output = writer.toString(); - Ensure.that("Output should contain: [" + expected + "] but was:\n>>>\n" + output + "\n<<<", output.indexOf(expected) != -1); - } - public void shouldSummarizeSingleSuccessfulResult() throws Exception { // given... Result succeeded = newSuccessResult(); @@ -87,7 +82,7 @@ listener.printReport(); // then... - verifyOutputContains("\nTotal: 1"); + ensureThat(writer, contains("\nTotal: 1")); } public void shouldSummarizeTwoSuccessfulResults() throws Exception { @@ -100,7 +95,7 @@ listener.printReport(); // then... - verifyOutputContains("\nTotal: 2"); + ensureThat(writer, contains("\nTotal: 2")); } public void shouldPrintSummaryForFailure() throws Exception { @@ -112,7 +107,7 @@ listener.printReport(); // then... - verifyOutputContains("\nTotal: 1. Failures: 1"); + ensureThat(writer, contains("\nTotal: 1. Failures: 1")); } public void shouldSummarizePendingResult() throws Exception { @@ -124,7 +119,7 @@ listener.printReport(); // then... - verifyOutputContains("\nPending: 1"); + ensureThat(writer, contains("\nPending: 1")); } public void shouldStartTimerWhenConstructed() throws Exception {
Modified: trunk/core/src/behaviour/jbehave/core/listener/PlainTextMethodListenerBehaviour.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/listener/PlainTextMethodListenerBehaviour.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/listener/PlainTextMethodListenerBehaviour.java 2006-12-01 20:03:40 UTC (rev 605) @@ -12,7 +12,6 @@ import jbehave.core.exception.VerificationException; import jbehave.core.result.BehaviourMethodResult; import jbehave.core.result.Result; -import mock.jbehave.core.listener.PendingResultInNonJBehavePackage; /** @@ -55,15 +54,15 @@ listener.printReport(); // then... - verifyOutputContains("Failures:"); - verifyOutputContains(expectedShortName); - verifyOutputContains(expectedFullName); - verifyOutputContains("VerificationException"); + ensureThat(writer, contains("Failures:")); + ensureThat(writer, contains(expectedShortName)); + ensureThat(writer, contains(expectedFullName)); + ensureThat(writer, contains("VerificationException")); } - public void shouldPrintStackElementForPending() throws Exception { + public void shouldPrintBehaviourClassNameForPending() throws Exception { // given... - Result pending = newPendingResultFromNonJBehavePackage(); + Result pending = new PendingResult(behaviourMethod); // expect String expectedShortName = "Foo"; @@ -74,11 +73,7 @@ listener.printReport(); // then... - verifyOutputContains("Pending:"); - verifyOutputContains("at mock.jbehave.core.listener.PendingResultInNonJBehavePackage.<init>("); + ensureThat(writer, contains("Pending:")); + ensureThat(writer, contains(FooBehaviour.class.getName())); } - - private Result newPendingResultFromNonJBehavePackage() { - return new PendingResultInNonJBehavePackage(behaviourMethod); - } }
Modified: trunk/core/src/behaviour/jbehave/core/story/AllBehaviours.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/story/AllBehaviours.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/story/AllBehaviours.java 2006-12-01 20:03:40 UTC (rev 605) @@ -15,6 +15,7 @@ import jbehave.core.story.domain.GivensBehaviour; import jbehave.core.story.domain.NarrativeBehaviour; import jbehave.core.story.domain.OutcomesBehaviour; +import jbehave.core.story.domain.ScenarioComponentsBehaviour; import jbehave.core.story.domain.ScenarioDrivenStoryBehaviour; import jbehave.core.story.domain.ScenarioUsingMiniMockBehaviour; import jbehave.core.story.domain.ScenariosBehaviour; @@ -34,13 +35,13 @@ TextStoryParserBehaviour.class, EventOutcomeStepBehaviour.class, EventsBehaviour.class, + GivensBehaviour.class, GivenScenarioBehaviour.class, - GivensBehaviour.class, NarrativeBehaviour.class, OutcomesBehaviour.class, ScenarioDrivenStoryBehaviour.class, + ScenariosBehaviour.class, ScenarioUsingMiniMockBehaviour.class, - ScenariosBehaviour.class, StepsBehaviour.class, PlainTextScenarioListenerBehaviour.class, PlainTextRendererBehaviour.class,
Deleted: trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextListenerBehaviour.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextListenerBehaviour.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextListenerBehaviour.java 2006-12-01 20:03:40 UTC (rev 605) @@ -1,129 +0,0 @@ -/* - * Created on 29-Dec-2003 - * - * (c) 2003-2004 ThoughtWorks - * - * See license.txt for licence details - */ -package jbehave.core.story.listener; - -import java.io.StringWriter; - -import jbehave.core.Ensure; -import jbehave.core.exception.PendingException; -import jbehave.core.listener.PlainTextListener; -import jbehave.core.minimock.UsingMiniMock; -import jbehave.core.result.Result; -import jbehave.core.util.Timer; - - -/** - * @author <a href="" PROTECTED]">Dan North</a> - * - * copied from core behaviours - should clean this up! - */ -public abstract class PlainTextListenerBehaviour extends UsingMiniMock { - private static class StatefulTimer extends Timer { - public boolean isRunning = false; - public void start() { - isRunning = true; - } - public void stop() { - isRunning = false; - } - } - - protected StringWriter writer; - protected PlainTextListener listener; - protected StatefulTimer timer; - - protected abstract PlainTextListener newPlainTextListener(); - protected abstract Result newSuccessResult(); - protected abstract Result newFailureResult(); - protected abstract Result newExceptionResult(); - protected abstract Result newPendingResult(); - - public static class FooBehaviour { - public void shouldDoSomething() {} - } - - public void setUp() throws Exception { - writer = new StringWriter(); - timer = new StatefulTimer(); - listener = newPlainTextListener(); - } - - public void shouldRenderSuccessSymbolForSuccess() throws Exception { - listener.gotResult(new Result("shouldSucceed", "Container", Result.SUCCEEDED)); - ensureThat(writer.toString(), eq(Result.SUCCEEDED.symbol())); - } - - public void shouldRenderFailureSymbolForFailure() throws Exception { - listener.gotResult(new Result("shouldFail", "Container", Result.FAILED)); - ensureThat(writer.toString(), eq(Result.FAILED.symbol())); - } - - public void shouldRenderPendingSymbolForPending() throws Exception { - listener.gotResult(new Result("shouldBePending", "Container", new PendingException())); - ensureThat(writer.toString(), eq(Result.PENDING.symbol())); - } - - protected void verifyOutputContains(String expected) { - String output = writer.toString(); - Ensure.that("Output should contain: [" + expected + "] but was:\n>>>\n" + output + "\n<<<", output.indexOf(expected) != -1); - } - - public void shouldSummarizeSingleSuccessfulResult() throws Exception { - // given... - Result succeeded = newSuccessResult(); - - // when... - listener.gotResult(succeeded); - listener.printReport(); - - // then... - verifyOutputContains("\nTotal: 1"); - } - - public void shouldSummarizeTwoSuccessfulResults() throws Exception { - // given... - Result succeeded = newSuccessResult(); - - // when... - listener.gotResult(succeeded); - listener.gotResult(succeeded); - listener.printReport(); - - // then... - verifyOutputContains("\nTotal: 2"); - } - - public void shouldPrintSummaryForFailure() throws Exception { - // given... - Result failed = newFailureResult(); - - // when... - listener.gotResult(failed); - listener.printReport(); - - // then... - verifyOutputContains("\nTotal: 1. Failures: 1"); - } - - public void shouldSummarizePendingResult() throws Exception { - // given... - Result pending = newPendingResult(); - - // when... - listener.gotResult(pending); - listener.printReport(); - - // then... - verifyOutputContains("\nPending: 1"); - } - - public void shouldStartTimerWhenConstructed() throws Exception { - // verify... - Ensure.that(timer.isRunning); - } -}
Modified: trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextScenarioListenerBehaviour.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextScenarioListenerBehaviour.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/story/listener/PlainTextScenarioListenerBehaviour.java 2006-12-01 20:03:40 UTC (rev 605) @@ -10,15 +10,15 @@ import jbehave.core.exception.PendingException; import jbehave.core.exception.VerificationException; import jbehave.core.listener.PlainTextListener; +import jbehave.core.listener.PlainTextListenerBehaviourSupport; import jbehave.core.result.Result; -import jbehave.core.story.listener.PlainTextScenarioListener; import jbehave.core.story.result.ScenarioResult; /** * @author <a href="" PROTECTED]">Dan North</a> */ -public class PlainTextScenarioListenerBehaviour extends PlainTextListenerBehaviour { +public class PlainTextScenarioListenerBehaviour extends PlainTextListenerBehaviourSupport { public void setUp() throws Exception { super.setUp(); @@ -63,6 +63,6 @@ listener.printReport(); // then... - verifyOutputContains("\nUsed mocks: 1"); + ensureThat(writer, contains("\nUsed mocks: 1")); } }
Modified: trunk/core/src/behaviour/jbehave/core/util/BehavioursLoaderBehaviour.java (604 => 605)
--- trunk/core/src/behaviour/jbehave/core/util/BehavioursLoaderBehaviour.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/jbehave/core/util/BehavioursLoaderBehaviour.java 2006-12-01 20:03:40 UTC (rev 605) @@ -5,10 +5,10 @@ import java.util.HashSet; import java.util.Set; +import jbehave.core.listener.PlainTextListenerBehaviourSupport; import jbehave.core.minimock.MiniMockObjectBehaviour; import jbehave.core.mock.Constraint; import jbehave.core.mock.UsingConstraints; -import jbehave.core.story.listener.PlainTextListenerBehaviour; public class BehavioursLoaderBehaviour extends UsingConstraints { @@ -37,8 +37,8 @@ private void ensureThatBehavioursAreLoaded(Set loadedFromBehaviourLoader) { ensureThat(loadedFromBehaviourLoader, setContains(MiniMockObjectBehaviour.class)); - ensureThat(Modifier.isAbstract(PlainTextListenerBehaviour.class.getModifiers()), eq(true)); - ensureThat(loadedFromBehaviourLoader, not(setContains(PlainTextListenerBehaviour.class))); + ensureThat(Modifier.isAbstract(PlainTextListenerBehaviourSupport.class.getModifiers()), eq(true)); + ensureThat(loadedFromBehaviourLoader, not(setContains(PlainTextListenerBehaviourSupport.class))); } private Constraint setContains(final Object item) {
Deleted: trunk/core/src/behaviour/mock/jbehave/core/listener/PendingResultInNonJBehavePackage.java (604 => 605)
--- trunk/core/src/behaviour/mock/jbehave/core/listener/PendingResultInNonJBehavePackage.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/behaviour/mock/jbehave/core/listener/PendingResultInNonJBehavePackage.java 2006-12-01 20:03:40 UTC (rev 605) @@ -1,11 +0,0 @@ -package mock.jbehave.core.listener; - -import jbehave.core.behaviour.BehaviourMethod; -import jbehave.core.exception.PendingException; -import jbehave.core.result.BehaviourMethodResult; - -public class PendingResultInNonJBehavePackage extends BehaviourMethodResult { - public PendingResultInNonJBehavePackage(BehaviourMethod behaviourMethod) { - super(behaviourMethod, new PendingException()); - } -}
Modified: trunk/core/src/java/jbehave/core/mock/UsingConstraints.java (604 => 605)
--- trunk/core/src/java/jbehave/core/mock/UsingConstraints.java 2006-12-01 18:26:15 UTC (rev 604) +++ trunk/core/src/java/jbehave/core/mock/UsingConstraints.java 2006-12-01 20:03:40 UTC (rev 605) @@ -165,9 +165,9 @@ } public CustomConstraint contains(final String fragment) { - return new CustomConstraint("string ending with <" + fragment + ">") { + return new CustomConstraint("string containing <" + fragment + ">") { public boolean matches(Object arg) { - return ((String)arg).indexOf(fragment) != -1; + return arg.toString().indexOf(fragment) != -1; } }; }
To unsubscribe from this list please visit:
