jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] 06/12: changes based on feedback
Date Fri, 12 Mar 2021 16:21:00 GMT
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 f29000caf04e469c3e8951e1b299fb4641a049fe
Author: David Pecollet <david.pecollet@gmail.com>
AuthorDate: Tue Dec 15 22:40:03 2020 +0000

    changes based on feedback
    
    also removed time assertions that made some unit tests flaky
---
 .../protocol/bolt/sampler/AbstractBoltTestElement.java   | 10 +++++++---
 .../apache/jmeter/protocol/bolt/sampler/BoltSampler.java |  4 ++--
 .../bolt/sampler/BoltTestElementBeanInfoSupport.java     | 16 ++++++++--------
 .../bolt/sampler/BoltSamplerResources.properties         |  2 +-
 .../jmeter/protocol/bolt/sampler/BoltSamplerSpec.groovy  |  2 --
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
index 807b7ad..0ec9579 100644
--- a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
+++ b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
@@ -19,6 +19,8 @@ package org.apache.jmeter.protocol.bolt.sampler;
 
 import java.time.Duration;
 
+import org.apache.commons.lang3.EnumUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.testelement.AbstractTestElement;
 import org.neo4j.driver.AccessMode;
 import org.neo4j.driver.SessionConfig;
@@ -45,12 +47,14 @@ public abstract class AbstractBoltTestElement extends AbstractTestElement
{
         if (accessMode != null) {
             return accessMode;
         } else {
-            return "WRITE";
+            return AccessMode.WRITE.toString();
         }
     }
 
     public void setAccessMode(String accessMode) {
-        this.accessMode = accessMode;
+        if (EnumUtils.isValidEnum(AccessMode.class, accessMode)) {
+            this.accessMode = accessMode;
+        }
     }
 
     public String getDatabase() {
@@ -90,7 +94,7 @@ public abstract class AbstractBoltTestElement extends AbstractTestElement
{
         SessionConfig.Builder sessionConfigBuilder = SessionConfig.builder()
                 .withDefaultAccessMode(Enum.valueOf(AccessMode.class, getAccessMode()));
 
-        if (database != null && !"".equals(database)) {
+        if (StringUtils.isNotBlank(database)) {
             sessionConfigBuilder.withDatabase(database);
         }
 
diff --git a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltSampler.java
b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltSampler.java
index d3787dc..94ec298 100644
--- a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltSampler.java
+++ b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltSampler.java
@@ -163,7 +163,7 @@ public class BoltSampler extends AbstractBoltTestElement implements Sampler,
Tes
             //get records already as consume() will exhaust the stream
             records = result.list();
         } else {
-            records = null;
+            records = Collections.emptyList();
         }
         response.append("\nSummary:");
         ResultSummary summary = result.consume();
@@ -190,7 +190,7 @@ public class BoltSampler extends AbstractBoltTestElement implements Sampler,
Tes
                 .append("\nRelationships Deleted: ")
                 .append(summary.counters().relationshipsDeleted());
         response.append("\n\nRecords: ");
-        if (records != null) {
+        if (isRecordQueryResults()) {
             for (Record record : records) {
                 response.append("\n").append(record);
             }
diff --git a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltTestElementBeanInfoSupport.java
b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltTestElementBeanInfoSupport.java
index cd07b8f..a4c93a5 100644
--- a/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltTestElementBeanInfoSupport.java
+++ b/src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltTestElementBeanInfoSupport.java
@@ -18,6 +18,7 @@
 package org.apache.jmeter.protocol.bolt.sampler;
 
 import java.beans.PropertyDescriptor;
+import java.util.Arrays;
 
 import org.apache.jmeter.testbeans.BeanInfoSupport;
 import org.apache.jmeter.testbeans.TestBean;
@@ -36,34 +37,33 @@ public abstract class BoltTestElementBeanInfoSupport extends BeanInfoSupport
{
         createPropertyGroup("query", new String[] { "cypher","params","recordQueryResults"});
         createPropertyGroup("options", new String[] { "accessMode","database", "txTimeout"});
 
-        PropertyDescriptor propertyDescriptor =  property("cypher", TypeEditor.TextAreaEditor);
+        PropertyDescriptor propertyDescriptor = property("cypher", TypeEditor.TextAreaEditor);
         propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
         propertyDescriptor.setValue(DEFAULT, "");
 
-        propertyDescriptor =  property("params", TypeEditor.TextAreaEditor);
+        propertyDescriptor = property("params", TypeEditor.TextAreaEditor);
         propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
         propertyDescriptor.setValue(DEFAULT, "{\"paramName\":\"paramValue\"}");
 
-        propertyDescriptor =  property("recordQueryResults");
+        propertyDescriptor = property("recordQueryResults");
         propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
         propertyDescriptor.setValue(DEFAULT, Boolean.FALSE);
 
-        propertyDescriptor =  property("accessMode", TypeEditor.ComboStringEditor);
+        propertyDescriptor = property("accessMode", TypeEditor.ComboStringEditor);
         propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
         propertyDescriptor.setValue(NOT_EXPRESSION, Boolean.TRUE);
         propertyDescriptor.setValue(DEFAULT, AccessMode.WRITE.toString());
         propertyDescriptor.setValue(TAGS, getListAccessModes());
 
-        propertyDescriptor =  property("database", TypeEditor.ComboStringEditor);
+        propertyDescriptor = property("database", TypeEditor.ComboStringEditor);
         propertyDescriptor.setValue(DEFAULT, "neo4j");
 
         propertyDescriptor = property("txTimeout");
         propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
-        propertyDescriptor.setValue(DEFAULT, "60");
+        propertyDescriptor.setValue(DEFAULT, 60);
     }
 
     private String[] getListAccessModes() {
-        String[] list = {AccessMode.READ.toString(), AccessMode.WRITE.toString()};
-        return list;
+        return Arrays.stream(AccessMode.values()).map(Enum::toString).toArray(String[]::new);
     }
 }
diff --git a/src/protocol/bolt/src/main/resources/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerResources.properties
b/src/protocol/bolt/src/main/resources/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerResources.properties
index 5e02808..fda9c0a 100644
--- a/src/protocol/bolt/src/main/resources/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerResources.properties
+++ b/src/protocol/bolt/src/main/resources/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerResources.properties
@@ -27,6 +27,6 @@ recordQueryResults.shortDescription=Records the results of queries and displays
 accessMode.displayName=Access Mode
 accessMode.shortDescription=Whether it's a READ or WRITE query (affects query routing in
clusters)
 database.displayName=Database
-database.shortDescription=Neo4j 4.x : database to query (leave empty for 3.5)
+database.shortDescription=Neo4j 4.x: database to query (leave empty for 3.5)
 txTimeout.displayName=Transaction timeout
 txTimeout.shortDescription=Transaction timeout in seconds
diff --git a/src/protocol/bolt/src/test/groovy/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerSpec.groovy
b/src/protocol/bolt/src/test/groovy/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerSpec.groovy
index d7a2565..a6062c7 100644
--- a/src/protocol/bolt/src/test/groovy/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerSpec.groovy
+++ b/src/protocol/bolt/src/test/groovy/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerSpec.groovy
@@ -82,7 +82,6 @@ class BoltSamplerSpec extends Specification {
             str.endsWith("Records: Skipped")
             response.getSampleCount() == 1
             response.getErrorCount() == 0
-            response.getTime() > 0
     }
 
     def "should display results if asked"() {
@@ -162,7 +161,6 @@ class BoltSamplerSpec extends Specification {
             str.endsWith("Records: Skipped")
             response.getSampleCount() == 1
             response.getErrorCount() == 0
-            response.getTime() > 0
     }
 
     def getEmptyQueryResult() {


Mime
View raw message