diff --git a/.gitignore b/.gitignore index 23dde485aa..6a329b204f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ target *.iws tmp/ doc/ +/.settings +/.project diff --git a/clojure/.gitignore b/clojure/.gitignore new file mode 100644 index 0000000000..2bc09d1be1 --- /dev/null +++ b/clojure/.gitignore @@ -0,0 +1,3 @@ +/.classpath +/.settings +/.project diff --git a/clojure/src/main/java/cucumber/runtime/clojure/ClojureBackend.java b/clojure/src/main/java/cucumber/runtime/clojure/ClojureBackend.java index 53d21bca9b..97191458ea 100644 --- a/clojure/src/main/java/cucumber/runtime/clojure/ClojureBackend.java +++ b/clojure/src/main/java/cucumber/runtime/clojure/ClojureBackend.java @@ -1,17 +1,21 @@ package cucumber.runtime.clojure; -import clojure.lang.AFunction; -import clojure.lang.RT; -import cucumber.classpath.Classpath; -import cucumber.classpath.Consumer; -import cucumber.classpath.Input; -import cucumber.runtime.*; import gherkin.formatter.model.Step; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; +import clojure.lang.AFunction; +import clojure.lang.RT; +import cucumber.classpath.Classpath; +import cucumber.classpath.Consumer; +import cucumber.classpath.Input; +import cucumber.runtime.Backend; +import cucumber.runtime.CucumberException; +import cucumber.runtime.StepDefinition; + public class ClojureBackend implements Backend { private final List stepDefinitions = new ArrayList(); private String scriptPath; @@ -67,9 +71,9 @@ private StackTraceElement stepDefLocation(String interpreterClassName, String in throw new CucumberException("Couldn't find location for step definition"); } - public static void addStepDefinition(Pattern regexp, AFunction body) { + public static void addStepDefinition(Pattern regexp, AFunction body, Locale locale) { StackTraceElement location = instance.stepDefLocation("clojure.lang.Compiler", "eval"); - instance.stepDefinitions.add(new ClojureStepDefinition(regexp, body, location)); + instance.stepDefinitions.add(new ClojureStepDefinition(regexp, body, location, locale)); } } diff --git a/clojure/src/main/java/cucumber/runtime/clojure/ClojureStepDefinition.java b/clojure/src/main/java/cucumber/runtime/clojure/ClojureStepDefinition.java index 03238582e3..ce230259fb 100644 --- a/clojure/src/main/java/cucumber/runtime/clojure/ClojureStepDefinition.java +++ b/clojure/src/main/java/cucumber/runtime/clojure/ClojureStepDefinition.java @@ -1,24 +1,27 @@ package cucumber.runtime.clojure; -import clojure.lang.AFunction; -import cucumber.runtime.JdkPatternArgumentMatcher; -import cucumber.runtime.StepDefinition; -import cuke4duke.internal.Utils; import gherkin.formatter.Argument; import gherkin.formatter.model.Step; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; -public class ClojureStepDefinition implements StepDefinition { +import clojure.lang.AFunction; +import cucumber.runtime.AbstractStepDefinition; +import cucumber.runtime.JdkPatternArgumentMatcher; +import cuke4duke.internal.Utils; + +public class ClojureStepDefinition extends AbstractStepDefinition { private final Pattern regexp; private final AFunction closure; private StackTraceElement location; - public ClojureStepDefinition(Pattern regexp, AFunction closure, StackTraceElement location) { - this.regexp = regexp; + public ClojureStepDefinition(Pattern regexp, AFunction closure, StackTraceElement location, Locale locale) { + super(locale); + this.regexp = regexp; this.closure = closure; this.location = location; } diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 0000000000..2bc09d1be1 --- /dev/null +++ b/core/.gitignore @@ -0,0 +1,3 @@ +/.classpath +/.settings +/.project diff --git a/core/Rakefile b/core/Rakefile index 11505e0da2..5851a49b13 100644 --- a/core/Rakefile +++ b/core/Rakefile @@ -1,7 +1,8 @@ +require 'rubygems' require 'gherkin/i18n' require 'erb' -task :default => ['generate:java', 'generate:groovy'] +task :default => ['generate:java'] namespace :generate do desc 'Generate Java code' @@ -28,13 +29,4 @@ public interface I18n { end end - desc 'Generate Groovy code' - task :groovy do - groovy = ERB.new(IO.read(File.dirname(__FILE__) + '/src/main/code_generator/I18n.groovy.erb'), nil, '-') - Gherkin::I18n.all.each do |i18n| - File.open(File.dirname(__FILE__) + "/src/main/java/cucumber/runtime/groovy/#{i18n.underscored_iso_code.upcase}.java", 'wb') do |io| - io.write(groovy.result(binding)) - end - end - end -end + end diff --git a/core/src/main/java/cucumber/runtime/AbstractStepDefinition.java b/core/src/main/java/cucumber/runtime/AbstractStepDefinition.java new file mode 100644 index 0000000000..998f47e5e4 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/AbstractStepDefinition.java @@ -0,0 +1,18 @@ +package cucumber.runtime; + +import java.util.Locale; + +public abstract class AbstractStepDefinition implements StepDefinition { + // TODO: Used by StepDefinitionMatch to convert arguments before executions (float etc.) + // Maybe pass it to run instead (taking it from the locale of feature instead). + // For now StepDefinitions are linked to the Backend with locale agnostic + private final Locale locale; + + public AbstractStepDefinition(Locale locale) { + this.locale = locale; + } + + public Locale getLocale() { + return this.locale; + } +} diff --git a/core/src/main/java/cucumber/runtime/Runtime.java b/core/src/main/java/cucumber/runtime/Runtime.java index 7459368030..89f4133c55 100644 --- a/core/src/main/java/cucumber/runtime/Runtime.java +++ b/core/src/main/java/cucumber/runtime/Runtime.java @@ -1,9 +1,7 @@ package cucumber.runtime; -import cucumber.classpath.Classpath; -import gherkin.GherkinParser; +import static java.util.Arrays.asList; import gherkin.formatter.Argument; -import gherkin.formatter.model.Feature; import gherkin.formatter.model.Step; import java.util.ArrayList; @@ -11,11 +9,13 @@ import java.util.Comparator; import java.util.List; -import static java.util.Arrays.asList; +import cucumber.classpath.Classpath; +import cucumber.runtime.transformers.Transformer; public class Runtime { private final List backends; private final List undefinedSteps = new ArrayList(); + private Transformer transformer; public Runtime(Backend... backends) { this.backends = asList(backends); @@ -45,7 +45,7 @@ private List stepDefinitionMatches(Step step) { for (StepDefinition stepDefinition : backend.getStepDefinitions()) { List arguments = stepDefinition.matchedArguments(step); if (arguments != null) { - result.add(new StepDefinitionMatch(arguments, stepDefinition, step)); + result.add(new StepDefinitionMatch(arguments, stepDefinition, step, getTransformer())); } } } @@ -84,4 +84,15 @@ public int compare(Step a, Step b) { public World newWorld() { return new World(backends, this); } + + public Transformer getTransformer() { + if (this.transformer == null) { + this.transformer = new Transformer(); + } + return this.transformer; + } + + public void setTransformer(Transformer transformer) { + this.transformer = transformer; + } } diff --git a/core/src/main/java/cucumber/runtime/StepDefinition.java b/core/src/main/java/cucumber/runtime/StepDefinition.java index 7049f67b65..b434bd4835 100644 --- a/core/src/main/java/cucumber/runtime/StepDefinition.java +++ b/core/src/main/java/cucumber/runtime/StepDefinition.java @@ -4,6 +4,7 @@ import gherkin.formatter.model.Step; import java.util.List; +import java.util.Locale; public interface StepDefinition { /** @@ -40,4 +41,9 @@ public interface StepDefinition { * stack traces. */ boolean isDefinedAt(StackTraceElement stackTraceElement); // TODO: redundant with getLocation? + + /** + * @return the locale associated with the step + */ + Locale getLocale(); } diff --git a/core/src/main/java/cucumber/runtime/StepDefinitionMatch.java b/core/src/main/java/cucumber/runtime/StepDefinitionMatch.java index b412bbf0c0..4c5649b8ef 100644 --- a/core/src/main/java/cucumber/runtime/StepDefinitionMatch.java +++ b/core/src/main/java/cucumber/runtime/StepDefinitionMatch.java @@ -6,17 +6,22 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; +import java.util.Locale; + +import cucumber.runtime.transformers.Transformer; import static java.util.Arrays.asList; public class StepDefinitionMatch extends Match { private final StepDefinition stepDefinition; private final Step step; + private Transformer transformer; - public StepDefinitionMatch(List arguments, StepDefinition stepDefinition, Step step) { + public StepDefinitionMatch(List arguments, StepDefinition stepDefinition, Step step, Transformer transformer) { super(arguments, stepDefinition.getLocation()); this.stepDefinition = stepDefinition; this.step = step; + this.transformer = transformer; } public void run(String path) throws Throwable { @@ -39,13 +44,15 @@ private Object[] getTransformedArgs(Class[] parameterTypes) { Object[] result = new Object[getArguments().size()]; int n = 0; for (Argument a : getArguments()) { - // TODO: Use the Locale for transformation - // TODO: Also use method signature to transform ints... - result[n++] = a.getVal(); + result[n] = this.transformer.transform(a, parameterTypes[n++], getLocale()); } return result; } + private Locale getLocale() { + return this.stepDefinition.getLocale(); + } + private Throwable filterStacktrace(Throwable error, StackTraceElement stepLocation) { StackTraceElement[] stackTraceElements = error.getStackTrace(); if (error.getCause() != null && error.getCause() != error) { diff --git a/core/src/main/java/cucumber/runtime/transformers/BigDecimalTransformable.java b/core/src/main/java/cucumber/runtime/transformers/BigDecimalTransformable.java new file mode 100644 index 0000000000..ded02d6f37 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/BigDecimalTransformable.java @@ -0,0 +1,14 @@ +package cucumber.runtime.transformers; + +import java.math.BigDecimal; + +public class BigDecimalTransformable extends + TransformableWithNumberFormat { + + @Override + protected BigDecimal doTransform(Number number) { + // See http://java.sun.com/j2se/6/docs/api/java/math/BigDecimal.html#BigDecimal%28double%29 + return new BigDecimal(Double.toString(number.doubleValue())); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/BigIntegerTransformable.java b/core/src/main/java/cucumber/runtime/transformers/BigIntegerTransformable.java new file mode 100644 index 0000000000..b34660bb63 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/BigIntegerTransformable.java @@ -0,0 +1,12 @@ +package cucumber.runtime.transformers; + +import java.math.BigInteger; + +public class BigIntegerTransformable extends TransformableWithNumberFormat { + + @Override + protected BigInteger doTransform(Number argument) { + return BigInteger.valueOf(argument.longValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/BooleanTransformable.java b/core/src/main/java/cucumber/runtime/transformers/BooleanTransformable.java new file mode 100644 index 0000000000..2b16029270 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/BooleanTransformable.java @@ -0,0 +1,15 @@ +package cucumber.runtime.transformers; + +import java.util.Locale; + +public class BooleanTransformable implements Transformable { + + public Boolean transform(String argument, Locale locale) { + if ("false".equalsIgnoreCase(argument) || "true".equalsIgnoreCase(argument)) { + return Boolean.parseBoolean(argument); + } else { + throw new TransformationException(String.format(locale, "Could not convert %s to Boolean", argument)); + } + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/ByteTransformable.java b/core/src/main/java/cucumber/runtime/transformers/ByteTransformable.java new file mode 100644 index 0000000000..c8294d4eda --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/ByteTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class ByteTransformable extends TransformableWithNumberFormat { + + @Override + protected Byte doTransform(Number value) { + return Byte.valueOf(value.byteValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/CharacterTransformable.java b/core/src/main/java/cucumber/runtime/transformers/CharacterTransformable.java new file mode 100644 index 0000000000..11529bd227 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/CharacterTransformable.java @@ -0,0 +1,14 @@ +package cucumber.runtime.transformers; + +import java.util.Locale; + +public class CharacterTransformable implements Transformable { + + public Character transform(String argument, Locale locale) { + if (argument.length() < 1) { + return null; + } + return Character.valueOf(argument.charAt(0)); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/DateTransformable.java b/core/src/main/java/cucumber/runtime/transformers/DateTransformable.java new file mode 100644 index 0000000000..30d59080b4 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/DateTransformable.java @@ -0,0 +1,17 @@ +package cucumber.runtime.transformers; + +import java.text.DateFormat; +import java.text.Format; +import java.util.Date; +import java.util.Locale; + +public class DateTransformable extends TransformableWithFormat { + + public Format getFormat(Locale locale) { + DateFormat format = DateFormat + .getDateInstance(DateFormat.SHORT, locale); + format.setLenient(false); + return format; + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/DoubleTransformable.java b/core/src/main/java/cucumber/runtime/transformers/DoubleTransformable.java new file mode 100644 index 0000000000..03c2ab7a9f --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/DoubleTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class DoubleTransformable extends TransformableWithNumberFormat { + + @Override + protected Double doTransform(Number transform) { + return Double.valueOf(transform.doubleValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/FloatTransformable.java b/core/src/main/java/cucumber/runtime/transformers/FloatTransformable.java new file mode 100644 index 0000000000..0668b38764 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/FloatTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class FloatTransformable extends TransformableWithNumberFormat { + + @Override + protected Float doTransform(Number argument) { + return Float.valueOf(argument.floatValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/IntegerTransformable.java b/core/src/main/java/cucumber/runtime/transformers/IntegerTransformable.java new file mode 100644 index 0000000000..97a4aa861d --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/IntegerTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class IntegerTransformable extends TransformableWithNumberFormat { + + @Override + protected Integer doTransform(Number number) { + return Integer.valueOf(number.intValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/LongTransformable.java b/core/src/main/java/cucumber/runtime/transformers/LongTransformable.java new file mode 100644 index 0000000000..229f1d1763 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/LongTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class LongTransformable extends TransformableWithNumberFormat { + + @Override + protected Long doTransform(Number argument) { + return Long.valueOf(argument.longValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/ShortTransformable.java b/core/src/main/java/cucumber/runtime/transformers/ShortTransformable.java new file mode 100644 index 0000000000..64464f9d54 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/ShortTransformable.java @@ -0,0 +1,10 @@ +package cucumber.runtime.transformers; + +public class ShortTransformable extends TransformableWithNumberFormat { + + @Override + protected Short doTransform(Number argument) { + return Short.valueOf(argument.shortValue()); + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/StringTransformable.java b/core/src/main/java/cucumber/runtime/transformers/StringTransformable.java new file mode 100644 index 0000000000..88fe93d3f3 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/StringTransformable.java @@ -0,0 +1,11 @@ +package cucumber.runtime.transformers; + +import java.util.Locale; + +public class StringTransformable implements Transformable { + + public String transform(String argument, Locale locale) { + return argument; + } + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/Transformable.java b/core/src/main/java/cucumber/runtime/transformers/Transformable.java new file mode 100644 index 0000000000..6ed96e493d --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/Transformable.java @@ -0,0 +1,7 @@ +package cucumber.runtime.transformers; + +import java.util.Locale; + +public interface Transformable { + public T transform(String argument, Locale locale); +} diff --git a/core/src/main/java/cucumber/runtime/transformers/TransformableWithFormat.java b/core/src/main/java/cucumber/runtime/transformers/TransformableWithFormat.java new file mode 100644 index 0000000000..8b3b171f22 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/TransformableWithFormat.java @@ -0,0 +1,45 @@ +package cucumber.runtime.transformers; + +import java.text.Format; +import java.text.ParsePosition; +import java.util.Locale; + +public abstract class TransformableWithFormat implements Transformable { + + public T transform(String argument, Locale locale) { + return transform(getFormat(locale), argument, locale); + } + + /** + * + * @param locale + * The locale used to parse + * @return A Format to parse the argument + */ + public abstract Format getFormat(Locale locale); + + /** + * Parses a value using one of the java.util.text format classes. + * + * @param format + * The format to use + * @param argument + * The object to parse + * @param locale + * The locale used to parse + * @return The object + * @throws TransformationException + * Thrown if parsing fails + */ + @SuppressWarnings("unchecked") + protected T transform(final Format format, final String argument, + Locale locale) { + ParsePosition position = new ParsePosition(0); + Object result = format.parseObject(argument, position); + if (position.getErrorIndex() != -1) { + throw new TransformationException("Can't parse '" + argument + + "' using format " + format); + } + return (T) result; + } +} diff --git a/core/src/main/java/cucumber/runtime/transformers/TransformableWithNumberFormat.java b/core/src/main/java/cucumber/runtime/transformers/TransformableWithNumberFormat.java new file mode 100644 index 0000000000..1ccf9f51a8 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/TransformableWithNumberFormat.java @@ -0,0 +1,22 @@ +package cucumber.runtime.transformers; + +import java.text.Format; +import java.text.NumberFormat; +import java.util.Locale; + +public abstract class TransformableWithNumberFormat extends + TransformableWithFormat { + + @Override + public T transform(String argument, Locale locale) { + return doTransform(super.transform(argument, locale)); + } + + @Override + public Format getFormat(Locale locale) { + return NumberFormat.getNumberInstance(locale); + } + + protected abstract T doTransform(Number argument); + +} diff --git a/core/src/main/java/cucumber/runtime/transformers/TransformationException.java b/core/src/main/java/cucumber/runtime/transformers/TransformationException.java new file mode 100644 index 0000000000..8c61fdd182 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/TransformationException.java @@ -0,0 +1,21 @@ +package cucumber.runtime.transformers; + +public class TransformationException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 3893851462286949513L; + + public TransformationException(Throwable t) { + super(t); + } + + public TransformationException(String message, Throwable t) { + super (message, t); + } + + public TransformationException(String message) { + super (message); + } +} diff --git a/core/src/main/java/cucumber/runtime/transformers/Transformer.java b/core/src/main/java/cucumber/runtime/transformers/Transformer.java new file mode 100644 index 0000000000..7e26370439 --- /dev/null +++ b/core/src/main/java/cucumber/runtime/transformers/Transformer.java @@ -0,0 +1,78 @@ +package cucumber.runtime.transformers; + +import gherkin.formatter.Argument; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +/** + * + * Class for transforming argument to a certain type using a Locale + * + */ +public class Transformer { + private Map, Transformable> transformables; + + @SuppressWarnings("unchecked") + public T transform(Argument argument, Class clazz, Locale locale) { + Transformable transformable = getTransformable(clazz); + if (transformable == null) { + throw new TransformationException("Can't transform " + argument.getVal() + " to: " + clazz.getName() + ". No transformable found."); + } + return (T) transformable.transform(argument.getVal(), locale); + } + + private Transformable getTransformable(Class clazz) { + return getTransformables().get(clazz); + } + + public Map, Transformable> getTransformables() { + if (this.transformables == null) { + this.transformables = registerDefaultTransformables(); + } + return this.transformables; + } + + protected Map, Transformable> registerDefaultTransformables() { + HashMap, Transformable> hashMap = new HashMap, Transformable>(); + hashMap.put(String.class, new StringTransformable()); + hashMap.put(Date.class, new DateTransformable()); + hashMap.put(BigDecimal.class, new BigDecimalTransformable()); + hashMap.put(BigIntegerTransformable.class, new BigIntegerTransformable()); + BooleanTransformable booleanTransformable = new BooleanTransformable(); + hashMap.put(Boolean.TYPE, booleanTransformable); + hashMap.put(Boolean.class, booleanTransformable); + ByteTransformable byteTransformable = new ByteTransformable(); + hashMap.put(Byte.TYPE, byteTransformable); + hashMap.put(Byte.class, byteTransformable); + CharacterTransformable characterTransformable = new CharacterTransformable(); + hashMap.put(Character.TYPE, characterTransformable); + hashMap.put(Character.class, characterTransformable); + DoubleTransformable doubleTransformable = new DoubleTransformable(); + hashMap.put(Double.TYPE, doubleTransformable); + hashMap.put(Double.class, doubleTransformable); + FloatTransformable floatTransformable = new FloatTransformable(); + hashMap.put(Float.TYPE, floatTransformable); + hashMap.put(Float.class, floatTransformable); + IntegerTransformable integerTransformable = new IntegerTransformable(); + hashMap.put(Integer.TYPE, integerTransformable); + hashMap.put(Integer.class, integerTransformable); + LongTransformable longTransformable = new LongTransformable(); + hashMap.put(Long.TYPE, longTransformable); + hashMap.put(Long.class, longTransformable); + ShortTransformable shortTransformable = new ShortTransformable(); + hashMap.put(Short.TYPE, shortTransformable); + hashMap.put(Short.class, shortTransformable); + return hashMap; + } + + public void addTransformable(Class clazz, Transformable transformable) { + getTransformables().put(clazz, transformable); + } + + public void setTransformables(Map, Transformable> transformables) { + this.transformables = transformables; + } +} diff --git a/core/src/main/java/cuke4duke/internal/jvmclass/DefaultJvmTransforms.java b/core/src/main/java/cuke4duke/internal/jvmclass/DefaultJvmTransforms.java deleted file mode 100644 index 002081a6f1..0000000000 --- a/core/src/main/java/cuke4duke/internal/jvmclass/DefaultJvmTransforms.java +++ /dev/null @@ -1,85 +0,0 @@ -package cuke4duke.internal.jvmclass; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.Locale; - -public class DefaultJvmTransforms { - public static Object transformStringToObject(String argument, Locale locale) { - return argument; - } - - public static int transformStringToInt(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).intValue(); - } - - public static Integer transformStringToInteger(String argument, Locale locale) throws ParseException { - return transformStringToInt(argument, locale); - } - - public static long transformStringToLongPrimitive(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).longValue(); - } - - public static Long transformStringToLong(String argument, Locale locale) throws ParseException { - return transformStringToLongPrimitive(argument, locale); - } - - public static double transformStringToDoublePrimitive(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).doubleValue(); - } - - public static Double transformStringToDouble(String argument, Locale locale) throws ParseException { - return transformStringToDoublePrimitive(argument, locale); - } - - public static float transformStringToFloatPrimitive(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).floatValue(); - } - - public static Float transformStringToFloat(String argument, Locale locale) throws ParseException { - return transformStringToFloatPrimitive(argument, locale); - } - - public static short transformStringToShortPrimitive(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).shortValue(); - } - - public static Short transformStringToShort(String argument, Locale locale) throws ParseException { - return transformStringToShortPrimitive(argument, locale); - } - - public static byte transformStringToBytePrimitive(String argument, Locale locale) throws ParseException { - return NumberFormat.getInstance(locale).parse(argument).byteValue(); - } - - public static Byte transformStringToByte(String argument, Locale locale) throws ParseException { - return transformStringToBytePrimitive(argument, locale); - } - - public static char transformStringToChar(String argument, Locale locale) { - return argument.charAt(0); - } - - public static Character transformStringToCharacters(String argument, Locale locale) { - return argument.charAt(0); - } - - public static BigDecimal transformStringToBigDecimal(String argument, Locale locale) throws ParseException { - return BigDecimal.valueOf(transformStringToDoublePrimitive(argument, locale)); - } - - public static BigInteger transformStringToBigInteger(String argument, Locale locale) throws ParseException { - return BigInteger.valueOf(transformStringToLongPrimitive(argument, locale)); - } - - public static boolean transformStringToBooleanPrimitive(String argument, Locale locale) { - return Boolean.valueOf(argument); - } - - public static Boolean transformStringToBoolean(String argument, Locale locale) { - return Boolean.valueOf(argument); - } -} diff --git a/core/src/test/java/cucumber/runtime/StepDefinitionMatchTest.java b/core/src/test/java/cucumber/runtime/StepDefinitionMatchTest.java new file mode 100644 index 0000000000..57571f254a --- /dev/null +++ b/core/src/test/java/cucumber/runtime/StepDefinitionMatchTest.java @@ -0,0 +1,29 @@ +package cucumber.runtime; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import gherkin.formatter.Argument; +import gherkin.formatter.model.Step; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import org.junit.Test; + +import cucumber.runtime.transformers.Transformer; +public class StepDefinitionMatchTest { + @Test + public void shouldConvertParameters() throws Throwable { + List arguments = Arrays.asList(new Argument(0, "5")); + StepDefinition stepDefinition = mock(StepDefinition.class); + when(stepDefinition.getLocale()).thenReturn(Locale.ENGLISH); + Class[] parameterTypes = {Integer.TYPE}; + when(stepDefinition.getParameterTypes()).thenReturn(parameterTypes ); + StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(arguments, stepDefinition, mock(Step.class), new Transformer()); + stepDefinitionMatch.run("step-definition-match-test"); + Object[] args = {5}; + verify(stepDefinition).execute(args); + } +} diff --git a/core/src/test/java/cucumber/runtime/transformers/StandardTransformersTest.java b/core/src/test/java/cucumber/runtime/transformers/StandardTransformersTest.java new file mode 100644 index 0000000000..d2a0b94bc7 --- /dev/null +++ b/core/src/test/java/cucumber/runtime/transformers/StandardTransformersTest.java @@ -0,0 +1,133 @@ +package cucumber.runtime.transformers; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import org.junit.Assert; +import org.junit.Test; + +import cuke4duke.internal.Utils; + +public class StandardTransformersTest { + @Test + public void shouldTransformBoolean() { + Boolean transformFalse = new BooleanTransformable().transform("false", Locale.ENGLISH); + Boolean transformTrue = new BooleanTransformable().transform("true", Locale.ENGLISH); + Assert.assertFalse(transformFalse); + Assert.assertTrue(transformTrue); + } + + @Test(expected = TransformationException.class) + public void shouldThrowTransformationExceptionWhenConvertingBoolean() { + new BooleanTransformable().transform("vrai", Locale.ENGLISH); + } + + @Test + public void shouldTransformBigDecimal() { + BigDecimal englishBigDecimal = new BigDecimalTransformable().transform("300.15", + Locale.ENGLISH); + BigDecimal englishBigDecimal2 = new BigDecimalTransformable().transform("30000000.15", + Locale.ENGLISH); + BigDecimal englishInteger = new BigDecimalTransformable().transform("300", Locale.ENGLISH); + BigDecimal frenchBigDecimal = new BigDecimalTransformable().transform("300,15", + Locale.FRENCH); + Assert.assertEquals(new BigDecimal("300.15"), englishBigDecimal); + Assert.assertEquals(new BigDecimal("30000000.15"), englishBigDecimal2); + Assert.assertEquals(new BigDecimal("300.15"), frenchBigDecimal); + Assert.assertEquals(new BigDecimal("300.0"), englishInteger); + } + + @Test + public void shouldTransformDate() { + Assert.assertEquals(getDateToTest(), + new DateTransformable().transform("11/29/2011", Locale.ENGLISH)); + Assert.assertEquals(getDateToTest(), + new DateTransformable().transform("29/11/2011", Locale.FRENCH)); + } + + @Test(expected = TransformationException.class) + public void shouldThrowTransformationExceptionWhenConvertingInvalidDate() { + Assert.assertEquals(getDateToTest(), + new DateTransformable().transform("29/11/2011", Locale.ENGLISH)); + } + + private Date getDateToTest() { + Calendar calendar = Calendar.getInstance(); + calendar.set(2011, 10, 29, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTime(); + } + + @Test + public void shouldTransformIntegers() { + Integer expected = Integer.valueOf(1000); + Assert.assertEquals(expected, new IntegerTransformable().transform("1000", Locale.ENGLISH)); + Assert.assertEquals(expected, new IntegerTransformable().transform("1,000", Locale.ENGLISH)); + Assert.assertEquals(expected, + new IntegerTransformable().transform("1.000", Utils.localeFor("pt"))); + } + + @Test + public void shouldTransformDoubles() { + Double expected = Double.valueOf(3000.15); + Assert.assertEquals(expected, + new DoubleTransformable().transform("3000.15", Locale.ENGLISH)); + Assert.assertEquals(expected, + new DoubleTransformable().transform("3,000.15", Locale.ENGLISH)); + Assert.assertEquals(expected, + new DoubleTransformable().transform("3.000,15", Utils.localeFor("pt"))); + Assert.assertEquals(expected, + new DoubleTransformable().transform("3000,15", Locale.FRENCH)); + } + + @Test + public void shouldTransformLongs() { + Long expected = Long.valueOf(8589934592L); + Assert.assertEquals(expected, new LongTransformable().transform("8589934592", Locale.ENGLISH)); + Assert.assertEquals(expected, new LongTransformable().transform("8,589,934,592", Locale.ENGLISH)); + } + + @Test + public void shouldTransformShorts() { + short exp = 32767; + short exp2 = -32768; + Short expected = Short.valueOf(exp); + Short expected2 = Short.valueOf(exp2); + Assert.assertEquals(expected, new ShortTransformable().transform("32767", Locale.ENGLISH)); + Assert.assertEquals(expected, new ShortTransformable().transform("32,767", Locale.ENGLISH)); + Assert.assertEquals(expected2, new ShortTransformable().transform("-32,768", Locale.ENGLISH)); + } + + @Test + public void shouldTransformBytes() { + byte exp = 127; + Byte expected = Byte.valueOf(exp); + Assert.assertEquals(expected, new ByteTransformable().transform("127", Locale.ENGLISH)); + Assert.assertEquals(expected, new ByteTransformable().transform("127", Locale.ENGLISH)); + } + + @Test + public void shouldTransformChars() { + Character expected = Character.valueOf('C'); + Assert.assertEquals(expected, new CharacterTransformable().transform("Cedric", Locale.ENGLISH)); + Assert.assertEquals(expected, new CharacterTransformable().transform("C", Locale.ENGLISH)); + } + + @Test + public void shouldTransformFloats() { + Float expected = Float.valueOf(3000.15f); + Assert.assertEquals(expected, new FloatTransformable().transform("3000.15", Locale.ENGLISH)); + Assert.assertEquals(expected, new FloatTransformable().transform("3,000.15", Locale.ENGLISH)); + } + + @Test + public void shouldTransformBigInteger() { + BigInteger expected = BigInteger.valueOf(8589934592L); + Assert.assertEquals(expected, new BigIntegerTransformable().transform("8589934592", Locale.ENGLISH)); + Assert.assertEquals(expected, new BigIntegerTransformable().transform("8,589,934,592", Locale.ENGLISH)); + } + +} diff --git a/core/src/test/java/cucumber/runtime/transformers/TransformerTest.java b/core/src/test/java/cucumber/runtime/transformers/TransformerTest.java new file mode 100644 index 0000000000..890d499c16 --- /dev/null +++ b/core/src/test/java/cucumber/runtime/transformers/TransformerTest.java @@ -0,0 +1,25 @@ +package cucumber.runtime.transformers; + +import gherkin.formatter.Argument; + +import java.math.BigDecimal; +import java.util.Locale; + +import org.junit.Assert; +import org.junit.Test; + +public class TransformerTest { + @Test + public void shouldTransformToTheRightType() { + Argument argument = new Argument(0, "true"); + Transformer transformer = new Transformer(); + Locale english = Locale.ENGLISH; + Boolean transformBool = transformer.transform(argument, Boolean.class, english); + Assert.assertTrue(transformBool); + boolean transformBoolPrimitive = transformer.transform(argument, Boolean.TYPE, english); + Assert.assertTrue("Boolean primitive transformation", transformBoolPrimitive); + Assert.assertEquals("Float class transformation", Float.valueOf(3000.15f), transformer.transform(new Argument(0, "3000.15"), Float.class, english)); + Assert.assertEquals("Float primitive transformation", Float.valueOf(3000.15f), transformer.transform(new Argument(0, "3000.15"), Float.TYPE, english)); + Assert.assertEquals("BigDecimal transformation", new BigDecimal("3000.15"), transformer.transform(new Argument(0, "3000.15"), BigDecimal.class, english)); + } +} diff --git a/cucumber-ant/.gitignore b/cucumber-ant/.gitignore new file mode 100644 index 0000000000..e2cd23009b --- /dev/null +++ b/cucumber-ant/.gitignore @@ -0,0 +1,3 @@ +/.settings +/.project +/.classpath diff --git a/groovy/.gitignore b/groovy/.gitignore new file mode 100644 index 0000000000..ebbbd5fe9d --- /dev/null +++ b/groovy/.gitignore @@ -0,0 +1,3 @@ +/.classpath +/.project +/.settings diff --git a/groovy/Rakefile b/groovy/Rakefile new file mode 100644 index 0000000000..bfa23a1ba5 --- /dev/null +++ b/groovy/Rakefile @@ -0,0 +1,17 @@ +require 'rubygems' +require 'gherkin/i18n' +require 'erb' + +task :default => ['generate:groovy'] + +namespace :generate do + desc 'Generate Groovy code' + task :groovy do + groovy = ERB.new(IO.read(File.dirname(__FILE__) + '/src/main/code_generator/I18n.groovy.erb'), nil, '-') + Gherkin::I18n.all.each do |i18n| + File.open(File.dirname(__FILE__) + "/src/main/java/cucumber/runtime/groovy/#{i18n.underscored_iso_code.upcase}.java", 'wb') do |io| + io.write(groovy.result(binding)) + end + end + end +end diff --git a/core/src/main/code_generator/I18n.groovy.erb b/groovy/src/main/code_generator/I18n.groovy.erb similarity index 58% rename from core/src/main/code_generator/I18n.groovy.erb rename to groovy/src/main/code_generator/I18n.groovy.erb index e6ad839826..a50a68c607 100644 --- a/core/src/main/code_generator/I18n.groovy.erb +++ b/groovy/src/main/code_generator/I18n.groovy.erb @@ -1,12 +1,15 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; +import java.util.Locale; import java.util.regex.Pattern; public class <%= i18n.underscored_iso_code.upcase %> { + private final static Locale locale = Utils.localeFor("<%= i18n.iso_code %>"); <% i18n.code_keywords.each do |kw| -%> public static void <%= kw %>(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } <% end -%> diff --git a/groovy/src/main/java/cucumber/runtime/groovy/AR.java b/groovy/src/main/java/cucumber/runtime/groovy/AR.java index 5b79e6b750..9b116830ab 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/AR.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/AR.java @@ -1,36 +1,38 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class AR { + private final static Locale locale = Utils.localeFor("ar"); public static void بفرض(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void متى(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void عندما(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void اذاً(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void ثم(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void و(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void لكن(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/BG.java b/groovy/src/main/java/cucumber/runtime/groovy/BG.java index 766d521857..e0ea130474 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/BG.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/BG.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class BG { + private final static Locale locale = Utils.localeFor("bg"); public static void Дадено(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Когато(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void То(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void И(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Но(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/CA.java b/groovy/src/main/java/cucumber/runtime/groovy/CA.java index c7d03070e5..f9f4afc854 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/CA.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/CA.java @@ -1,44 +1,46 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class CA { + private final static Locale locale = Utils.localeFor("ca"); public static void Donat(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Donada(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Atès(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Atesa(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Quan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Aleshores(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Cal(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void I(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Però(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/CS.java b/groovy/src/main/java/cucumber/runtime/groovy/CS.java index e7a2b8360e..5cecb56f02 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/CS.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/CS.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class CS { + private final static Locale locale = Utils.localeFor("cs"); public static void Pokud(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Když(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Pak(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void A(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ataké(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ale(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/CY_GB.java b/groovy/src/main/java/cucumber/runtime/groovy/CY_GB.java index bb3b87e429..236814e875 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/CY_GB.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/CY_GB.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class CY_GB { + private final static Locale locale = Utils.localeFor("cy-GB"); public static void Anrhegediga(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Pryd(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Yna(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void A(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ond(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/DA.java b/groovy/src/main/java/cucumber/runtime/groovy/DA.java index c6eebd9222..fc45535fd2 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/DA.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/DA.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class DA { + private final static Locale locale = Utils.localeFor("da"); public static void Givet(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Når(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Så(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Og(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Men(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/DE.java b/groovy/src/main/java/cucumber/runtime/groovy/DE.java index 6012b1a332..567e0be623 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/DE.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/DE.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class DE { + private final static Locale locale = Utils.localeFor("de"); public static void Angenommen(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Gegebensei(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Wenn(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Dann(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Und(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Aber(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN.java b/groovy/src/main/java/cucumber/runtime/groovy/EN.java index 1adcd17544..1e1e2d871e 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN { + private final static Locale locale = Utils.localeFor("en"); public static void Given(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void When(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Then(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void And(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void But(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN_AU.java b/groovy/src/main/java/cucumber/runtime/groovy/EN_AU.java index 6bbf2b18b6..0d17e0c66d 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN_AU.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN_AU.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN_AU { + private final static Locale locale = Utils.localeFor("en-au"); public static void Yaknowhow(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void When(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Yagotta(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void N(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Cept(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN_LOL.java b/groovy/src/main/java/cucumber/runtime/groovy/EN_LOL.java index ed5aeb7ae4..1d71f0b2d8 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN_LOL.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN_LOL.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN_LOL { + private final static Locale locale = Utils.localeFor("en-lol"); public static void ICANHAZ(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void WEN(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void DEN(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void AN(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void BUT(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN_PIRATE.java b/groovy/src/main/java/cucumber/runtime/groovy/EN_PIRATE.java index 2495bee235..802edabfb8 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN_PIRATE.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN_PIRATE.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN_PIRATE { + private final static Locale locale = Utils.localeFor("en-pirate"); public static void Gangway(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Blimey(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Letgoandhaul(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Aye(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Avast(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN_SCOUSE.java b/groovy/src/main/java/cucumber/runtime/groovy/EN_SCOUSE.java index b934914799..86acc862d6 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN_SCOUSE.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN_SCOUSE.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN_SCOUSE { + private final static Locale locale = Utils.localeFor("en-Scouse"); public static void Givun(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Youseknowwhenyousegot(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Wun(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Youseknowlikewhen(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Dun(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Denyousegotta(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void An(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Buh(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EN_TX.java b/groovy/src/main/java/cucumber/runtime/groovy/EN_TX.java index f458ea4cc7..35c13c5a1e 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EN_TX.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EN_TX.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EN_TX { + private final static Locale locale = Utils.localeFor("en-tx"); public static void Givenyall(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Whenyall(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Thenyall(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Andyall(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Butyall(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/EO.java b/groovy/src/main/java/cucumber/runtime/groovy/EO.java index bcd6e9c298..487b95c09c 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/EO.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/EO.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class EO { + private final static Locale locale = Utils.localeFor("eo"); public static void Donitaĵo(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Se(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Do(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kaj(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Sed(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/ES.java b/groovy/src/main/java/cucumber/runtime/groovy/ES.java index 0e6ed7449f..f2b3cab737 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/ES.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/ES.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class ES { + private final static Locale locale = Utils.localeFor("es"); public static void Dado(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Cuando(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Entonces(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Y(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Pero(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/ET.java b/groovy/src/main/java/cucumber/runtime/groovy/ET.java index 8e302c2a17..5ba573a981 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/ET.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/ET.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class ET { + private final static Locale locale = Utils.localeFor("et"); public static void Eeldades(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kui(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Siis(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ja(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kuid(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/FI.java b/groovy/src/main/java/cucumber/runtime/groovy/FI.java index d285d68c67..afc3decc7f 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/FI.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/FI.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class FI { + private final static Locale locale = Utils.localeFor("fi"); public static void Oletetaan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kun(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Niin(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ja(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Mutta(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/FR.java b/groovy/src/main/java/cucumber/runtime/groovy/FR.java index 1784dbb97f..f17f923066 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/FR.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/FR.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class FR { + private final static Locale locale = Utils.localeFor("fr"); public static void Soit(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Etantdonné(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Quand(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Lorsque(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Lorsqu(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Alors(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Et(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Mais(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java b/groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java index b00b301c1d..b07c514dc5 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java @@ -1,11 +1,5 @@ package cucumber.runtime.groovy; -import cucumber.classpath.Classpath; -import cucumber.classpath.Consumer; -import cucumber.classpath.Input; -import cucumber.runtime.Backend; -import cucumber.runtime.CucumberException; -import cucumber.runtime.StepDefinition; import gherkin.formatter.model.Step; import groovy.lang.Binding; import groovy.lang.Closure; @@ -14,8 +8,16 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; +import cucumber.classpath.Classpath; +import cucumber.classpath.Consumer; +import cucumber.classpath.Input; +import cucumber.runtime.Backend; +import cucumber.runtime.CucumberException; +import cucumber.runtime.StepDefinition; + public class GroovyBackend implements Backend { private static GroovyBackend instance; @@ -56,8 +58,8 @@ public String getSnippet(Step step) { return new GroovySnippetGenerator(step).getSnippet(); } - public static void addStepDefinition(Pattern regexp, Closure body) { - instance.stepDefinitions.add(new GroovyStepDefinition(regexp, body, stepDefLocation(), instance)); + public static void addStepDefinition(Pattern regexp, Closure body, Locale locale) { + instance.stepDefinitions.add(new GroovyStepDefinition(regexp, body, stepDefLocation(), instance, locale)); } public static void registerWorld(Closure closure) { diff --git a/groovy/src/main/java/cucumber/runtime/groovy/GroovyStepDefinition.java b/groovy/src/main/java/cucumber/runtime/groovy/GroovyStepDefinition.java index 025b42d048..49ae1e1422 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/GroovyStepDefinition.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/GroovyStepDefinition.java @@ -1,21 +1,24 @@ package cucumber.runtime.groovy; -import cucumber.runtime.JdkPatternArgumentMatcher; -import cucumber.runtime.StepDefinition; import gherkin.formatter.Argument; import gherkin.formatter.model.Step; import groovy.lang.Closure; import java.util.List; +import java.util.Locale; import java.util.regex.Pattern; -public class GroovyStepDefinition implements StepDefinition { +import cucumber.runtime.AbstractStepDefinition; +import cucumber.runtime.JdkPatternArgumentMatcher; + +public class GroovyStepDefinition extends AbstractStepDefinition { private final JdkPatternArgumentMatcher argumentMatcher; private final Closure body; private final StackTraceElement location; private GroovyBackend backend; - public GroovyStepDefinition(Pattern pattern, Closure body, StackTraceElement location, GroovyBackend backend) { + public GroovyStepDefinition(Pattern pattern, Closure body, StackTraceElement location, GroovyBackend backend, Locale locale) { + super(locale); this.backend = backend; this.argumentMatcher = new JdkPatternArgumentMatcher(pattern); this.body = body; diff --git a/groovy/src/main/java/cucumber/runtime/groovy/HE.java b/groovy/src/main/java/cucumber/runtime/groovy/HE.java index e5364c77fe..21902b8394 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/HE.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/HE.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class HE { + private final static Locale locale = Utils.localeFor("he"); public static void בהינתן(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void כאשר(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void אז(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void אזי(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void וגם(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void אבל(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/HR.java b/groovy/src/main/java/cucumber/runtime/groovy/HR.java index 900659af5f..35c7cd2904 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/HR.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/HR.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class HR { + private final static Locale locale = Utils.localeFor("hr"); public static void Zadan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Zadani(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Zadano(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kada(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kad(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Onda(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void I(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ali(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/HU.java b/groovy/src/main/java/cucumber/runtime/groovy/HU.java index 8cad99bd5a..3aab61977c 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/HU.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/HU.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class HU { + private final static Locale locale = Utils.localeFor("hu"); public static void Amennyiben(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Adott(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Majd(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ha(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Amikor(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Akkor(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void És(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void De(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/ID.java b/groovy/src/main/java/cucumber/runtime/groovy/ID.java index faeaa6b7cc..070b40ca98 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/ID.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/ID.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class ID { + private final static Locale locale = Utils.localeFor("id"); public static void Dengan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ketika(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Maka(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Dan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Tapi(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/IT.java b/groovy/src/main/java/cucumber/runtime/groovy/IT.java index 4052f4e7ba..667cc6e41f 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/IT.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/IT.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class IT { + private final static Locale locale = Utils.localeFor("it"); public static void Dato(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Quando(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Allora(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void E(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ma(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/JA.java b/groovy/src/main/java/cucumber/runtime/groovy/JA.java index 2ddb3fdfaa..cc622595d5 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/JA.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/JA.java @@ -1,36 +1,38 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class JA { + private final static Locale locale = Utils.localeFor("ja"); public static void 前提(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void もし(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void ならば(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void かつ(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void しかし(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 但し(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void ただし(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/KO.java b/groovy/src/main/java/cucumber/runtime/groovy/KO.java index 6d5e64dfef..28acbcbb77 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/KO.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/KO.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class KO { + private final static Locale locale = Utils.localeFor("ko"); public static void 조건(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 먼저(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 만일(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 만약(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 그러면(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 그리고(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 하지만(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 단(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/LT.java b/groovy/src/main/java/cucumber/runtime/groovy/LT.java index c5ec32d0aa..ece85a1ae8 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/LT.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/LT.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class LT { + private final static Locale locale = Utils.localeFor("lt"); public static void Duota(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kai(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Tada(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ir(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Bet(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/LU.java b/groovy/src/main/java/cucumber/runtime/groovy/LU.java index 4f0ec92837..b42458c89f 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/LU.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/LU.java @@ -1,36 +1,38 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class LU { + private final static Locale locale = Utils.localeFor("lu"); public static void ugeholl(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void wann(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void dann(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void an(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void a(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void awer(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void mä(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/LV.java b/groovy/src/main/java/cucumber/runtime/groovy/LV.java index cde881e56b..5bc813517d 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/LV.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/LV.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class LV { + private final static Locale locale = Utils.localeFor("lv"); public static void Kad(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ja(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Tad(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Un(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Bet(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/NL.java b/groovy/src/main/java/cucumber/runtime/groovy/NL.java index b0346d4906..a71d0b9e12 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/NL.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/NL.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class NL { + private final static Locale locale = Utils.localeFor("nl"); public static void Gegeven(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Stel(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Als(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Dan(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void En(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Maar(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/NO.java b/groovy/src/main/java/cucumber/runtime/groovy/NO.java index a69c757431..2042d5f921 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/NO.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/NO.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class NO { + private final static Locale locale = Utils.localeFor("no"); public static void Gitt(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Når(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Så(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Og(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Men(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/PL.java b/groovy/src/main/java/cucumber/runtime/groovy/PL.java index eeed4c2158..7b75a3b397 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/PL.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/PL.java @@ -1,28 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class PL { + private final static Locale locale = Utils.localeFor("pl"); public static void Zakładając(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Mając(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Jeżeli(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Jeśli(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Wtedy(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Oraz(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void I(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ale(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/PT.java b/groovy/src/main/java/cucumber/runtime/groovy/PT.java index 85941a1dea..0511aeefef 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/PT.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/PT.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class PT { + private final static Locale locale = Utils.localeFor("pt"); public static void Dado(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Quando(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Então(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Entao(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void E(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Mas(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/RO.java b/groovy/src/main/java/cucumber/runtime/groovy/RO.java index 9e15b617e8..ab3dd3d5cc 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/RO.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/RO.java @@ -1,28 +1,58 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class RO { - public static void Daca(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + private final static Locale locale = Utils.localeFor("ro"); + public static void Datefiind(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Datfiind(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Datifiind(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Dațifiind(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Daţifiind(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Cand(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Când(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Atunci(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Si(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Și(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); + } + + public static void Şi(Pattern regexp, Closure body) throws Throwable { + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Dar(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/RO_RO.java b/groovy/src/main/java/cucumber/runtime/groovy/RO_RO.java deleted file mode 100644 index 710187447a..0000000000 --- a/groovy/src/main/java/cucumber/runtime/groovy/RO_RO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cucumber.runtime.groovy; - -import groovy.lang.Closure; - -import java.util.regex.Pattern; - -public class RO_RO { - public static void Dacă(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); - } - - public static void Când(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); - } - - public static void Atunci(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); - } - - public static void Și(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); - } - - public static void Dar(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); - } - -} diff --git a/groovy/src/main/java/cucumber/runtime/groovy/RU.java b/groovy/src/main/java/cucumber/runtime/groovy/RU.java index ca07c75f3f..e3f055f8cf 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/RU.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/RU.java @@ -1,52 +1,54 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class RU { + private final static Locale locale = Utils.localeFor("ru"); public static void Допустим(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Дано(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Пусть(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Если(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Когда(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void То(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Тогда(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void И(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ктомуже(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Но(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void А(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/SK.java b/groovy/src/main/java/cucumber/runtime/groovy/SK.java index 6e6bd39745..ece24d8c72 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/SK.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/SK.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class SK { + private final static Locale locale = Utils.localeFor("sk"); public static void Pokiaľ(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Keď(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Tak(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void A(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ale(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/SR_CYRL.java b/groovy/src/main/java/cucumber/runtime/groovy/SR_CYRL.java index 3572de2b03..6effb5302d 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/SR_CYRL.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/SR_CYRL.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class SR_CYRL { + private final static Locale locale = Utils.localeFor("sr-Cyrl"); public static void Задато(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Задате(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Задати(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Када(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Кад(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Онда(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void И(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Али(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/SR_LATN.java b/groovy/src/main/java/cucumber/runtime/groovy/SR_LATN.java index 1038b3605d..a194860cf4 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/SR_LATN.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/SR_LATN.java @@ -1,40 +1,42 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class SR_LATN { + private final static Locale locale = Utils.localeFor("sr-Latn"); public static void Zadato(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Zadate(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Zatati(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kada(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Kad(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Onda(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void I(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ali(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/SV.java b/groovy/src/main/java/cucumber/runtime/groovy/SV.java index 11ea754efc..dd9c608c7b 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/SV.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/SV.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class SV { + private final static Locale locale = Utils.localeFor("sv"); public static void Givet(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void När(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Så(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Och(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Men(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/TR.java b/groovy/src/main/java/cucumber/runtime/groovy/TR.java index 4fac4f98af..e46525b5cb 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/TR.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/TR.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class TR { + private final static Locale locale = Utils.localeFor("tr"); public static void Diyelimki(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Eğerki(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ozaman(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ve(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Fakat(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ama(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/UK.java b/groovy/src/main/java/cucumber/runtime/groovy/UK.java index bae2647435..485e5089d3 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/UK.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/UK.java @@ -1,56 +1,58 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class UK { + private final static Locale locale = Utils.localeFor("uk"); public static void Припустимо(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Припустимощо(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Нехай(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Дано(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Якщо(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Коли(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void То(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Тоді(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void І(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Атакож(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Та(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Але(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/UZ.java b/groovy/src/main/java/cucumber/runtime/groovy/UZ.java index d6b0392025..6a129a4b07 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/UZ.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/UZ.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class UZ { + private final static Locale locale = Utils.localeFor("uz"); public static void Агар(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Унда(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Ва(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Лекин(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Бирок(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Аммо(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/VI.java b/groovy/src/main/java/cucumber/runtime/groovy/VI.java index 3eb8316682..14f6389fdc 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/VI.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/VI.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class VI { + private final static Locale locale = Utils.localeFor("vi"); public static void Biết(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Cho(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Khi(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Thì(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Và(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void Nhưng(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/ZH_CN.java b/groovy/src/main/java/cucumber/runtime/groovy/ZH_CN.java index 4f2e379859..99ab575aab 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/ZH_CN.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/ZH_CN.java @@ -1,28 +1,30 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class ZH_CN { + private final static Locale locale = Utils.localeFor("zh-CN"); public static void 假如(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 当(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 那么(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 而且(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 但是(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/groovy/src/main/java/cucumber/runtime/groovy/ZH_TW.java b/groovy/src/main/java/cucumber/runtime/groovy/ZH_TW.java index 2d6bd715ec..8f59b98523 100644 --- a/groovy/src/main/java/cucumber/runtime/groovy/ZH_TW.java +++ b/groovy/src/main/java/cucumber/runtime/groovy/ZH_TW.java @@ -1,32 +1,34 @@ package cucumber.runtime.groovy; +import cuke4duke.internal.Utils; import groovy.lang.Closure; - +import java.util.Locale; import java.util.regex.Pattern; public class ZH_TW { + private final static Locale locale = Utils.localeFor("zh-TW"); public static void 假設(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 當(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 那麼(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 而且(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 並且(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } public static void 但是(Pattern regexp, Closure body) throws Throwable { - GroovyBackend.addStepDefinition(regexp, body); + GroovyBackend.addStepDefinition(regexp, body, locale); } } diff --git a/guice/.gitignore b/guice/.gitignore new file mode 100644 index 0000000000..b75532f04d --- /dev/null +++ b/guice/.gitignore @@ -0,0 +1,3 @@ +/.project +/.settings +/.classpath diff --git a/ioke/.gitignore b/ioke/.gitignore new file mode 100644 index 0000000000..e2cd23009b --- /dev/null +++ b/ioke/.gitignore @@ -0,0 +1,3 @@ +/.settings +/.project +/.classpath diff --git a/ioke/src/main/java/cucumber/runtime/ioke/IokeBackend.java b/ioke/src/main/java/cucumber/runtime/ioke/IokeBackend.java index c1b679a843..4d6c206d7e 100644 --- a/ioke/src/main/java/cucumber/runtime/ioke/IokeBackend.java +++ b/ioke/src/main/java/cucumber/runtime/ioke/IokeBackend.java @@ -1,12 +1,5 @@ package cucumber.runtime.ioke; -import cucumber.Table; -import cucumber.classpath.Classpath; -import cucumber.classpath.Consumer; -import cucumber.classpath.Input; -import cucumber.runtime.Backend; -import cucumber.runtime.CucumberException; -import cucumber.runtime.StepDefinition; import gherkin.formatter.model.Step; import ioke.lang.IokeObject; import ioke.lang.Message; @@ -16,6 +9,15 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; + +import cucumber.Table; +import cucumber.classpath.Classpath; +import cucumber.classpath.Consumer; +import cucumber.classpath.Input; +import cucumber.runtime.Backend; +import cucumber.runtime.CucumberException; +import cucumber.runtime.StepDefinition; public class IokeBackend implements Backend { private final Runtime ioke; @@ -50,8 +52,8 @@ public void consume(Input input) { } } - public void addStepDefinition(Object iokeStepDefObject) throws Throwable { - stepDefinitions.add(new IokeStepDefinition(this, ioke, (IokeObject) iokeStepDefObject, currentLocation)); + public void addStepDefinition(Object iokeStepDefObject, Locale locale) throws Throwable { + stepDefinitions.add(new IokeStepDefinition(this, ioke, (IokeObject) iokeStepDefObject, currentLocation, locale)); } public List getStepDefinitions() { diff --git a/ioke/src/main/java/cucumber/runtime/ioke/IokeStepDefinition.java b/ioke/src/main/java/cucumber/runtime/ioke/IokeStepDefinition.java index 91b6aa1320..656f416f9c 100644 --- a/ioke/src/main/java/cucumber/runtime/ioke/IokeStepDefinition.java +++ b/ioke/src/main/java/cucumber/runtime/ioke/IokeStepDefinition.java @@ -1,7 +1,5 @@ package cucumber.runtime.ioke; -import cucumber.runtime.CucumberException; -import cucumber.runtime.StepDefinition; import gherkin.formatter.Argument; import gherkin.formatter.model.Step; import ioke.lang.IokeObject; @@ -9,14 +7,19 @@ import ioke.lang.exceptions.ControlFlow; import java.util.List; +import java.util.Locale; + +import cucumber.runtime.AbstractStepDefinition; +import cucumber.runtime.CucumberException; -public class IokeStepDefinition implements StepDefinition { +public class IokeStepDefinition extends AbstractStepDefinition { private final Runtime ioke; private final IokeObject iokeStepDefObject; private final IokeBackend backend; private final String location; - public IokeStepDefinition(IokeBackend iokeBackend, Runtime ioke, IokeObject iokeStepDefObject, String location) throws Throwable { + public IokeStepDefinition(IokeBackend iokeBackend, Runtime ioke, IokeObject iokeStepDefObject, String location, Locale locale) throws Throwable { + super(locale); this.ioke = ioke; this.iokeStepDefObject = iokeStepDefObject; this.backend = iokeBackend; diff --git a/java/.gitignore b/java/.gitignore new file mode 100644 index 0000000000..5e68373517 --- /dev/null +++ b/java/.gitignore @@ -0,0 +1,3 @@ +/.settings +/.classpath +/.project diff --git a/java/src/main/java/cucumber/runtime/java/ClasspathMethodScanner.java b/java/src/main/java/cucumber/runtime/java/ClasspathMethodScanner.java index bd90ff58a6..426a8f5d7e 100644 --- a/java/src/main/java/cucumber/runtime/java/ClasspathMethodScanner.java +++ b/java/src/main/java/cucumber/runtime/java/ClasspathMethodScanner.java @@ -49,7 +49,7 @@ private void scan(Method method, Collection> cucumbe if (isHookAnnotation(annotation)) { // TODO Add hook } - + //TODO: scan cucumber.annotation.Transform annotations Locale locale = Utils.localeFor(annotation.annotationType().getAnnotation(CucumberAnnotation.class).value()); try { Method regexpMethod = annotation.getClass().getMethod("value"); diff --git a/java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java b/java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java index 5b91c23762..0b9b75e02c 100644 --- a/java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java +++ b/java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java @@ -1,8 +1,6 @@ package cucumber.runtime.java; -import cucumber.runtime.CucumberException; -import cucumber.runtime.JdkPatternArgumentMatcher; -import cucumber.runtime.StepDefinition; +import static java.util.Arrays.asList; import gherkin.formatter.Argument; import gherkin.formatter.model.Step; @@ -11,21 +9,22 @@ import java.util.Locale; import java.util.regex.Pattern; -import static java.util.Arrays.asList; +import cucumber.runtime.AbstractStepDefinition; +import cucumber.runtime.CucumberException; +import cucumber.runtime.JdkPatternArgumentMatcher; -public class JavaStepDefinition implements StepDefinition { +public class JavaStepDefinition extends AbstractStepDefinition { private final MethodFormat methodFormat; private final Method method; private final ObjectFactory objectFactory; private final JdkPatternArgumentMatcher argumentMatcher; - private final Locale locale; // TODO: Use to convert arguments before executions (float etc.) Maybe pass it to execute instead (taking it from the locale of feature instead). public JavaStepDefinition(Pattern pattern, Method method, ObjectFactory objectFactory, Locale locale) { - this.argumentMatcher = new JdkPatternArgumentMatcher(pattern); + super(locale); + this.argumentMatcher = new JdkPatternArgumentMatcher(pattern); this.method = method; this.objectFactory = objectFactory; this.methodFormat = new MethodFormat(); - this.locale = locale; } public void execute(Object[] args) throws Throwable { diff --git a/picocontainer/.gitignore b/picocontainer/.gitignore new file mode 100644 index 0000000000..e2cd23009b --- /dev/null +++ b/picocontainer/.gitignore @@ -0,0 +1,3 @@ +/.settings +/.project +/.classpath diff --git a/pom.xml b/pom.xml index 469f025983..5e0de63bc0 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 2.4.1 + 2.4.2 3.3 1.7 1.5.3 diff --git a/rhino/.gitignore b/rhino/.gitignore new file mode 100644 index 0000000000..b75532f04d --- /dev/null +++ b/rhino/.gitignore @@ -0,0 +1,3 @@ +/.project +/.settings +/.classpath diff --git a/rhino/src/main/java/cucumber/runtime/rhino/RhinoBackend.java b/rhino/src/main/java/cucumber/runtime/rhino/RhinoBackend.java index 8b71e4381e..4a8b1d096f 100644 --- a/rhino/src/main/java/cucumber/runtime/rhino/RhinoBackend.java +++ b/rhino/src/main/java/cucumber/runtime/rhino/RhinoBackend.java @@ -1,20 +1,25 @@ package cucumber.runtime.rhino; -import cucumber.classpath.Classpath; -import cucumber.classpath.Consumer; -import cucumber.classpath.Input; -import cucumber.runtime.*; -import cucumber.runtime.javascript.JavascriptSnippetGenerator; import gherkin.formatter.model.Step; -import org.mozilla.javascript.Context; -import org.mozilla.javascript.NativeFunction; -import org.mozilla.javascript.Scriptable; -import org.mozilla.javascript.tools.shell.Global; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; +import java.util.Locale; + +import org.mozilla.javascript.Context; +import org.mozilla.javascript.NativeFunction; +import org.mozilla.javascript.Scriptable; +import org.mozilla.javascript.tools.shell.Global; + +import cucumber.classpath.Classpath; +import cucumber.classpath.Consumer; +import cucumber.classpath.Input; +import cucumber.runtime.Backend; +import cucumber.runtime.CucumberException; +import cucumber.runtime.StepDefinition; +import cucumber.runtime.javascript.JavascriptSnippetGenerator; public class RhinoBackend implements Backend { private static final String JS_DSL = "/cucumber/runtime/rhino/dsl.js"; @@ -78,9 +83,9 @@ private StackTraceElement stepDefLocation(String extension) { throw new RuntimeException("Couldn't find location for step definition"); } - public void addStepDefinition(Global jsStepDefinition, NativeFunction bodyFunc, NativeFunction argumentsFromFunc) throws Throwable { + public void addStepDefinition(Global jsStepDefinition, NativeFunction bodyFunc, NativeFunction argumentsFromFunc, Locale locale) throws Throwable { StackTraceElement stepDefLocation = stepDefLocation(".js"); - RhinoStepDefinition stepDefinition = new RhinoStepDefinition(cx, scope, jsStepDefinition, bodyFunc, stepDefLocation, argumentsFromFunc); + RhinoStepDefinition stepDefinition = new RhinoStepDefinition(cx, scope, jsStepDefinition, bodyFunc, stepDefLocation, argumentsFromFunc, locale); stepDefinitions.add(stepDefinition); } } diff --git a/rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java b/rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java index 58ab5355fa..466ef98252 100644 --- a/rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java +++ b/rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java @@ -1,17 +1,20 @@ package cucumber.runtime.rhino; -import cucumber.runtime.StepDefinition; import gherkin.formatter.Argument; import gherkin.formatter.model.Step; + +import java.util.List; +import java.util.Locale; + import org.mozilla.javascript.Context; import org.mozilla.javascript.NativeFunction; import org.mozilla.javascript.NativeJavaObject; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.tools.shell.Global; -import java.util.List; +import cucumber.runtime.AbstractStepDefinition; -public class RhinoStepDefinition implements StepDefinition { +public class RhinoStepDefinition extends AbstractStepDefinition { private final Context cx; private final Scriptable scope; private final Global jsStepDefinition; @@ -19,8 +22,9 @@ public class RhinoStepDefinition implements StepDefinition { private final StackTraceElement location; private final NativeFunction argumentsFromFunc; - public RhinoStepDefinition(Context cx, Scriptable scope, Global jsStepDefinition, NativeFunction bodyFunc, StackTraceElement location, NativeFunction argumentsFromFunc) { - this.cx = cx; + public RhinoStepDefinition(Context cx, Scriptable scope, Global jsStepDefinition, NativeFunction bodyFunc, StackTraceElement location, NativeFunction argumentsFromFunc, Locale locale) { + super(locale); + this.cx = cx; this.scope = scope; this.jsStepDefinition = jsStepDefinition; this.bodyFunc = bodyFunc; diff --git a/spring/.gitignore b/spring/.gitignore new file mode 100644 index 0000000000..e2cd23009b --- /dev/null +++ b/spring/.gitignore @@ -0,0 +1,3 @@ +/.settings +/.project +/.classpath