You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/06/03 15:31:00 UTC
svn commit: r1797515 -
/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
Author: fschumacher
Date: Sat Jun 3 15:31:00 2017
New Revision: 1797515
URL: http://svn.apache.org/viewvc?rev=1797515&view=rev
Log:
Followup to r1793271. Make it clear, that partial matches have to be handled with parens.
Modified:
jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
Modified: jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java?rev=1797515&r1=1797514&r2=1797515&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java Sat Jun 3 15:31:00 2017
@@ -107,23 +107,35 @@ public class TestValueReplacer extends J
String replacedDomain = element.getPropertyAsString("domain");
assertEquals("${${shortMatch}", replacedDomain);
}
-
+
+ @Test
+ public void testPartialWordMatchesWithoutParens() throws Exception {
+ assertEquals("toto%40005", replaceWord("005", "toto%40005"));
+ }
+
+ @Test
+ public void testPartialWordMatchesWithParens() throws Exception {
+ assertEquals("toto%40${domainMatcher}", replaceWord("(005)", "toto%40005"));
+ }
+
@Test
- public void test2Matches() throws Exception {
+ public void testCompleteWordMatchesWithoutParens() throws Exception {
+ assertEquals("toto@${domainMatcher}", replaceWord("005", "toto@005"));
+ }
+
+ @Test
+ public void testCompleteWordMatchesWithParens() throws Exception {
+ assertEquals("toto@${domainMatcher}", replaceWord("(005)", "toto@005"));
+ }
+
+ private String replaceWord(String matchRegex, String testData) throws Exception {
TestPlan plan = new TestPlan();
- plan.addParameter("firstMatch", "toto");
- plan.addParameter("secondMatch", "005");
+ plan.addParameter("domainMatcher", matchRegex);
ValueReplacer replacer = new ValueReplacer(plan);
TestElement element = new TestPlan();
- element.setProperty(new StringProperty("mail", "toto%40005"));
- replacer.reverseReplace(element, true);
- String replacedDomain = element.getPropertyAsString("mail");
- assertEquals("${firstMatch}%40005", replacedDomain);
-
- element.setProperty(new StringProperty("mail", "toto@005"));
+ element.setProperty(new StringProperty("mail", testData));
replacer.reverseReplace(element, true);
- replacedDomain = element.getPropertyAsString("mail");
- assertEquals("${firstMatch}@${secondMatch}", replacedDomain);
+ return element.getPropertyAsString("mail");
}
@Test