- Revision
- 787
- Author
- mauro
- Date
- 2007-09-05 05:10:39 -0500 (Wed, 05 Sep 2007)
Log Message
Refactored StoryLoader#loadStoryClass() to throw a runtime InvalidStoryClassException.
Modified Paths
- trunk/core/src/java/org/jbehave/core/story/StoryLoader.java
- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java
- 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
Diff
Modified: trunk/core/src/java/org/jbehave/core/story/StoryLoader.java (786 => 787)
--- trunk/core/src/java/org/jbehave/core/story/StoryLoader.java 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/core/src/java/org/jbehave/core/story/StoryLoader.java 2007-09-05 10:10:39 UTC (rev 787) @@ -3,7 +3,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.net.MalformedURLException; import java.util.NoSuchElementException; import org.jbehave.core.story.codegen.domain.StoryDetails; @@ -26,21 +25,25 @@ this.storyParser = storyParser; } - public StoryDetails loadStoryDetails(String storyPath) throws MalformedURLException { + public StoryDetails loadStoryDetails(String storyPath) { return storyParser.parseStory(getReader(storyPath, classLoader)); } - public Story loadStory(String storyPath) throws MalformedURLException { + public Story loadStory(String storyPath) { StoryDetails storyDetails = loadStoryDetails(storyPath); return new StoryBuilder(storyDetails, classLoader).story(); } - public Story loadStory(Class storyClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException { + public Story loadStory(Class storyClass) { return loadStoryClass(storyClass.getName()); } - public Story loadStoryClass(String storyClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return (Story) classLoader.loadClass(storyClassName).newInstance(); + public Story loadStoryClass(String storyClassName) { + try { + return (Story) classLoader.loadClass(storyClassName).newInstance(); + } catch ( Exception e) { + throw new InvalidStoryClassException("Failed to load story for class "+storyClassName, e); + } } protected Reader getReader(String resource, ClassLoader classLoader) { @@ -50,4 +53,10 @@ } return new InputStreamReader(is); } + + static class InvalidStoryClassException extends RuntimeException { + public InvalidStoryClassException(String message, Exception cause) { + super(message, cause); + } + } }
Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (786 => 787)
--- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-09-05 10:10:39 UTC (rev 787) @@ -6,8 +6,6 @@ * See license.txt for license details */ package org.jbehave.core.story; -import java.net.MalformedURLException; - import org.jbehave.core.story.codegen.parser.TextStoryParser; import org.jbehave.core.story.domain.Story; import org.jbehave.core.story.renderer.PlainTextRenderer; @@ -29,19 +27,19 @@ this.renderer = renderer; } - public void print(String storyPath) throws MalformedURLException, InstantiationException, IllegalAccessException, ClassNotFoundException { + public void print(String storyPath) { Story story = storyLoader.loadStoryClass(storyPath); story.specify(); story.narrateTo(renderer); } - public void print(Class storyClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException{ + public void print(Class storyClass) { Story story = storyLoader.loadStory(storyClass); story.specify(); story.narrateTo(renderer); } - public static void main(String[] args) throws MalformedURLException, InstantiationException, IllegalAccessException, ClassNotFoundException { + public static void main(String[] args) { StoryPrinter printer = new StoryPrinter( new StoryLoader(new TextStoryParser(), StoryPrinter.class.getClassLoader()), new PlainTextRenderer(System.out));
Modified: trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story (786 => 787)
--- trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/TheGlyphIsConstrainedByThePit.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,66 +1,66 @@ -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 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 should be against the left wall -TTT.... -.T..... -....... -....... -....... -....... -....... -....... -....... -....... -....... -....... -....... - - -Scenario: the glyph will not move down - -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... - +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 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 should be against the left wall +TTT.... +.T..... +....... +....... +....... +....... +....... +....... +....... +....... +....... +....... +....... + + +Scenario: the glyph will not move down + +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/TheGlyphMovesAsTimePasses.story (786 => 787)
--- trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/TheGlyphMovesAsTimePasses.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,11 +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 +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
Modified: trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story (786 => 787)
--- trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/ThePlayerDropsTheGlyph.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,63 +1,63 @@ -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 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 -....... -....... -....... -....... -....... -....... -....... -....... -....... -..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... - +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 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 +....... +....... +....... +....... +....... +....... +....... +....... +....... +..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 (786 => 787)
--- trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/ThePlayerInteractsWithTheGlyph.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,40 +1,40 @@ -Story: the player interacts with the glyph - -As a game player -I want to move the shape -So that I can make space for the next glyph - -Scenario: the player moves the glyph - -Given the first glyph is displayed on the board -When the player presses the right key -Then the glyph should move right -When the player presses the left key -Then the glyph should be centred at the top of the pit -When the player presses the down key -Then the glyph should move downwards -and the heartbeat should be skipped - -Scenario: the player rotates the glyph left - -Given the first glyph is displayed on the board -When the player presses left rotate -Then the glyph should turn to one quarter -When the player presses left rotate -Then the glyph turns to two quarters -When the player presses left rotate -Then the glyph turns to three quarters -When the player presses left rotate -Then the glyph should be centred at the top of the pit - -Scenario: the player rotates the glyph right - -Given the first glyph is displayed on the board -When the player presses right rotate -Then the glyph turns to three quarters -When the player presses right rotate -Then the glyph turns to two quarters -When the player presses right rotate -Then the glyph should turn to one quarter -When the player presses right rotate -Then the glyph should be centred at the top of the pit +Story: the player interacts with the glyph + +As a game player +I want to move the shape +So that I can make space for the next glyph + +Scenario: the player moves the glyph + +Given the first glyph is displayed on the board +When the player presses the right key +Then the glyph should move right +When the player presses the left key +Then the glyph should be centred at the top of the pit +When the player presses the down key +Then the glyph should move downwards +and the heartbeat should be skipped + +Scenario: the player rotates the glyph left + +Given the first glyph is displayed on the board +When the player presses left rotate +Then the glyph should turn to one quarter +When the player presses left rotate +Then the glyph turns to two quarters +When the player presses left rotate +Then the glyph turns to three quarters +When the player presses left rotate +Then the glyph should be centred at the top of the pit + +Scenario: the player rotates the glyph right + +Given the first glyph is displayed on the board +When the player presses right rotate +Then the glyph turns to three quarters +When the player presses right rotate +Then the glyph turns to two quarters +When the player presses right rotate +Then the glyph should turn to one quarter +When the player presses right rotate +Then the glyph should be centred at the top of the pit
Modified: trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame.story (786 => 787)
--- trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/ThePlayerLosesTheGame.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,27 +1,27 @@ -Story: the player loses the game - -As a game player -I want to lose the game -So that the game is a challenge - -Scenario: there is no space for the next glyph - -Given the junk is almost to the top -When the player presses the drop key -and time passes -Then the glyph should become junk and the next glyph should appear overlapping it -..L.... -..L.... -..LL... -...XX.. -...X... -...X... -..XX... -...XX.. -..XX... -..XX... -...XX.. -..XXX.. -...X... - -and the game should be over +Story: the player loses the game + +As a game player +I want to lose the game +So that the game is a challenge + +Scenario: there is no space for the next glyph + +Given the junk is almost to the top +When the player presses the drop key +and time passes +Then the glyph should become junk and the next glyph should appear overlapping it +..L.... +..L.... +..LL... +...XX.. +...X... +...X... +..XX... +...XX.. +..XX... +..XX... +...XX.. +..XXX.. +...X... + +and the game should be over
Modified: trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story (786 => 787)
--- trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story 2007-08-16 12:53:33 UTC (rev 786) +++ trunk/examples/hellbound/src/stories/ThePlayerMakesALine.story 2007-09-05 10:10:39 UTC (rev 787) @@ -1,26 +1,26 @@ -Story: the player makes a line - -As a game player -I want lines to disappear when I complete them -So that I can progress the game - -Scenario: the player drops the glyph to make a line - -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 line should disappear and the next glyph should appear -..ZZ... -...ZZ.. -....... -....... -....... -....... -....... -....... -....... -....... -...X... -...XX.X -.XXXX.X - +Story: the player makes a line + +As a game player +I want lines to disappear when I complete them +So that I can progress the game + +Scenario: the player drops the glyph to make a line + +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 line should disappear and the next glyph should appear +..ZZ... +...ZZ.. +....... +....... +....... +....... +....... +....... +....... +....... +...X... +...XX.X +.XXXX.X +
To unsubscribe from this list please visit:
