From f48166db83466047027052b4b81791256c98e37d Mon Sep 17 00:00:00 2001 From: anoordover Date: Thu, 12 Mar 2015 14:29:14 +0100 Subject: [PATCH 1/3] #1: support for dutch --- .gitignore | 3 +- .../groovy/nl/BasicVariableStepsNL.groovy | 46 +++++++ .../java/nl/BasicVariableStepsNL.java | 53 ++++++++ .../cucumber/variables/nl/DutchDecoder.java | 42 +++++++ .../java/nl/BasicVariableStepsSpec.groovy | 102 +++++++++++++++ .../variables/nl/DutchDecoderSpec.groovy | 119 ++++++++++++++++++ gradle-app.setting | 26 ++++ integration-tests/groovy_nl/build.gradle | 19 +++ .../cucumber/features/TestVariablesNL.feature | 36 ++++++ .../groovy_nl/src/cucumber/resources/.gitkeep | 0 .../variables/groovy/nl/TestingStepsNL.groovy | 61 +++++++++ integration-tests/java_nl/build.gradle | 19 +++ .../cucumber/features/TestVariables.feature | 28 +++++ .../java_nl/src/cucumber/resources/.gitkeep | 0 .../variables/java/nl/TestingSteps.java | 62 +++++++++ settings.gradle | 3 +- 16 files changed, 617 insertions(+), 2 deletions(-) create mode 100644 core/src/main/groovy/io/jdev/cucumber/variables/groovy/nl/BasicVariableStepsNL.groovy create mode 100644 core/src/main/java/io/jdev/cucumber/variables/java/nl/BasicVariableStepsNL.java create mode 100644 core/src/main/java/io/jdev/cucumber/variables/nl/DutchDecoder.java create mode 100644 core/src/test/groovy/io/jdev/cucumber/variables/java/nl/BasicVariableStepsSpec.groovy create mode 100644 core/src/test/groovy/io/jdev/cucumber/variables/nl/DutchDecoderSpec.groovy create mode 100644 gradle-app.setting create mode 100644 integration-tests/groovy_nl/build.gradle create mode 100644 integration-tests/groovy_nl/src/cucumber/features/TestVariablesNL.feature create mode 100644 integration-tests/groovy_nl/src/cucumber/resources/.gitkeep create mode 100644 integration-tests/groovy_nl/src/test/groovy/io/jdev/cucumber/variables/groovy/nl/TestingStepsNL.groovy create mode 100644 integration-tests/java_nl/build.gradle create mode 100644 integration-tests/java_nl/src/cucumber/features/TestVariables.feature create mode 100644 integration-tests/java_nl/src/cucumber/resources/.gitkeep create mode 100644 integration-tests/java_nl/src/test/java/io/jdev/cucumber/variables/java/nl/TestingSteps.java diff --git a/.gitignore b/.gitignore index 02c43f9..2659dff 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ out/ .settings/ .classpath .project -.gradle \ No newline at end of file +.gradle +.idea diff --git a/core/src/main/groovy/io/jdev/cucumber/variables/groovy/nl/BasicVariableStepsNL.groovy b/core/src/main/groovy/io/jdev/cucumber/variables/groovy/nl/BasicVariableStepsNL.groovy new file mode 100644 index 0000000..3dcff38 --- /dev/null +++ b/core/src/main/groovy/io/jdev/cucumber/variables/groovy/nl/BasicVariableStepsNL.groovy @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.groovy.nl +import cucumber.api.Scenario +import io.jdev.cucumber.variables.core.BasicSteps +import io.jdev.cucumber.variables.nl.DutchDecoder + +import static cucumber.api.groovy.EN.Given +import static cucumber.api.groovy.Hooks.After +import static cucumber.api.groovy.Hooks.Before + +def steps = new BasicSteps() + +Before() { Scenario scenario -> + steps.before(scenario, new DutchDecoder()) +} + +After() { Scenario scenario -> + steps.after(scenario) +} + +Given(~/^de (.*) is gevuld met (.*)$/) { String name, String value -> + steps.setVariable(name, steps.getVariable(value)); +} diff --git a/core/src/main/java/io/jdev/cucumber/variables/java/nl/BasicVariableStepsNL.java b/core/src/main/java/io/jdev/cucumber/variables/java/nl/BasicVariableStepsNL.java new file mode 100644 index 0000000..92ebebb --- /dev/null +++ b/core/src/main/java/io/jdev/cucumber/variables/java/nl/BasicVariableStepsNL.java @@ -0,0 +1,53 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.java.nl; + +import cucumber.api.Scenario; +import cucumber.api.java.After; +import cucumber.api.java.Before; +import cucumber.api.java.nl.Gegeven; +import io.jdev.cucumber.variables.core.BasicSteps; +import io.jdev.cucumber.variables.nl.DutchDecoder; + +public class BasicVariableStepsNL { + + private BasicSteps steps = new BasicSteps(); + + @Before + public void before(Scenario scenario) { + steps.before(scenario, new DutchDecoder()); + } + + @After + public void after(Scenario scenario) { + steps.after(scenario); + } + + @Gegeven("^de (.*) is gevuld met (.*)$") + public void set(String name, String value) { + steps.setVariable(name, steps.getVariable(value)); + } + +} diff --git a/core/src/main/java/io/jdev/cucumber/variables/nl/DutchDecoder.java b/core/src/main/java/io/jdev/cucumber/variables/nl/DutchDecoder.java new file mode 100644 index 0000000..760e6ef --- /dev/null +++ b/core/src/main/java/io/jdev/cucumber/variables/nl/DutchDecoder.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.nl; + +import io.jdev.cucumber.variables.core.ChainedDecoder; +import io.jdev.cucumber.variables.core.RegexLiteralDecoder; +import io.jdev.cucumber.variables.core.RegexVariableDecoder; +import io.jdev.cucumber.variables.core.StringLiteralDecoder; + +public class DutchDecoder extends ChainedDecoder { + + public DutchDecoder() { + super( + new RegexVariableDecoder("de(?: (\\d+)(?:ste|de))? (.*)", 2, 1), + new StringLiteralDecoder(), + new RegexLiteralDecoder() + ); + } + +} diff --git a/core/src/test/groovy/io/jdev/cucumber/variables/java/nl/BasicVariableStepsSpec.groovy b/core/src/test/groovy/io/jdev/cucumber/variables/java/nl/BasicVariableStepsSpec.groovy new file mode 100644 index 0000000..8a4ddda --- /dev/null +++ b/core/src/test/groovy/io/jdev/cucumber/variables/java/nl/BasicVariableStepsSpec.groovy @@ -0,0 +1,102 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.java.nl + +import cucumber.api.Scenario +import io.jdev.cucumber.variables.VariableScope +import io.jdev.cucumber.variables.nl.DutchDecoder +import spock.lang.Specification + +class BasicVariableStepsSpec extends Specification { + + BasicVariableStepsNL steps + Scenario scenario + Scenario previousScenario + + void setup() { + steps = new BasicVariableStepsNL() + scenario = Mock(Scenario) + previousScenario = Mock(Scenario) + } + + void cleanup() { + VariableScope.removeCurrentScope() + } + + void "before step should set up variable scope when none present"() { + given: 'no current scope attached to thread' + VariableScope.removeCurrentScope() + + when: 'call before method' + steps.before(scenario) + + then: 'scope created and attached to given scenario' + def scope = VariableScope.currentScope + scope != null + scope.scenario == scenario + } + + void "before step should replace variable scope when one already present"() { + given: 'existing scope attached to thread' + def previousScope = VariableScope.getCurrentScope(previousScenario, new DutchDecoder()) + previousScope.storeVariable("dog name", 'Mork') + + when: 'call before method' + steps.before(scenario) + + then: 'scope has replaced previous one on the thread' + def scope = VariableScope.currentScope + scope != null + scope.scenario == scenario + + // ok it's more of an integration test + and: 'does not have previously set variable' + scope.decodeVariable('de dog name') == null + + when: 'set a variable' + scope.storeVariable("dog name", 'Mindy') + + then: 'decodes as expected' + scope.decodeVariable('de dog name') == 'Mindy' + scope.decodeVariable('de 1ste dog name') == 'Mindy' + + and: 'previous scope unchanged' + previousScope.decodeVariable('de 1ste dog name') == 'Mork' + previousScope.decodeVariable('de dog name') == 'Mork' + } + + void "set step should set variable"() { + given: 'current scope attached to thread' + steps.before(scenario) + + when: 'call set method' + def val = 'blah' + steps.set('foo', "'$val'") + + then: 'scope has given variable' + VariableScope.currentScope.decodeVariable('de foo') == val + } + +} diff --git a/core/src/test/groovy/io/jdev/cucumber/variables/nl/DutchDecoderSpec.groovy b/core/src/test/groovy/io/jdev/cucumber/variables/nl/DutchDecoderSpec.groovy new file mode 100644 index 0000000..ef2880c --- /dev/null +++ b/core/src/test/groovy/io/jdev/cucumber/variables/nl/DutchDecoderSpec.groovy @@ -0,0 +1,119 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.nl +import io.jdev.cucumber.variables.core.VariableSet +import spock.lang.Specification +import spock.lang.Unroll +/** + * This is basically an integration test for DutchDecoder and RegexVariableDecoder + */ +public class DutchDecoderSpec extends Specification { + + DutchDecoder decoder + VariableSet vars + + void setup() { + decoder = new DutchDecoder(); + vars = Mock(VariableSet) + } + + void "decodes single present variable correctly"() { + given: 'val' + def val = 1234L + + when: + def result = decoder.decode(vars, "de very long variable name") + + then: + vars.getVariable('very long variable name') >> [val] + + and: + result == val + } + + @Unroll + void "missing variable returns null"() { + when: + def result = decoder.decode(vars, "de very long variable name") + + then: + vars.getVariable('very long variable name') >> varVal + + and: + result == null + + where: + varVal << [null, []] + } + + void "decodes last present variable when no index given"() { + given: 'val' + def vals = [1234L, 'asdf', 'qwerty'] + + when: + def result = decoder.decode(vars, "de very long variable name") + + then: + vars.getVariable('very long variable name') >> vals + + and: + result == vals.last() + } + + void "decodes first present variable correctly"() { + given: 'val' + def vals = [1234L, 'asdf'] + + when: + def result = decoder.decode(vars, "de 1ste very long variable name") + + then: + vars.getVariable('very long variable name') >> vals + + and: + result == vals[0] + } + + @Unroll + void "decodes #time present variable correctly"() { + given: 'val' + def vals = [1234L, 'asdf'] + + when: + def result = decoder.decode(vars, "de $time very long variable name") + + then: + vars.getVariable('very long variable name') >> vals + + and: + result == vals[expectedIndex] + + where: + time | expectedIndex + '1ste' | 0 + '2de' | 1 + } + +} \ No newline at end of file diff --git a/gradle-app.setting b/gradle-app.setting new file mode 100644 index 0000000..1b2fd28 --- /dev/null +++ b/gradle-app.setting @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/integration-tests/groovy_nl/build.gradle b/integration-tests/groovy_nl/build.gradle new file mode 100644 index 0000000..ab1401e --- /dev/null +++ b/integration-tests/groovy_nl/build.gradle @@ -0,0 +1,19 @@ +apply plugin: 'com.github.samueltbrown.cucumber' + +dependencies { + testCompile "org.codehaus.groovy:groovy-all:$groovyVersion" + testCompile 'junit:junit-dep:4.10' + testCompile "info.cukes:cucumber-core:$cucumberJvmVersion" + testCompile "info.cukes:cucumber-groovy:$cucumberJvmVersion" + testCompile project(':core') +} + +cucumber { + formats = ['asyougo'] + glueDirs = ['classpath:io.jdev.cucumber.variables.groovy.nl'] + featureDirs = [file('src/cucumber/features').path] + strict = true +} + +check.dependsOn cucumber + diff --git a/integration-tests/groovy_nl/src/cucumber/features/TestVariablesNL.feature b/integration-tests/groovy_nl/src/cucumber/features/TestVariablesNL.feature new file mode 100644 index 0000000..0f2ee34 --- /dev/null +++ b/integration-tests/groovy_nl/src/cucumber/features/TestVariablesNL.feature @@ -0,0 +1,36 @@ +#language: nl +Functionaliteit: Test Variabelen + + @Dutch + Scenario: Test Enkelvoudige Variabele + Gegeven de hondennaam is gevuld met 'Max' + Dan heeft de hondennaam variabele waarde 'Max' + Dan heeft de hondennaam variabele de waarde 'Max' + Dan heeft de hondennaam variabele de waarde /\w{3}/ + Dan heeft de hondennaam variabele de waarde van de hondennaam + + @Dutch + Scenario: Test Meervoudgie Variabelen + Gegeven de hondennaam is gevuld met 'Max' + En de hondennaam is gevuld met 'Kensington' + Dan heeft de hondennaam variabele waarde 'Kensington' + En heeft de 1ste hondennaam variabele waarde 'Max' + En heeft de 2de hondennaam variabele waarde 'Kensington' + En heeft de 2de hondennaam variabele waarde /Kens.*/ + + @Dutch + Abstract Scenario: Test Variabelen With Voorbeelden + Gegeven de kattennaam is gevuld met + Dan heeft de kattennaam variabele waarde + Voorbeelden: + | cat_name | + | 'Piccadilly' | + | 'Blah' | + + @Dutch + Scenario: Test Geneste Variabeles + Gegeven de kat is een map met waarden: + | naam | Piccadilly | + | staartKleur | White | + Dan heeft de kat naam variabele waarde 'Piccadilly' + En heeft de kat staart kleur variabele waarde 'White' diff --git a/integration-tests/groovy_nl/src/cucumber/resources/.gitkeep b/integration-tests/groovy_nl/src/cucumber/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/integration-tests/groovy_nl/src/test/groovy/io/jdev/cucumber/variables/groovy/nl/TestingStepsNL.groovy b/integration-tests/groovy_nl/src/test/groovy/io/jdev/cucumber/variables/groovy/nl/TestingStepsNL.groovy new file mode 100644 index 0000000..afd3222 --- /dev/null +++ b/integration-tests/groovy_nl/src/test/groovy/io/jdev/cucumber/variables/groovy/nl/TestingStepsNL.groovy @@ -0,0 +1,61 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.groovy.nl +import cucumber.api.DataTable +import cucumber.api.Scenario +import io.jdev.cucumber.variables.core.BasicSteps +import io.jdev.cucumber.variables.nl.DutchDecoder +import org.junit.Assert + +import java.util.regex.Pattern + +import static cucumber.api.groovy.Hooks.After +import static cucumber.api.groovy.Hooks.Before +import static cucumber.api.groovy.NL.Dan +import static cucumber.api.groovy.NL.Gegeven + +def steps = new BasicSteps() + +Before("@Dutch") { Scenario scenario -> + steps.before(scenario, new DutchDecoder()) +} + +After("@Dutch") { Scenario scenario -> + steps.after(scenario) +} + +Dan(~/^heeft (de .*) variabele (?:de )?waarde (?:van )?(.*)$/) { String name, String rawValue -> + Object expectedValue = steps.getVariable(rawValue) + String actualValue = steps.getVariable(name) + if(expectedValue instanceof Pattern) { + Assert.assertTrue(((Pattern) expectedValue).matcher(actualValue).matches()) + } else { + Assert.assertEquals(expectedValue, actualValue) + } +} + +Gegeven(~/^de (.*) is een map met waarden:$/) { String name, DataTable dataTable -> + steps.setVariable(name, dataTable.asMap(String, String)) +} \ No newline at end of file diff --git a/integration-tests/java_nl/build.gradle b/integration-tests/java_nl/build.gradle new file mode 100644 index 0000000..3de75fa --- /dev/null +++ b/integration-tests/java_nl/build.gradle @@ -0,0 +1,19 @@ +apply plugin: 'com.github.samueltbrown.cucumber' + +dependencies { + testCompile 'junit:junit-dep:4.10' + testCompile "info.cukes:cucumber-core:$cucumberJvmVersion" + testCompile "info.cukes:cucumber-java:$cucumberJvmVersion" + testCompile project(':core') +} + +cucumber { + formats = ['asyougo'] + glueDirs = ['classpath:io.jdev.cucumber.variables.java.nl'] + featureDirs = [file('src/cucumber/features').path] + strict = true +} + +check.dependsOn cucumber +cucumber.shouldRunAfter test + diff --git a/integration-tests/java_nl/src/cucumber/features/TestVariables.feature b/integration-tests/java_nl/src/cucumber/features/TestVariables.feature new file mode 100644 index 0000000..8c698ff --- /dev/null +++ b/integration-tests/java_nl/src/cucumber/features/TestVariables.feature @@ -0,0 +1,28 @@ +#language: nl +Functionaliteit: Test Variabelen + + @Dutch + Scenario: Test Enkelvoudige Variabele + Gegeven de hondennaam is gevuld met 'Max' + Dan heeft de hondennaam variabele waarde 'Max' + Dan heeft de hondennaam variabele de waarde 'Max' + Dan heeft de hondennaam variabele de waarde /\w{3}/ + Dan heeft de hondennaam variabele de waarde van de hondennaam + + @Dutch + Scenario: Test Meervoudgie Variabelen + Gegeven de hondennaam is gevuld met 'Max' + En de hondennaam is gevuld met 'Kensington' + Dan heeft de hondennaam variabele waarde 'Kensington' + En heeft de 1ste hondennaam variabele waarde 'Max' + En heeft de 2de hondennaam variabele waarde 'Kensington' + En heeft de 2de hondennaam variabele waarde /Kens.*/ + + @Dutch + Abstract Scenario: Test Variabelen With Voorbeelden + Gegeven de kattennaam is gevuld met + Dan heeft de kattennaam variabele waarde + Voorbeelden: + | cat_name | + | 'Piccadilly' | + | 'Blah' | diff --git a/integration-tests/java_nl/src/cucumber/resources/.gitkeep b/integration-tests/java_nl/src/cucumber/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/integration-tests/java_nl/src/test/java/io/jdev/cucumber/variables/java/nl/TestingSteps.java b/integration-tests/java_nl/src/test/java/io/jdev/cucumber/variables/java/nl/TestingSteps.java new file mode 100644 index 0000000..204995b --- /dev/null +++ b/integration-tests/java_nl/src/test/java/io/jdev/cucumber/variables/java/nl/TestingSteps.java @@ -0,0 +1,62 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 the original author or authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package io.jdev.cucumber.variables.java.nl; + +import cucumber.api.Scenario; +import cucumber.api.java.After; +import cucumber.api.java.Before; +import cucumber.api.java.nl.Dan; +import io.jdev.cucumber.variables.core.BasicSteps; +import io.jdev.cucumber.variables.nl.DutchDecoder; +import org.junit.Assert; + +import java.util.regex.Pattern; + +public class TestingSteps extends BasicSteps { + + BasicSteps steps = new BasicSteps(); + + @Before + public void before(Scenario scenario) { + steps.before(scenario, new DutchDecoder()); + } + + @After + public void after(Scenario scenario) { + steps.after(scenario); + } + + @Dan("^heeft (de .*) variabele (?:de )?waarde (?:van )?(.*)$") + public void assertValue(String name, String rawValue) { + Object expectedValue = steps.getVariable(rawValue); + String actualValue = (String) steps.getVariable(name); + if(expectedValue instanceof Pattern) { + Assert.assertTrue(((Pattern) expectedValue).matcher(actualValue).matches()); + } else { + Assert.assertEquals(expectedValue, actualValue); + } + } + +} diff --git a/settings.gradle b/settings.gradle index 945ef08..e605a66 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ -include 'core', 'integration-tests:java', 'integration-tests:groovy' \ No newline at end of file +include 'core', 'integration-tests:java', 'integration-tests:groovy', + 'integration-tests:java_nl','integration-tests:groovy_nl' \ No newline at end of file From 177bab44be7e34b0a99423fbb6713c0869162232 Mon Sep 17 00:00:00 2001 From: Arno Noordover Date: Fri, 6 Nov 2015 20:13:05 +0100 Subject: [PATCH 2/3] #1: support for dutch --- build.gradle | 12 ++++++++---- core/build.gradle | 8 ++++---- core/gradle.properties | 1 + gradle.properties | 1 + integration-tests/gradle.properties | 1 + integration-tests/groovy/gradle.properties | 1 + integration-tests/groovy_nl/gradle.properties | 1 + integration-tests/java/gradle.properties | 1 + integration-tests/java_nl/gradle.properties | 1 + 9 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 core/gradle.properties create mode 100644 gradle.properties create mode 100644 integration-tests/gradle.properties create mode 100644 integration-tests/groovy/gradle.properties create mode 100644 integration-tests/groovy_nl/gradle.properties create mode 100644 integration-tests/java/gradle.properties create mode 100644 integration-tests/java_nl/gradle.properties diff --git a/build.gradle b/build.gradle index 4f80c3d..64e6bd1 100644 --- a/build.gradle +++ b/build.gradle @@ -22,12 +22,13 @@ buildscript { repositories { - mavenCentral() - maven { url 'http://repo.springsource.org/plugins-release' } + mavenLocal() + maven { url 'http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/groups/public' } } dependencies { classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' classpath 'com.github.samueltbrown:gradle-cucumber-plugin:0.7' + classpath 'net.researchgate:gradle-release:2.0.2' } } @@ -37,7 +38,7 @@ subprojects { apply plugin: 'propdeps' repositories { - mavenCentral() + maven { url 'http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/groups/public' } } sourceCompatibility = 1.6 @@ -50,9 +51,11 @@ allprojects { apply plugin: 'eclipse' apply plugin: 'propdeps-idea' apply plugin: 'propdeps-eclipse' + apply plugin: 'maven' + apply plugin: 'net.researchgate.release' group = 'io.jdev.cucumber' - version = '0.5' + version = '0.6-SNAPSHOT' ext { cucumberJvmVersion = "1.1.8" @@ -97,3 +100,4 @@ allprojects { } } } + diff --git a/core/build.gradle b/core/build.gradle index a84cb03..4fb272d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -52,11 +52,11 @@ uploadArchives { task -> uniqueVersion = false gradle.taskGraph.whenReady { taskGraph -> if (taskGraph.hasTask(task)) { - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: sonatypeOssUsername, password: sonatypeOssPassword) + repository(url: "http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/repositories/releases/") { + authentication(userName: "deployment", password: "h0o4c2h5d8") } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: sonatypeOssUsername, password: sonatypeOssPassword) + snapshotRepository(url: "http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/repositories/snapshots/") { + authentication(userName: "deployment", password: "h0o4c2h5d8") } } } diff --git a/core/gradle.properties b/core/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/core/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/integration-tests/gradle.properties b/integration-tests/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/integration-tests/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/integration-tests/groovy/gradle.properties b/integration-tests/groovy/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/integration-tests/groovy/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/integration-tests/groovy_nl/gradle.properties b/integration-tests/groovy_nl/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/integration-tests/groovy_nl/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/integration-tests/java/gradle.properties b/integration-tests/java/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/integration-tests/java/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file diff --git a/integration-tests/java_nl/gradle.properties b/integration-tests/java_nl/gradle.properties new file mode 100644 index 0000000..dbd7b44 --- /dev/null +++ b/integration-tests/java_nl/gradle.properties @@ -0,0 +1 @@ +version=0.6-SNAPSHOT \ No newline at end of file From eb9dc87cd49e6ddab8f63b14eb633d67b274896b Mon Sep 17 00:00:00 2001 From: Arno Noordover Date: Fri, 6 Nov 2015 20:44:18 +0100 Subject: [PATCH 3/3] #1: support for dutch (removed own repo) --- build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 64e6bd1..64715fc 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,8 @@ buildscript { repositories { mavenLocal() - maven { url 'http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/groups/public' } + mavenCentral() + maven { url 'http://repo.spring.io/plugins-release' } } dependencies { classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' @@ -38,7 +39,9 @@ subprojects { apply plugin: 'propdeps' repositories { - maven { url 'http://sldka.cak-bz.local:8080/nexus-webapp-1.8.0/content/groups/public' } + mavenLocal() + mavenCentral() + maven { url 'http://repo.spring.io/plugins-release' } } sourceCompatibility = 1.6