- Revision
- 1544
- Author
- mauro
- Date
- 2010-02-06 02:11:15 -0600 (Sat, 06 Feb 2010)
Log Message
JBEHAVE-163: Renamed ignorable step type for consistency.
Modified Paths
- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepType.java
- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsConfiguration.java
Diff
Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java (1543 => 1544)
--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java 2010-02-06 07:31:20 UTC (rev 1543) +++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java 2010-02-06 08:11:15 UTC (rev 1544) @@ -1,6 +1,19 @@ package org.jbehave.scenario.i18n; + import static org.hamcrest.CoreMatchers.equalTo; import static org.jbehave.Ensure.ensureThat; +import static org.jbehave.scenario.definition.KeyWords.AND; +import static org.jbehave.scenario.definition.KeyWords.EXAMPLES_TABLE; +import static org.jbehave.scenario.definition.KeyWords.EXAMPLES_TABLE_ROW; +import static org.jbehave.scenario.definition.KeyWords.FAILED; +import static org.jbehave.scenario.definition.KeyWords.GIVEN; +import static org.jbehave.scenario.definition.KeyWords.GIVEN_SCENARIOS; +import static org.jbehave.scenario.definition.KeyWords.IGNORABLE; +import static org.jbehave.scenario.definition.KeyWords.NOT_PERFORMED; +import static org.jbehave.scenario.definition.KeyWords.PENDING; +import static org.jbehave.scenario.definition.KeyWords.SCENARIO; +import static org.jbehave.scenario.definition.KeyWords.THEN; +import static org.jbehave.scenario.definition.KeyWords.WHEN; import static org.junit.Assert.assertEquals; import java.io.IOException; @@ -18,29 +31,29 @@ public class I18nKeywordsBehaviour { - private StringEncoder encoder = new StringEncoder("UTF-8", "UTF-8"); + private StringEncoder encoder = new StringEncoder("UTF-8", "UTF-8"); - @Test - public void shouldAllowKeywordsInEnglishAsDefault() throws IOException { - ensureKeywordsAreLocalisedFor(null, null); - } + @Test + public void shouldAllowKeywordsInEnglishAsDefault() throws IOException { + ensureKeywordsAreLocalisedFor(null, null); + } - @Test - public void shouldAllowKeywordsInADifferentLocale() throws IOException { - ensureKeywordsAreLocalisedFor(new Locale("it"), null); - } + @Test + public void shouldAllowKeywordsInADifferentLocale() throws IOException { + ensureKeywordsAreLocalisedFor(new Locale("it"), null); + } - @Test(expected = ResourceBundleNotFoundException.class) - public void shouldFailIfResourceBundleIsNotFound() throws IOException { - ensureKeywordsAreLocalisedFor(new Locale("en"), "unknown"); - } + @Test(expected = ResourceBundleNotFoundException.class) + public void shouldFailIfResourceBundleIsNotFound() throws IOException { + ensureKeywordsAreLocalisedFor(new Locale("en"), "unknown"); + } - @Test(expected = I18nKeywordNotFoundException.class) - public void shouldFailIfKeywordIsNotFound() throws IOException { - ensureKeywordsAreLocalisedFor(new Locale("es"), null); - } + @Test(expected = I18nKeywordNotFoundException.class) + public void shouldFailIfKeywordIsNotFound() throws IOException { + ensureKeywordsAreLocalisedFor(new Locale("es"), null); + } - @Test + @Test public void shouldAllowKeywordsToBeOverriddenInStepsConfiguration() { StepsConfiguration configuration = new StepsConfiguration(); ensureKeywordsAreLocalised(configuration, new Locale("en")); @@ -55,49 +68,48 @@ ensureThat(startingWordsByType.get(StepType.WHEN), equalTo(keywords.when())); ensureThat(startingWordsByType.get(StepType.THEN), equalTo(keywords.then())); ensureThat(startingWordsByType.get(StepType.AND), equalTo(keywords.and())); + ensureThat(startingWordsByType.get(StepType.IGNORABLE), equalTo(keywords.ignorable())); } - - private void ensureKeywordsAreLocalisedFor(Locale locale, String bundleName) - throws IOException { - KeyWords keywords = keyWordsFor(locale, bundleName); - Properties properties = bundleFor(locale); - ensureKeywordIs(properties, "Scenario", keywords.scenario()); - ensureKeywordIs(properties, "GivenScenarios", keywords.givenScenarios()); - ensureKeywordIs(properties, "ExamplesTable", keywords.examplesTable()); - ensureKeywordIs(properties, "ExamplesTableRow", keywords - .examplesTableRow()); - ensureKeywordIs(properties, "Given", keywords.given()); - ensureKeywordIs(properties, "When", keywords.when()); - ensureKeywordIs(properties, "Then", keywords.then()); - ensureKeywordIs(properties, "And", keywords.and()); - ensureKeywordIs(properties, "Pending", keywords.pending()); - ensureKeywordIs(properties, "NotPerformed", keywords.notPerformed()); - ensureKeywordIs(properties, "Failed", keywords.failed()); - } - private I18nKeyWords keyWordsFor(Locale locale, String bundleName) { - if ( bundleName == null ){ - return (locale == null ? new I18nKeyWords() : new I18nKeyWords(locale)); - } else { - return new I18nKeyWords(locale, new StringEncoder(), bundleName, Thread.currentThread().getContextClassLoader()); - } - } + private void ensureKeywordsAreLocalisedFor(Locale locale, String bundleName) throws IOException { + KeyWords keywords = keyWordsFor(locale, bundleName); + Properties properties = bundleFor(locale); + ensureKeywordIs(properties, SCENARIO, keywords.scenario()); + ensureKeywordIs(properties, GIVEN_SCENARIOS, keywords.givenScenarios()); + ensureKeywordIs(properties, EXAMPLES_TABLE, keywords.examplesTable()); + ensureKeywordIs(properties, EXAMPLES_TABLE_ROW, keywords.examplesTableRow()); + ensureKeywordIs(properties, GIVEN, keywords.given()); + ensureKeywordIs(properties, WHEN, keywords.when()); + ensureKeywordIs(properties, THEN, keywords.then()); + ensureKeywordIs(properties, AND, keywords.and()); + ensureKeywordIs(properties, IGNORABLE, keywords.ignorable()); + ensureKeywordIs(properties, PENDING, keywords.pending()); + ensureKeywordIs(properties, NOT_PERFORMED, keywords.notPerformed()); + ensureKeywordIs(properties, FAILED, keywords.failed()); + } - private Properties bundleFor(Locale locale) throws IOException { - Properties expected = new Properties(); - String bundle = "org/jbehave/scenario/i18n/keywords_" - + (locale == null ? "en" : locale.getLanguage()) - + ".properties"; - InputStream stream = Thread.currentThread().getContextClassLoader() - .getResourceAsStream(bundle); - if (stream != null) { - expected.load(stream); - } - return expected; - } - - private void ensureKeywordIs(Properties properties, String key, String value) { - assertEquals(encoder.encode(properties.getProperty(key, value)), value); - } + private I18nKeyWords keyWordsFor(Locale locale, String bundleName) { + if (bundleName == null) { + return (locale == null ? new I18nKeyWords() : new I18nKeyWords(locale)); + } else { + return new I18nKeyWords(locale, new StringEncoder(), bundleName, Thread.currentThread() + .getContextClassLoader()); + } + } + private Properties bundleFor(Locale locale) throws IOException { + Properties expected = new Properties(); + String bundle = "org/jbehave/scenario/i18n/keywords_" + (locale == null ? "en" : locale.getLanguage()) + + ".properties"; + InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(bundle); + if (stream != null) { + expected.load(stream); + } + return expected; + } + + private void ensureKeywordIs(Properties properties, String key, String value) { + assertEquals(encoder.encode(properties.getProperty(key, value)), value); + } + }
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java (1543 => 1544)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java 2010-02-06 07:31:20 UTC (rev 1543) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java 2010-02-06 08:11:15 UTC (rev 1544) @@ -76,7 +76,7 @@ public boolean ignore(String stepAsString) { try { - String ignoreWord = startingWordFor(StepType.IGNORE); + String ignoreWord = startingWordFor(StepType.IGNORABLE); return stepAsString.startsWith(ignoreWord); } catch (StartingWordNotFound e) { return false;
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepType.java (1543 => 1544)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepType.java 2010-02-06 07:31:20 UTC (rev 1543) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepType.java 2010-02-06 08:11:15 UTC (rev 1544) @@ -28,5 +28,5 @@ /** * Represents an ignorable step */ - IGNORE + IGNORABLE }
Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsConfiguration.java (1543 => 1544)
--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsConfiguration.java 2010-02-06 07:31:20 UTC (rev 1543) +++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsConfiguration.java 2010-02-06 08:11:15 UTC (rev 1544) @@ -2,7 +2,7 @@ import static org.jbehave.scenario.steps.StepType.AND; import static org.jbehave.scenario.steps.StepType.GIVEN; -import static org.jbehave.scenario.steps.StepType.IGNORE; +import static org.jbehave.scenario.steps.StepType.IGNORABLE; import static org.jbehave.scenario.steps.StepType.THEN; import static org.jbehave.scenario.steps.StepType.WHEN; @@ -121,7 +121,7 @@ words.put(WHEN, keywords.when()); words.put(THEN, keywords.then()); words.put(AND, keywords.and()); - words.put(IGNORE, keywords.ignorable()); + words.put(IGNORABLE, keywords.ignorable()); return words; }
To unsubscribe from this list please visit:
