jmeter-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 62604] New: Not being able to use json-smart in BeanShell
Date Tue, 07 Aug 2018 20:59:23 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=62604

            Bug ID: 62604
           Summary: Not being able to use json-smart in BeanShell
           Product: JMeter
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Main
          Assignee: issues@jmeter.apache.org
          Reporter: ricardogaspar2@gmail.com
  Target Milestone: ---

Created attachment 36076
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36076&action=edit
jmx file

I'm using JMeter 4.0r1823414

I'm trying to use the library json-smart that resides in lib folder of jmeter
inside a BeanShell script  but without  success.

I'm already using JSON Extractor just to extract some JSONs, but now I need to
manipulate them; that's why I I'm using BeanShell. 

I'm getting the following errors:

2018-08-07 21:38:03,549 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh
method: eval     Sourced file: inline evaluation of: ``import
net.minidev.json.JSONObject; import net.minidev.json.parser.JSONParser;   . . .
'' : Typed variable declaration
2018-08-07 21:38:03,549 WARN o.a.j.e.BeanShellPostProcessor: Problem in
BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh
method: eval      Sourced file: inline evaluation of: ``import
net.minidev.json.JSONObject; import net.minidev.json.parser.JSONParser;   . . .
'' : Typed variable declaration

And this is my BeanShell Script:

-------
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;

// formats JSON variables houseDataJson; entityTypeGroupsJson
// takes the variable with the JSON for entityTypeGroups and adds the prefix
"entityTypeGroups":{ VARIABLE WITH JSON CODE HERE} 

String SCRIPT_NAME = "[FormatJsonVariables]";

// names of the variables retrieved from JSON Extractor from get_house_data
request
String PKID_VAR_NAME = "pkid";
String HOUSE_DATA_VAR_NAME = "houseDataJson";
String ENTITY_TYPE_GROUPS_VAR_NAME = "entityTypeGroupsJson";

log.info(SCRIPT_NAME+ " checking id variables " + HOUSE_DATA_VAR_NAME +" and "
+ ENTITY_TYPE_GROUPS_VAR_NAME + " are present");

String currentPkid = vars.get(PKID_VAR_NAME);
JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);

JSONObject currentHouseDataJson = (JSONObject)
parser.parse(vars.get(HOUSE_DATA_VAR_NAME));
JSONObject currentEntityTypeGroupsJson = (JSONObject)
parser.parse(vars.get(ENTITY_TYPE_GROUPS_VAR_NAME));

log.info(SCRIPT_NAME + " current variable values:\n-currentPkid: " +
currentPkid + "\ncurrentHouseDataJson: "+ currentHouseDataJson
+"\ncurrentEntityTypeGroupsJson: " +currentEntityTypeGroupsJson)

------------

-- 
You are receiving this mail because:
You are the assignee for the bug.
Mime
View raw message