- 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 @@ <delete dir="${working_dir}" /> </target> - <target name="build" depends="verify-behaviour, run-example-behaviours, run-example-stories, build-source-zip" + <target name="build" depends="verify-behaviour, run-example-behaviours, run-example-stories, print-example-stories, build-source-zip" description="build the jbehave binary and zip up the project" /> <target name="dist" depends="clean, build, javadoc" description="create distribution" /> @@ -242,7 +242,7 @@ <target name="print-example-stories" depends="compile-example-behaviours, compile-example-stories" description="Prints stories for examples"> <taskdef name="printstories" classname="${story.printer.task}" classpath="${jbehave_jar}" /> - <printstories destdir="${dist_dir}"> + <printstories destdir="${examples_dir}/${example}/src/stories"> <classpath> <path refid="libs" /> <pathelement path="${example_classes_dir}" />
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("\\."); String simpleStoryName = storyNameParts[storyNameParts.length - 1]; @@ -43,12 +43,13 @@ outputStream.close(); } - public static void main(String[] args) { - File directory = new File(args[0]); + public static void main(String[] args) throws ClassNotFoundException { + File directory = new File(args[0]); + Thread.currentThread().getContextClassLoader().loadClass("com.sirenian.hellbound.stories.TheGlyphIsConstrainedByThePit"); try { StoryToDirectoryPrinter printer = new StoryToDirectoryPrinter( - new StoryLoader(new TextStoryParser(), StoryPrinter.class.getClassLoader()), + new StoryLoader(new TextStoryParser(), Thread.currentThread().getContextClassLoader()), directory); for (int i = 1; i < args.length; i++) {
Modified: trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java (783 => 784)
--- trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/core/src/java/org/jbehave/core/story/domain/MultiStepScenario.java 2007-08-15 17:07:05 UTC (rev 784) @@ -66,8 +66,14 @@ private List steps = new ArrayList(); private String state; + private final String name; public MultiStepScenario() { + this(null); + } + + public MultiStepScenario(String name) { + this.name = name; state = UNSPECIFIED; } @@ -78,7 +84,7 @@ } public String getName() { - return this.getClass().getName(); + return name == null ? this.getClass().getName() : name; } protected abstract void specifySteps();
Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java (783 => 784)
--- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/FrontPanelBehaviour.java 2007-08-15 17:07:05 UTC (rev 784) @@ -7,7 +7,6 @@ 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;
Modified: trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story (783 => 784)
--- trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story 2007-08-15 12:16:28 UTC (rev 783) +++ trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story 2007-08-15 17:07:05 UTC (rev 784) @@ -6,10 +6,21 @@ Scenario: the player drops the glyph to make a line -Given that the junk has a hole -and a glyph of the right shape is above the hole -When the player presses the drop button +Given the junk has a hole and a glyph of the right shape is above it +When the player presses the drop key and time passes -Then the glyph becomes junk -and the line disappears -and the next glyph appears \ No newline at end of file +Then the line should disappear and the next glyph should appear +..ZZ... +...ZZ.. +....... +....... +....... +....... +....... +....... +....... +....... +...X... +...XX.X +.XXXX.X +
To unsubscribe from this list please visit:
