jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1611959 - in /jmeter/trunk: src/core/org/apache/jmeter/resources/ src/protocol/http/org/apache/jmeter/protocol/http/modifier/ src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/ test/src/org/apache/jmeter/protocol/http/modifier...
Date Sat, 19 Jul 2014 20:30:58 GMT
Author: pmouawad
Date: Sat Jul 19 20:30:58 2014
New Revision: 1611959

URL: http://svn.apache.org/r1611959
Log:
Bug 41319 - URLRewritingModifier : Allow Parameter value to be url encoded
Bugzilla Id: 41319

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Sat Jul 19 20:30:58
2014
@@ -260,6 +260,7 @@ edit=Edit
 email_results_title=Email Results
 en=English
 enable=Enable
+encode=URL Encode
 encode?=Encode?
 encoded_value=URL Encoded Value
 endtime=End Time  

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Sat Jul 19 20:30:58
2014
@@ -254,6 +254,7 @@ edit=Editer
 email_results_title=R\u00E9sultat d'email
 en=Anglais
 enable=Activer
+encode=URL Encoder
 encode?=Encodage
 encoded_value=Valeur de l'URL encod\u00E9e
 endtime=Date et heure de fin \:

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/URLRewritingModifier.java
Sat Jul 19 20:30:58 2014
@@ -63,6 +63,8 @@ public class URLRewritingModifier extend
 
     private static final String SHOULD_CACHE = "cache_value"; // $NON-NLS-1$
 
+    private static final String ENCODE = "encode"; // $NON-NLS-1$
+
     // PreProcessors are cloned per-thread, so this will be saved per-thread
     private transient String savedValue = ""; // $NON-NLS-1$
 
@@ -137,7 +139,7 @@ public class URLRewritingModifier extend
             }
         } else {
             sampler.getArguments().removeArgument(getArgumentName());
-            sampler.getArguments().addArgument(new HTTPArgument(getArgumentName(), value,
true));
+            sampler.getArguments().addArgument(new HTTPArgument(getArgumentName(), value,
!encode()));
         }
     }
 
@@ -225,4 +227,12 @@ public class URLRewritingModifier extend
         savedValue = "";
         return this;
     }
+
+    public boolean encode() {
+        return getPropertyAsBoolean(ENCODE, false);        
+    }
+    public void setEncode(boolean b) {
+        setProperty(new BooleanProperty(ENCODE, b));
+    }
+
 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java
Sat Jul 19 20:30:58 2014
@@ -42,6 +42,8 @@ public class URLRewritingModifierGui ext
 
     private JCheckBox shouldCache;
 
+    private JCheckBox encode;
+
     @Override
     public String getLabelResource() {
         return "http_url_rewriting_modifier_title"; // $NON-NLS-1$
@@ -75,6 +77,10 @@ public class URLRewritingModifierGui ext
         shouldCache.setSelected(true);
         mainPanel.add(shouldCache);
 
+        encode = new JCheckBox(JMeterUtils.getResString("encode")); // $NON-NLS-1$
+        encode.setSelected(false);
+        mainPanel.add(encode);
+
         add(mainPanel, BorderLayout.CENTER);
     }
 
@@ -102,6 +108,7 @@ public class URLRewritingModifierGui ext
         rewritingModifier.setPathExtensionNoEquals(pathExtNoEquals.isSelected());
         rewritingModifier.setPathExtensionNoQuestionmark(pathExtNoQuestionmark.isSelected());
         rewritingModifier.setShouldCache((shouldCache.isSelected()));
+        rewritingModifier.setEncode(encode.isSelected());
     }
 
     /**
@@ -116,6 +123,7 @@ public class URLRewritingModifierGui ext
         pathExtNoEquals.setSelected(false);
         pathExtNoQuestionmark.setSelected(false);
         shouldCache.setSelected(false);
+        encode.setSelected(false);
     }
 
     /**
@@ -129,7 +137,7 @@ public class URLRewritingModifierGui ext
         pathExtNoEquals.setSelected(rewritingModifier.isPathExtensionNoEquals());
         pathExtNoQuestionmark.setSelected(rewritingModifier.isPathExtensionNoQuestionmark());
         shouldCache.setSelected(rewritingModifier.shouldCache());
-
+        encode.setSelected(rewritingModifier.encode());
         super.configure(el);
     }
 }

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestURLRewritingModifier.java
Sat Jul 19 20:30:58 2014
@@ -106,6 +106,42 @@ public class TestURLRewritingModifier ex
             Arguments args = sampler.getArguments();
             assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
         }
+        
+        public void testGrabSessionId6() throws Exception {
+            String html = "location: http://server.com/index.html" + "?session_id=bonjour+monsieur";
+            response = new SampleResult();
+            response.setResponseData(html, null);
+            mod.setArgumentName("session_id");
+            HTTPSamplerBase sampler = createSampler();
+            sampler.addArgument("session_id", "adfasdfdsafasdfasd");
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            assertEquals("bonjour+monsieur", ((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+            assertEquals("http://server.com/index.html?" + "session_id=bonjour+monsieur",
sampler.toString());
+        }
+        
+        public void testGrabSessionId7() throws Exception {
+            String html = "location: http://server.com/index.html" + "?session_id=bonjour+monsieur";
+            response = new SampleResult();
+            response.setResponseData(html, null);
+            mod.setArgumentName("session_id");
+            mod.setEncode(true);
+            HTTPSamplerBase sampler = createSampler();
+            sampler.addArgument("session_id", "adfasdfdsafasdfasd");
+            context.setCurrentSampler(sampler);
+            context.setPreviousResult(response);
+            mod.process();
+            Arguments args = sampler.getArguments();
+            System.out.println(((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+            System.out.println(sampler.toString());
+            assertEquals("bonjour+monsieur", ((Argument) args.getArguments().get(0).getObjectValue())
+                    .getValue());
+            assertEquals("http://server.com/index.html?" + "session_id=bonjour%2Bmonsieur",
sampler.toString());
+        }
 
         public void testGrabSessionIdFromXMLNonPatExtension() throws Exception { // Bug 50286
             String html = "<url>/some/path;jsessionid=123456789</url>";

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Jul 19 20:30:58 2014
@@ -157,6 +157,7 @@ A workaround is to use a Java 7 update 4
 <ul>
 <li><bugzilla>56162</bugzilla> -  HTTP Cache Manager should not cache PUT/POST
etc.</li>
 <li><bugzilla>56227</bugzilla> - AssertionGUI : NPE in assertion on mouse
selection</li>
+<li><bugzilla>41319</bugzilla> - URLRewritingModifier : Allow Parameter
value to be url encoded</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1611959&r1=1611958&r2=1611959&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Jul 19 20:30:58 2014
@@ -4968,6 +4968,9 @@ Clever users will even determine that th
         <property name="Cache Session Id?" required="Yes">
         Should the value of the session Id be saved for later use when the session Id is
not present?
         </property>
+        <property name="URL Encode" required="No">
+        URL Encode value when writing parameter
+        </property>
 </properties>
 
 <note>



Mime
View raw message