Title: [1493] trunk/core/jbehave-pico/src/main/java/org/jbehave/scenario/steps/pico: Moved behaviour steps in test class.

Diff

Modified: trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/PicoEnabledCandidateStepBehaviour.java (1492 => 1493)

--- trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/PicoEnabledCandidateStepBehaviour.java	2010-01-04 21:29:20 UTC (rev 1492)
+++ trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/PicoEnabledCandidateStepBehaviour.java	2010-01-05 11:40:23 UTC (rev 1493)
@@ -2,6 +2,7 @@
 
 import org.jbehave.scenario.annotations.Given;
 import org.jbehave.scenario.annotations.When;
+import org.jbehave.scenario.definition.ExamplesTable;
 import org.jbehave.scenario.parser.PrefixCapturingPatternBuilder;
 import org.jbehave.scenario.parser.StepPatternBuilder;
 import org.jbehave.scenario.reporters.ScenarioReporter;
@@ -63,14 +64,14 @@
 
     @Test
     public void shouldMatchASimpleString() throws Exception {
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I laugh", GIVEN, SomeSteps2.class.getMethod("aMethod"),
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I laugh", GIVEN, SomeSteps.class.getMethod("aMethod"),
                 null, PATTERN_BUILDER, new ParameterConverters(), startingWords, new EmptyPicoContainer());
         ensureThat(candidateStep.matches("Given I laugh"));
     }
 
     @Test
     public void shouldMatchAStringWithArguments() throws Exception {
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("windows on the $nth floor", WHEN, SomeSteps2.class
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("windows on the $nth floor", WHEN, SomeSteps.class
 				        .getMethod("aMethod"), null, PATTERN_BUILDER, new ParameterConverters(), startingWords, new EmptyPicoContainer());
         ensureThat(candidateStep.matches("When windows on the 1st floor"));
         ensureThat(not(candidateStep.matches("When windows on the 1st floor are open")));
@@ -78,9 +79,9 @@
 
     @Test
     public void shouldProvideARealStepUsingTheMatchedString() throws Exception {
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I live on the $args floor", THEN, SomeSteps2.class.getMethod(
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I live on the $args floor", THEN, SomeSteps.class.getMethod(
 				        "aMethodWith", String.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         Step step = candidateStep.createFrom(tableRow, "Then I live on the 1st floor");
         step.perform();
@@ -89,31 +90,31 @@
 
     @Test
     public void shouldMatchMultilineStrings() throws Exception {
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("the grid should look like $grid", THEN, SomeSteps2.class
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("the grid should look like $grid", THEN, SomeSteps.class
 				        .getMethod("aMethod"), null, PATTERN_BUILDER, new ParameterConverters(), startingWords, new EmptyPicoContainer());
         ensureThat(candidateStep.matches("Then the grid should look like " + NL + "...." + NL + "...." + NL));
     }
 
     @Test
     public void shouldConvertArgsToAppropriateNumbers() throws Exception {
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps2.class.getMethod(
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps.class.getMethod(
 				        "aMethodWith", int.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform();
         ensureThat((Integer) someSteps.args, equalTo(14));
 
-        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps2.class.getMethod("aMethodWith",
+        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps.class.getMethod("aMethodWith",
 				        long.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform();
         ensureThat((Long) someSteps.args, equalTo(14L));
 
-        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps2.class.getMethod("aMethodWith",
+        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps.class.getMethod("aMethodWith",
 				        double.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform();
         ensureThat((Double) someSteps.args, equalTo(14.0));
 
-        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps2.class.getMethod("aMethodWith",
+        candidateStep = new PicoEnabledCandidateStep("I should live in no. $args", THEN, SomeSteps.class.getMethod("aMethodWith",
 				        float.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "Then I should live in no. 14").perform();
         ensureThat((Float) someSteps.args, equalTo(14.0f));
@@ -122,9 +123,9 @@
     @Test
     public void shouldProvideAStepWithADescriptionThatMatchesTheCandidateStep() throws Exception {
         ScenarioReporter reporter = mock(ScenarioReporter.class);
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I live on the $nth floor", THEN, SomeSteps2.class.getMethod(
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("I live on the $nth floor", THEN, SomeSteps.class.getMethod(
 				        "aMethodWith", String.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         Step step = candidateStep.createFrom(tableRow, "Then I live on the 1st floor");
 
@@ -139,9 +140,9 @@
         String windowsNewline = "\r\n";
         String unixNewline = "\n";
         String systemNewline = System.getProperty("line.separator");
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
-        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("the grid should look like $grid", THEN, SomeSteps2.class.getMethod(
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
+        PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("the grid should look like $grid", THEN, SomeSteps.class.getMethod(
 				        "aMethodWith", String.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         Step step = candidateStep.createFrom(tableRow, "Then the grid should look like" + windowsNewline + ".." + unixNewline
                 + ".." + windowsNewline);
@@ -152,25 +153,25 @@
     @Test
     @Ignore
     public void shouldConvertArgsToListOfNumbers() throws Exception {
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
         PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("windows on the $nth floors",
-        		WHEN, SomeSteps2.methodFor("aMethodWithListOfLongs"), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
+        		WHEN, stepMethodFor("aMethodWithListOfLongs", SomeSteps.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "When windows on the 1L,2L,3L floors").perform();
         ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1L, 2L, 3L).toString()));
 
         candidateStep = new PicoEnabledCandidateStep("windows on the $nth floors", WHEN,
-                SomeSteps2.methodFor("aMethodWithListOfIntegers"), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
+                stepMethodFor("aMethodWithListOfIntegers", SomeSteps.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "When windows on the 1,2,3 floors").perform();
         ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1, 2, 3).toString()));
 
         candidateStep = new PicoEnabledCandidateStep("windows on the $nth floors", WHEN,
-                SomeSteps2.methodFor("aMethodWithListOfDoubles"), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
+                stepMethodFor("aMethodWithListOfDoubles", SomeSteps.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "When windows on the 1.1,2.2,3.3 floors").perform();
         ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1.1, 2.2, 3.3).toString()));
 
         candidateStep = new PicoEnabledCandidateStep("windows on the $nth floors", WHEN,
-                SomeSteps2.methodFor("aMethodWithListOfFloats"), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
+                stepMethodFor("aMethodWithListOfFloats", SomeSteps.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "When windows on the 1.1f,2.2f,3.3f floors").perform();
         ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList(1.1f, 2.2f, 3.3f).toString()));
 
@@ -179,10 +180,10 @@
     @Test
     @Ignore
     public void shouldConvertArgsToListOfStrings() throws Exception {
-        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps2.class);
-        SomeSteps2 someSteps = parent.getComponent(SomeSteps2.class);
+        parent.as(Characteristics.USE_NAMES).addComponent(SomeSteps.class);
+        SomeSteps someSteps = parent.getComponent(SomeSteps.class);
         PicoEnabledCandidateStep candidateStep = new PicoEnabledCandidateStep("windows on the $nth floors",
-        		WHEN, SomeSteps2.methodFor("aMethodWithListOfStrings"), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
+        		WHEN, stepMethodFor("aMethodWithListOfStrings", SomeSteps.class), someSteps, PATTERN_BUILDER, new ParameterConverters(), startingWords, parent);
         candidateStep.createFrom(tableRow, "When windows on the 1,2,3 floors").perform();
         ensureThat(((List<?>) someSteps.args).toString(), equalTo(asList("1", "2", "3").toString()));
     }
@@ -349,6 +350,68 @@
 
     }
 
+    public static class SomeSteps extends PicoEnabledSteps {
+
+        public SomeSteps(PicoEnabledStepsConfiguration configuration) {
+            super(configuration);
+        }
+
+        public Object args;
+
+        public void aMethod() {
+
+        }
+
+        public void aMethodWith(String args) {
+            this.args = args;
+        }
+
+        public void aMethodWith(double args) {
+            this.args = args;
+        }
+
+        public void aMethodWith(long args) {
+            this.args = args;
+        }
+
+        public void aMethodWith(int args) {
+            this.args = args;
+        }
+
+        public void aMethodWith(float args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfStrings(List<String> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfLongs(List<Long> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfIntegers(List<Integer> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfDoubles(List<Double> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfFloats(List<Float> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithListOfNumbers(List<Number> args) {
+            this.args = args;
+        }
+
+        public void aMethodWithExamplesTable(ExamplesTable args) {
+            this.args = args;
+        }
+
+    }
+
     static Method stepMethodFor(String methodName, Class<? extends Steps> stepsClass) throws IntrospectionException {
         BeanInfo beanInfo = Introspector.getBeanInfo(stepsClass);
         for (MethodDescriptor md : beanInfo.getMethodDescriptors()) {
@@ -358,5 +421,6 @@
         }
         return null;
     }
+    
 
 }

Deleted: trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/SomeSteps2.java (1492 => 1493)

--- trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/SomeSteps2.java	2010-01-04 21:29:20 UTC (rev 1492)
+++ trunk/core/jbehave-pico/src/behaviour/java/org/jbehave/scenario/steps/pico/SomeSteps2.java	2010-01-05 11:40:23 UTC (rev 1493)
@@ -1,83 +0,0 @@
-package org.jbehave.scenario.steps.pico;
-
-import org.jbehave.scenario.definition.ExamplesTable;
-import org.jbehave.scenario.steps.Steps;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.MethodDescriptor;
-import java.lang.reflect.Method;
-import java.util.List;
-
-public class SomeSteps2 extends Steps {
-
-    public SomeSteps2() {
-        System.out.println("");
-    }
-
-    public Object args;
-
-    public void aMethod() {
-
-    }
-
-    public void aMethodWith(String args) {
-        this.args = args;
-    }
-
-    public void aMethodWith(double args) {
-        this.args = args;
-    }
-
-    public void aMethodWith(long args) {
-        this.args = args;
-    }
-
-    public void aMethodWith(int args) {
-        this.args = args;
-    }
-
-    public void aMethodWith(float args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfStrings(List<String> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfLongs(List<Long> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfIntegers(List<Integer> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfDoubles(List<Double> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfFloats(List<Float> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithListOfNumbers(List<Number> args) {
-        this.args = args;
-    }
-
-    public void aMethodWithExamplesTable(ExamplesTable args) {
-        this.args = args;
-    }
-
-    public static Method methodFor(String methodName) throws IntrospectionException {
-        BeanInfo beanInfo = Introspector.getBeanInfo(SomeSteps2.class);
-        for (MethodDescriptor md : beanInfo.getMethodDescriptors()) {
-            if (md.getMethod().getName().equals(methodName)) {
-                return md.getMethod();
-            }
-        }
-        return null;
-    }
-
-}

Modified: trunk/core/jbehave-pico/src/main/java/org/jbehave/scenario/steps/pico/PicoEnabledSteps.java (1492 => 1493)

--- trunk/core/jbehave-pico/src/main/java/org/jbehave/scenario/steps/pico/PicoEnabledSteps.java	2010-01-04 21:29:20 UTC (rev 1492)
+++ trunk/core/jbehave-pico/src/main/java/org/jbehave/scenario/steps/pico/PicoEnabledSteps.java	2010-01-05 11:40:23 UTC (rev 1493)
@@ -1,11 +1,13 @@
 package org.jbehave.scenario.steps.pico;
 
-import org.jbehave.scenario.definition.KeyWords;
-import org.jbehave.scenario.steps.*;
+import java.lang.reflect.Method;
+
+import org.jbehave.scenario.steps.CandidateStep;
+import org.jbehave.scenario.steps.StepType;
+import org.jbehave.scenario.steps.Steps;
+import org.jbehave.scenario.steps.StepsConfiguration;
 import org.picocontainer.PicoContainer;
 
-import java.lang.reflect.Method;
-
 public class PicoEnabledSteps extends Steps {
 
     public PicoEnabledSteps(PicoEnabledStepsConfiguration configuration) {
@@ -16,11 +18,11 @@
         if (!(configuration instanceof PicoEnabledStepsConfiguration)) {
             throw new PicoEnabledException("StepsConfiguration parameter should be instanceof PicoEnabledStepsConfiguration");
         }
+        PicoContainer parent = ((PicoEnabledStepsConfiguration) configuration).getParentContainer();
         return new PicoEnabledCandidateStep(stepPatternAsString, stepType, method,
                 this, configuration.getPatternBuilder(),
                 configuration.getParameterConverters(),
-                configuration.getStartingWordsByType(), ((PicoEnabledStepsConfiguration) configuration).getParentContainer());
+                configuration.getStartingWordsByType(), parent);
     }
 
-
 }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to