[jbehave-scm] [scm-core][1/1] JBEHAVE-1062: Now using Matcher.quoteReplacement() when replacing the named parameter values
commit 09e5180a8e28b5490ee4d0bb962a61519c673075 Author: rszabi ruginaszabo...@gmail.com AuthorDate: Fri, 19 Dec 2014 14:04:32 +0200 Commit: Mauro Talevi mauro.tal...@aquilonia.org CommitDate: Sat, 20 Dec 2014 17:24:02 +0100 JBEHAVE-1062: Now using Matcher.quoteReplacement() when replacing the named parameter values diff --git a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java index 598416a..d15551e 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java +++ b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java @@ -336,7 +336,7 @@ public class ExamplesTable { String replacedValue = row.get(key); for (String namedKey : namedParameters.keySet()) { String namedValue = namedParameters.get(namedKey); -replacedValue = replacedValue.replaceAll(namedKey, namedValue); +replacedValue = replacedValue.replaceAll(namedKey, Matcher.quoteReplacement(namedValue)); } replaced.put(key, replacedValue); } diff --git a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java index 1e6fcb2..b0bdcf3 100755 --- a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java +++ b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java @@ -333,6 +333,30 @@ public class ExamplesTableBehaviour { } +/** + * The values given named parameter values as strings should not suffer any modification after are replaced in table. + * @see {@link String#replaceAll(String, String)} to see why are not present in values the '\' and '$' characters. + */ +@Test +public void shouldKeepExactValueInReplacedNamedParameterValues() throws Exception { +// Given +ExamplesTableFactory factory = new ExamplesTableFactory(); +String problematicNamedParameterValueCharacters = value having the \\ backslash and the $ dollar character; + +// When +String tableAsString = |Name|Value|\n|name|value|; +MapString, String namedParameters = new HashMapString, String(); +namedParameters.put(value, problematicNamedParameterValueCharacters); +ExamplesTable table = factory.createExamplesTable(tableAsString).withNamedParameters(namedParameters); + +// Then +Parameters firstRow = table.getRowsAsParameters(true).get(0); +MapString, String firstRowValues = firstRow.values(); +assertThat(firstRowValues.containsKey(Value), is(true)); +assertThat(firstRow.valueAs(Value, String.class), is(problematicNamedParameterValueCharacters)); + +} + @Test public void shouldMapParametersToType() throws Exception { // Given
[jbehave-scm] [scm-core/jbehave-4.x][1/1] JBEHAVE-1062: Now using Matcher.quoteReplacement() when replacing the named parameter values
commit f3d255f9a197da15ee7c5e51198938864c253b0b Author: rszabi ruginaszabo...@gmail.com AuthorDate: Fri, 19 Dec 2014 14:04:32 +0200 Commit: Mauro Talevi mauro.tal...@aquilonia.org CommitDate: Sat, 20 Dec 2014 17:28:02 +0100 JBEHAVE-1062: Now using Matcher.quoteReplacement() when replacing the named parameter values diff --git a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java index 5e4137a..32a656e 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java +++ b/jbehave-core/src/main/java/org/jbehave/core/model/ExamplesTable.java @@ -335,7 +335,7 @@ public class ExamplesTable { String replacedValue = row.get(key); for (String namedKey : namedParameters.keySet()) { String namedValue = namedParameters.get(namedKey); -replacedValue = replacedValue.replaceAll(namedKey, namedValue); +replacedValue = replacedValue.replaceAll(namedKey, Matcher.quoteReplacement(namedValue)); } replaced.put(key, replacedValue); } diff --git a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java index 1368119..1fe66e4 100755 --- a/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java +++ b/jbehave-core/src/test/java/org/jbehave/core/model/ExamplesTableBehaviour.java @@ -333,6 +333,30 @@ public class ExamplesTableBehaviour { } +/** + * The values given named parameter values as strings should not suffer any modification after are replaced in table. + * @see {@link String#replaceAll(String, String)} to see why are not present in values the '\' and '$' characters. + */ +@Test +public void shouldKeepExactValueInReplacedNamedParameterValues() throws Exception { +// Given +ExamplesTableFactory factory = new ExamplesTableFactory(); +String problematicNamedParameterValueCharacters = value having the \\ backslash and the $ dollar character; + +// When +String tableAsString = |Name|Value|\n|name|value|; +MapString, String namedParameters = new HashMapString, String(); +namedParameters.put(value, problematicNamedParameterValueCharacters); +ExamplesTable table = factory.createExamplesTable(tableAsString).withNamedParameters(namedParameters); + +// Then +Parameters firstRow = table.getRowsAsParameters(true).get(0); +MapString, String firstRowValues = firstRow.values(); +assertThat(firstRowValues.containsKey(Value), is(true)); +assertThat(firstRow.valueAs(Value, String.class), is(problematicNamedParameterValueCharacters)); + +} + @Test public void shouldMapParametersToType() throws Exception { // Given
[jbehave-dev] [jira] (JBEHAVE-1062) Named parameter values containing backslash and dollar characters cause side effects
Title: Message Title Mauro Talevi resolved an issue as Fixed Pulled with thanks! JBehave / JBEHAVE-1062 Named parameter values containing backslash and dollar characters cause side effects Change By: Mauro Talevi Resolution: Fixed Status: Open Resolved Add Comment This message was sent by Atlassian JIRA (v6.1.6#6162-sha1:7af547c) - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
[jbehave-dev] [jira] (JBEHAVE-1062) Named parameter values containing backslash and dollar characters cause side effects
Title: Message Title Mauro Talevi updated an issue JBehave / JBEHAVE-1062 Named parameter values containing backslash and dollar characters cause side effects Change By: Mauro Talevi Affects Version/s: 3.9.6 Affects Version/s: 3.x Add Comment This message was sent by Atlassian JIRA (v6.1.6#6162-sha1:7af547c) - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
[jbehave-dev] [jira] (JBEHAVE-979) Improve default report
Title: Message Title Mauro Talevi commented on an issue Re: Improve default report Hi, thanks for the contribution. It's been pulled and applied to both master and jbehave-4.x branches. A couple of minor further suggestions: do we need all the tablefilter*.js files or tablefilter_all_min.js? can we use lower capitalisation consistently? can we use white as the background color of the table header? Add Comment JBehave / JBEHAVE-979 Improve default report The current report suffers from lack of information. i'm working on a bit project and most of the people prefer the junit report provided on jenkins ci. i think that the default report should have more information regrading: * step failure - add full stacktrace and as much information as possible * step duration * filtering for the report table (ex... This message was sent by Atlassian JIRA (v6.1.6#6162-sha1:7af547c)
[jbehave-dev] [jira] (JBEHAVE-1061) @BeforeScenario runs for every steps file that are instanciated
Title: Message Title Mauro Talevi commented on an issue Re: @BeforeScenario runs for every steps file that are instanciated All the methods annotated with @BeforeScenario will run before each scenario, regardless of which steps file the are contained in. Can you provide a sample project reproducing your behaviour? Add Comment JBehave / JBEHAVE-1061 @BeforeScenario runs for every steps file that are instanciated When i run my scenario that are using multiple steps files, the method that are annotated with @BeforeScenario runs for each steps file. Im excpecting it to only run per scenario not per steps file This message was sent by Atlassian JIRA (v6.1.6#6162-sha1:7af547c) - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email