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 2019/09/29 10:17:10 UTC

[jmeter] branch master updated (a1d8517 -> c9fb919)

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git.


    from a1d8517  Generate url String in one go
     new 5eb8495  Use string format in log messages
     new c9fb919  Extract common code blocks into private methods

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/jmeter/util/BeanShellTestElement.java   | 70 +++++++---------------
 1 file changed, 21 insertions(+), 49 deletions(-)


[jmeter] 02/02: Extract common code blocks into private methods

Posted by fs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit c9fb919cc48be23847183360e070925a0bcc7c35
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Sep 29 12:14:22 2019 +0200

    Extract common code blocks into private methods
---
 .../apache/jmeter/util/BeanShellTestElement.java   | 60 ++++++----------------
 1 file changed, 16 insertions(+), 44 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java b/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
index 76c97f9..93da10b 100644
--- a/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
+++ b/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
@@ -177,67 +177,40 @@ public abstract class BeanShellTestElement extends AbstractTestElement
 
     @Override
     public void threadStarted() {
-        if (bshInterpreter == null || !hasInitFile) {
-            return;
-        }
-        try {
-            bshInterpreter.evalNoLog("threadStarted()"); // $NON-NLS-1$
-        } catch (JMeterException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
-            }
-        }
+        tryEvalNoLog("threadStarted()"); // $NON-NLS-1$
     }
 
     @Override
     public void threadFinished() {
-        if (bshInterpreter == null || !hasInitFile) {
-            return;
-        }
-        try {
-            bshInterpreter.evalNoLog("threadFinished()"); // $NON-NLS-1$
-        } catch (JMeterException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
-            }
-        }
+        tryEvalNoLog("threadFinished()"); // $NON-NLS-1$
     }
 
     @Override
     public void testEnded() {
-        if (bshInterpreter == null || !hasInitFile) {
-            return;
-        }
-        try {
-            bshInterpreter.evalNoLog("testEnded()"); // $NON-NLS-1$
-        } catch (JMeterException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
-            }
-        }
+        tryEvalNoLog("testEnded()"); // $NON-NLS-1$
     }
 
     @Override
     public void testEnded(String host) {
-        if (bshInterpreter == null || !hasInitFile) {
-            return;
-        }
-        try {
-            bshInterpreter.eval("testEnded(\"" + host + "\")");
-        } catch (JMeterException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
-            }
-        }
+        tryEval("testEnded(\"" + host + "\")"); // $NON-NLS-1$
     }
 
     @Override
     public void testStarted() {
+        tryEvalNoLog("testStarted()");// $NON-NLS-1$
+    }
+
+    @Override
+    public void testStarted(String host) {
+        tryEval("testStarted(\"" + host + "\")"); // $NON-NLS-1$
+    }
+
+    private void tryEval(String code) {
         if (bshInterpreter == null || !hasInitFile) {
             return;
         }
         try {
-            bshInterpreter.evalNoLog("testStarted()"); // $NON-NLS-1$
+            bshInterpreter.eval(code);
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
                 log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
@@ -245,13 +218,12 @@ public abstract class BeanShellTestElement extends AbstractTestElement
         }
     }
 
-    @Override
-    public void testStarted(String host) {
+    private void tryEvalNoLog(String code) {
         if (bshInterpreter == null || !hasInitFile) {
             return;
         }
         try {
-            bshInterpreter.eval("testStarted(\"" + host + "\")");
+            bshInterpreter.evalNoLog(code);
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
                 log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$


[jmeter] 01/02: Use string format in log messages

Posted by fs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 5eb8495e5fa77925950c39f6057e9454ad8b67ef
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Sep 29 12:00:04 2019 +0200

    Use string format in log messages
---
 .../org/apache/jmeter/util/BeanShellTestElement.java   | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java b/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
index c681710..76c97f9 100644
--- a/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
+++ b/src/core/src/main/java/org/apache/jmeter/util/BeanShellTestElement.java
@@ -78,7 +78,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             try {
                 bshInterpreter.reset();
             } catch (ClassNotFoundException e) {
-                log.error("Cannot reset BeanShell: "+e.toString());
+                log.error("Cannot reset BeanShell: {}", e.toString());
             }
         }
 
@@ -92,7 +92,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.set("props", JMeterUtils.getJMeterProperties());
             bshInterpreter.set("vars", vars);//$NON-NLS-1$
         } catch (JMeterException e) {
-            log.warn("Problem setting one or more BeanShell variables "+e);
+            log.warn("Problem setting one or more BeanShell variables {}", e.toString());
         }
         return bshInterpreter;
     }
@@ -106,7 +106,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             hasInitFile = initFileName != null;
             bshInterpreter = new BeanShellInterpreter(initFileName, log);
         } catch (ClassNotFoundException e) {
-            log.error("Cannot find BeanShell: "+e.toString());
+            log.error("Cannot find BeanShell: {}", e.toString());
         }
     }
 
@@ -184,7 +184,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.evalNoLog("threadStarted()"); // $NON-NLS-1$
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }
@@ -198,7 +198,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.evalNoLog("threadFinished()"); // $NON-NLS-1$
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }
@@ -212,7 +212,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.evalNoLog("testEnded()"); // $NON-NLS-1$
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }
@@ -226,7 +226,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.eval("testEnded(\"" + host + "\")");
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }
@@ -240,7 +240,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.evalNoLog("testStarted()"); // $NON-NLS-1$
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }
@@ -254,7 +254,7 @@ public abstract class BeanShellTestElement extends AbstractTestElement
             bshInterpreter.eval("testStarted(\"" + host + "\")");
         } catch (JMeterException e) {
             if (log.isDebugEnabled()) {
-                log.debug(getClass().getName() + " : " + e.getLocalizedMessage()); // $NON-NLS-1$
+                log.debug("{} : {}", getClass().getName(), e.getLocalizedMessage()); // $NON-NLS-1$
             }
         }
     }