jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1749194 - in /jmeter/trunk: src/jorphan/org/apache/jorphan/reflect/ src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/ test/src/org/apache/jmeter/functions/ test/src/org/apache/jmeter/resources/ test/src/org/apache/jmeter/te...
Date Sun, 19 Jun 2016 19:26:52 GMT
Author: fschumacher
Date: Sun Jun 19 19:26:52 2016
New Revision: 1749194

URL: http://svn.apache.org/viewvc?rev=1749194&view=rev
Log:
Use contains instead of indexOf to make intent of logic clearer.
Correct a spelling error of local variable toke to token.
Patch by Graham Russell. Part of github pr #174.

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
    jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
    jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java
    jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/reflect/ClassFinder.java Sun Jun 19 19:26:52
2016
@@ -81,22 +81,21 @@ public final class ClassFinder {
 
         @Override
         public boolean accept(String className) {
-            
-            if (contains!=null && className.indexOf(contains) == -1){
+
+            if (contains != null && !className.contains(contains)) {
                 return false; // It does not contain a required string
             }
-            if (notContains!=null && className.indexOf(notContains) != -1){
+            if (notContains != null && className.contains(notContains)) {
                 return false; // It contains a banned string
             }
-            if ((className.indexOf('$') == -1) || inner) { // $NON-NLS-1$
-                if (isChildOf(parents,className, contextClassLoader)) {
+            if (!className.contains("$") || inner) { // $NON-NLS-1$
+                if (isChildOf(parents, className, contextClassLoader)) {
                     return true;
                 }
             }
             return false;
         }
     }
-
     
     private static class AnnoClassFilter implements ClassFilter {
         
@@ -113,7 +112,7 @@ public final class ClassFinder {
         
         @Override
         public boolean accept(String className) {
-            if ((className.indexOf('$') == -1) || inner) { // $NON-NLS-1$
+            if (!className.contains("$") || inner) { // $NON-NLS-1$
                 if (hasAnnotationOnMethod(annotations,className, contextClassLoader)) {
                     return true;
                 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/LogFilter.java
Sun Jun 19 19:26:52 2016
@@ -122,7 +122,7 @@ public class LogFilter implements Filter
     public void setReplaceExtension(String oldext, String newext) {
         if (oldext != null && newext != null) {
             this.CHANGEEXT = true;
-            if (oldext.indexOf('.') < 0 && newext.indexOf('.') < 0) {
+            if (!oldext.contains(".") && !newext.contains(".")) {
                 this.OLDEXT = "." + oldext;
                 this.NEWEXT = "." + newext;
             } else {

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
Sun Jun 19 19:26:52 2016
@@ -358,23 +358,18 @@ public class TCLogParser implements LogP
      */
     public String cleanURL(String entry) {
         String url = entry;
-        // if the string contains atleast one double
-        // quote and checkMethod is true, go ahead
-        // and tokenize the string.
-        if (entry.indexOf('"') > -1 && checkMethod(entry)) {
-            StringTokenizer tokens = null;
+        if (entry.contains("\"") && checkMethod(entry)) {
             // we tokenize using double quotes. this means
             // for tomcat we should have 3 tokens if there
             // isn't any additional information in the logs
-            tokens = this.tokenize(entry, "\"");
+            StringTokenizer tokens = this.tokenize(entry, "\"");
             while (tokens.hasMoreTokens()) {
-                String toke = tokens.nextToken();
-                // if checkMethod on the token is true
-                // we tokenzie it using space and escape
-                // the while loop. Only the first matching
-                // token will be used
-                if (checkMethod(toke)) {
-                    StringTokenizer token2 = this.tokenize(toke, " ");
+                String token = tokens.nextToken();
+                if (checkMethod(token)) {
+                    // we tokenzie it using space and escape
+                    // the while loop. Only the first matching
+                    // token will be used
+                    StringTokenizer token2 = this.tokenize(token, " ");
                     while (token2.hasMoreTokens()) {
                         String t = (String) token2.nextElement();
                         if (t.equalsIgnoreCase(GET)) {
@@ -432,7 +427,7 @@ public class TCLogParser implements LogP
      * @return String presenting the parameters, or <code>null</code> when none
where found
      */
     public String stripFile(String url, TestElement el) {
-        if (url.indexOf('?') > -1) {
+        if (url.contains("?")) {
             StringTokenizer tokens = this.tokenize(url, "?");
             this.URL_PATH = tokens.nextToken();
             el.setProperty(HTTPSamplerBase.PATH, URL_PATH);
@@ -451,10 +446,7 @@ public class TCLogParser implements LogP
      *         <code>false</code> otherwise
      */
     public boolean checkURL(String url) {
-        if (url.indexOf('?') > -1) {
-            return true;
-        }
-        return false;
+        return url.contains("?");
     }
 
     /**
@@ -466,10 +458,7 @@ public class TCLogParser implements LogP
      *         and <code>=</code>, <code>false</code> otherwise
      */
     public boolean checkParamFormat(String text) {
-        if (text.indexOf('&') > -1 && text.indexOf('=') > -1) {
-            return true;
-        }
-        return false;
+        return text.contains("&") && text.contains("=");
     }
 
     /**

Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
Sun Jun 19 19:26:52 2016
@@ -133,10 +133,9 @@ public class ComponentReferenceFunctionT
             if (ct) {
                 funcTitles.put(title, Boolean.TRUE);// For detecting extra entries
             }
-            if (// Is this a work in progress ?
-            title.indexOf("(ALPHA") == -1 && title.indexOf("(EXPERIMENTAL") == -1)
{// No, not a
-                                                                                    // work
in progress
-                                                                                    // ...
+            // Is this a work in progress ?
+            if (!title.contains("(ALPHA") && !title.contains("(EXPERIMENTAL")) {
+                // No, not a work in progress ...
                 String s = "function.xml needs '" + title + "' entry for " + funcItem.getClass().getName();
                 if (!ct) {
                     LOG.warn(s); // Record in log as well

Modified: jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java Sun Jun 19 19:26:52
2016
@@ -123,7 +123,7 @@ public class PackageTest extends TestCas
                          * JMeterUtils.getResString() converts space to _ and lowercases
                          * the key, so make sure all keys pass the test
                          */
-                        if ((key.indexOf(' ') >= 0) || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key))
{
+                        if (key.contains(" ") || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key))
{
                             System.out.println("Invalid key for JMeterUtils " + key);
                             fails++;
                         }
@@ -136,9 +136,9 @@ public class PackageTest extends TestCas
                      * parameters and check if there is a { in the output. A bit
                      * crude, but should be enough for now.
                      */
-                    if (val.indexOf("{0}") > 0 && val.indexOf('\'') > 0) {
+                    if (val.contains("{0}") && val.contains("'")) {
                         String m = java.text.MessageFormat.format(val, DUMMY_PARAMS);
-                        if (m.indexOf('{') > 0) {
+                        if (m.contains("{")) {
                             fails++;
                             System.out.println("Incorrect message format ? (input/output)
for: "+key);
                             System.out.println(val);

Modified: jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java?rev=1749194&r1=1749193&r2=1749194&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java Sun Jun 19 19:26:52
2016
@@ -128,7 +128,7 @@ public final class PackageTest extends J
         String dn = defaultBundle.getString("displayName").toUpperCase(Locale.ENGLISH);
 
         // Skip the rest of this test for alpha/experimental beans:
-        if (dn.indexOf("(ALPHA") != -1 || dn.indexOf("(EXPERIMENTAL") != -1) {
+        if (dn.contains("(ALPHA") || dn.contains("(EXPERIMENTAL")) {
             return;
         }
 



Mime
View raw message