Title: [1503] trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps: JBEHAVE-231: Refactored StepsFactory to not use static methods and to provide configuration via constructor.
Revision
1503
Author
mauro
Date
2010-01-07 11:10:31 -0600 (Thu, 07 Jan 2010)

Log Message

JBEHAVE-231:  Refactored StepsFactory to not use static methods and to provide configuration via constructor.

Modified Paths

Diff

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java (1502 => 1503)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java	2010-01-07 16:52:37 UTC (rev 1502)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderScenario.java	2010-01-07 17:10:31 UTC (rev 1503)
@@ -5,7 +5,6 @@
 import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.HTML;
 import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.TXT;
 import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.XML;
-import static org.jbehave.scenario.steps.StepsFactory.createCandidateSteps;
 
 import org.jbehave.examples.trader.converters.TraderConverter;
 import org.jbehave.examples.trader.model.Stock;
@@ -14,11 +13,20 @@
 import org.jbehave.scenario.JUnitScenario;
 import org.jbehave.scenario.PropertyBasedConfiguration;
 import org.jbehave.scenario.RunnableScenario;
-import org.jbehave.scenario.parser.*;
+import org.jbehave.scenario.parser.ClasspathScenarioDefiner;
+import org.jbehave.scenario.parser.PatternScenarioParser;
+import org.jbehave.scenario.parser.PrefixCapturingPatternBuilder;
+import org.jbehave.scenario.parser.ScenarioDefiner;
+import org.jbehave.scenario.parser.ScenarioNameResolver;
+import org.jbehave.scenario.parser.UnderscoredCamelCaseResolver;
 import org.jbehave.scenario.reporters.FilePrintStreamFactory;
 import org.jbehave.scenario.reporters.ScenarioReporter;
 import org.jbehave.scenario.reporters.ScenarioReporterBuilder;
-import org.jbehave.scenario.steps.*;
+import org.jbehave.scenario.steps.ParameterConverters;
+import org.jbehave.scenario.steps.SilentStepMonitor;
+import org.jbehave.scenario.steps.StepMonitor;
+import org.jbehave.scenario.steps.StepsConfiguration;
+import org.jbehave.scenario.steps.StepsFactory;
 
 public class TraderScenario extends JUnitScenario {
 
@@ -43,14 +51,14 @@
 
         });
 
-        StepsConfiguration config = new StepsConfiguration();
+        StepsConfiguration configuration = new StepsConfiguration();
         StepMonitor monitor = new SilentStepMonitor();
-		config.useParameterConverters(new ParameterConverters(
+		configuration.useParameterConverters(new ParameterConverters(
         		monitor, new TraderConverter(mockTradePersister())));  // define converter for custom type Trader
-        config.usePatternBuilder(new PrefixCapturingPatternBuilder("%")); // use '%' instead of '$' to identify parameters
-        config.useMonitor(monitor);
-
-        addSteps(createCandidateSteps(config, new TraderSteps()));
+        configuration.usePatternBuilder(new PrefixCapturingPatternBuilder("%")); // use '%' instead of '$' to identify parameters
+        configuration.useMonitor(monitor);
+        
+        addSteps(new StepsFactory(configuration).createCandidateSteps(new TraderSteps()));
     }
 
     private TraderPersister mockTradePersister() {

Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/StepsBehaviour.java (1502 => 1503)

--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/StepsBehaviour.java	2010-01-07 16:52:37 UTC (rev 1502)
+++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/StepsBehaviour.java	2010-01-07 17:10:31 UTC (rev 1503)
@@ -61,7 +61,7 @@
     @Test
     public void shouldProvideCandidateStepsCorrespondingToAnnotatedStepsInPojo() {
         PojoSteps steps = new PojoSteps();
-        CandidateStep[] candidateSteps = StepsFactory.createCandidateSteps(steps)[0].getSteps();
+        CandidateStep[] candidateSteps = new StepsFactory().createCandidateSteps(steps)[0].getSteps();
         ensureThat(candidateSteps.length, equalTo(6));
 
         findCandidateStep(candidateSteps, "GIVEN a given").createFrom(tableRow, "Given a given").perform();

Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsFactory.java (1502 => 1503)

--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsFactory.java	2010-01-07 16:52:37 UTC (rev 1502)
+++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepsFactory.java	2010-01-07 17:10:31 UTC (rev 1503)
@@ -8,11 +8,17 @@
  */
 public class StepsFactory {
 
-    public static CandidateSteps[] createCandidateSteps(Object... stepsInstances) {
-        return createCandidateSteps(new StepsConfiguration(), stepsInstances);
+    private StepsConfiguration configuration;
+
+    public StepsFactory() {
+        this(new StepsConfiguration());
     }
 
-    public static CandidateSteps[] createCandidateSteps(StepsConfiguration configuration, Object... stepsInstances) {
+    public StepsFactory(StepsConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public CandidateSteps[] createCandidateSteps(Object... stepsInstances) {
         CandidateSteps[] candidateSteps = new CandidateSteps[stepsInstances.length];
         for (int i = 0; i < stepsInstances.length; i++) {
             candidateSteps[i] = new Steps(configuration, stepsInstances[i]);


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to