You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/31 02:36:16 UTC

svn commit: r1379238 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Author: sebb
Date: Fri Aug 31 00:36:15 2012
New Revision: 1379238

URL: http://svn.apache.org/viewvc?rev=1379238&view=rev
Log:
Add tests to show current backslash behaviour
Bugzilla Id: 53534

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=1379238&r1=1379237&r2=1379238&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 Fri Aug 31 00:36:15 2012
@@ -83,6 +83,37 @@ public class TestValueReplacer extends J
             assertEquals("jakarta.apache.org", element.getPropertyAsString("domain"));
         }
 
+        public void testReplaceStringWithBackslash() throws Exception {
+            ValueReplacer replacer = new ValueReplacer();
+            replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
+            TestElement element = new ConfigTestElement();
+            String input = "\\${server} \\ \\\\ \\\\\\ \\, ";
+            element.setProperty(new StringProperty("domain", input));
+            replacer.replaceValues(element);
+            //log.debug("domain property = " + element.getProperty("domain"));
+            element.setRunningVersion(true);
+            assertEquals(input, element.getPropertyAsString("domain"));
+        }
+
+        /*
+         * This test should be compared with the one above.
+         * Here, the string contains a valid variable reference, so all
+         * backslashes are also processed.
+         * 
+         * See https://issues.apache.org/bugzilla/show_bug.cgi?id=53534
+         */
+        public void testReplaceFunctionWithBackslash() throws Exception {
+            ValueReplacer replacer = new ValueReplacer();
+            replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
+            TestElement element = new ConfigTestElement();
+            String input = "${server} \\ \\\\ \\\\\\ \\, ";
+            element.setProperty(new StringProperty("domain", input));
+            replacer.replaceValues(element);
+            //log.debug("domain property = " + element.getProperty("domain"));
+            element.setRunningVersion(true);
+            assertEquals("jakarta.apache.org \\ \\ \\\\ , ", element.getPropertyAsString("domain"));
+        }
+
         /** {@inheritDoc} */
         @Override
         protected void tearDown() throws Exception {