commit e6664b866f0d2f8fa84d6a7bf667348e62436a1d
Author:     Cristiano Gavião <cvgav...@gmail.com>
AuthorDate: Wed, 12 Mar 2014 17:01:47 -0300
Commit:     Mauro Talevi <mauro.tal...@aquilonia.org>
CommitDate: Sun, 13 Apr 2014 12:11:46 +0200

    JBEHAVE-1002:  Ensure parsing elements all use the same Configuration.

diff --git 
a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTableFactory.java 
b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTableFactory.java
index 320db73..c5ed6f3 100755
--- 
a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTableFactory.java
+++ 
b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTableFactory.java
@@ -30,7 +30,7 @@ import static org.apache.commons.lang.StringUtils.isBlank;
  */
 public class ExamplesTableFactory {
 
-    private final Keywords keywords;
+    private Keywords keywords;
     private final ResourceLoader resourceLoader;
     private final ParameterConverters parameterConverters;
     private final TableTransformers tableTransformers;
@@ -68,6 +68,13 @@ public class ExamplesTableFactory {
         this.tableTransformers = tableTranformers;
     }
     
+    public ExamplesTableFactory(Configuration configuration) {
+       this.keywords = configuration.keywords();
+       this.resourceLoader = configuration.resourceLoader();
+       this.parameterConverters = configuration.parameterConverters();
+       this.tableTransformers = new TableTransformers();
+    }
+
     public ExamplesTable createExamplesTable(String input) {
         String tableAsString;
         if (isBlank(input) || isTable(input)) {
@@ -84,4 +91,11 @@ public class ExamplesTableFactory {
         return input.contains(keywords.examplesTableHeaderSeparator());
     }
 
+    public void useKeywords(Keywords keywords){
+       this.keywords = keywords;
+    }
+
+       public Keywords keywords() {
+               return this.keywords;
+       }
 }
diff --git 
a/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java 
b/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
index b80f7d9..583b2ba 100755
--- a/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
@@ -7,6 +7,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
+import org.jbehave.core.configuration.Configuration;
 import org.jbehave.core.configuration.Keywords;
 import org.jbehave.core.i18n.LocalizedKeywords;
 import org.jbehave.core.model.Description;
@@ -38,16 +39,23 @@ public class RegexStoryParser implements StoryParser {
     }
 
     public RegexStoryParser(Keywords keywords) {
-        this(keywords, new ExamplesTableFactory());
+        this(keywords, new ExamplesTableFactory(keywords));
     }
 
     public RegexStoryParser(ExamplesTableFactory tableFactory) {
-        this(new LocalizedKeywords(), tableFactory);
+        this(tableFactory.keywords(), tableFactory);
     }
 
     public RegexStoryParser(Keywords keywords, ExamplesTableFactory 
tableFactory) {
         this.keywords = keywords;
         this.tableFactory = tableFactory;
+        // must ensure that both are using same keywords
+        this.tableFactory.useKeywords(keywords);
+    }
+
+    public RegexStoryParser(Configuration configuration) {
+       this.keywords = configuration.keywords();
+       this.tableFactory = new ExamplesTableFactory(configuration);
     }
     
     public Story parseStory(String storyAsText) {



Reply via email to