I am new to Jmeter's JSR223 PreProcessor. We have just integrated Paytm's payment gateway into our product and we had to run load tests using Jmeter. We have to generate a checksum using a set of values and then inject that into our Json payload. I am using Java Beanshell to execute the code. I have added the jar file available here in my bin directory and also added it to my class path before starting the tests. Here is what my code looks like:
import com.paytm.merchant.CheckSumServiceHelper;
com.paytm.merchant.CheckSumServiceHelper checkSumServiceHelper = com.paytm.merchant.CheckSumServiceHelper.getCheckSumServiceHelper();
TreeMap<String,String> parameters = new TreeMap<String,String>();
String merchantKey = "xxxxxxxxxxxxxxxxx";
parameters.put("MID", "xxxxxxxxxxxxxxxxxxxxxx");
parameters.put("ORDERID", "${orderId}");
parameters.put("TXNID", "20200113111212800110168201701179744");
parameters.put("TXN_AMOUNT", "10.01");
parameters.put("PAYMENTMODE", "DC");
parameters.put("CURRENCY", "INR");
parameters.put("TXNDATE", "2020-01-13 13:59:03.0");
parameters.put("STATUS", "TXN_SUCCESS");
parameters.put("RESPCODE", "01");
parameters.put("RESPMSG", "Txn Success");
parameters.put("GATEWAYNAME", "HDFC");
parameters.put("BANKTXNID", "777001911059826");
parameters.put("BANKNAME", "JPMORGAN CHASE BANK");
parameters.put("BANKNAME", "JPMORGAN CHASE BANK");
String checkSum = checkSumServiceHelper.genrateCheckSumGAE(merchantKey, parameters);
vars.put("checkSum", checkSum)
Here is the error I am getting as a result:
javax.script.ScriptException: Sourced file: inline evaluation of: ``import com.paytm.merchant.CheckSumServiceHelper; com.paytm.merchant.CheckSumSer . . . '' : Typed variable declaration : Class: com.paytm.merchant.CheckSumServiceHelper not found in namespace : at Line: 3 : in file: inline evaluation of: ``import com.paytm.merchant.CheckSumServiceHelper; com.paytm.merchant.CheckSumSer . . . '' : com .paytm .merchant .CheckSumServiceHelper
in inline evaluation of: ``import com.paytm.merchant.CheckSumServiceHelper; com.paytm.merchant.CheckSumSer . . . '' at line number 3
at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:93) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233) ~[java.scripting:?]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:225) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.modifiers.JSR223PreProcessor.process(JSR223PreProcessor.java:44) [ApacheJMeter_components.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:935) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:537) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
at java.lang.Thread.run(Thread.java:830) [?:?]
Any kind of help to resolve this error will be highly appreciated. It might be a stupid question but I am new to this so please help!! :)
EDIT:
I am now using the groovy syntax for doing this. I am not able to view my checksum variable in View Results Tree with my debug sampler but I am able to see it in the console. The value is shown correctly in console. But the variable is not being exported.
import com.paytm.pg.merchant.CheckSumServiceHelper;
com.paytm.pg.merchant.CheckSumServiceHelper checkSumServiceHelper = com.paytm.pg.merchant.CheckSumServiceHelper.getCheckSumServiceHelper();
TreeMap parameters = new TreeMap();
String merchantKey = "xxxxxxxxxxxxxxxxx";
parameters.put("MID", "xxxxxxxxxxxxxxxxxxxxxx");
parameters.put("ORDERID", "${orderId}");
parameters.put("TXNID", "20200113111212800110168201701179744");
parameters.put("TXN_AMOUNT", "10.01");
parameters.put("PAYMENTMODE", "DC");
parameters.put("CURRENCY", "INR");
parameters.put("TXNDATE", "2020-01-13 13:59:03.0");
parameters.put("STATUS", "TXN_SUCCESS");
parameters.put("RESPCODE", "01");
parameters.put("RESPMSG", "Txn Success");
parameters.put("GATEWAYNAME", "HDFC");
parameters.put("BANKTXNID", "777001911059826");
parameters.put("BANKNAME", "JPMORGAN CHASE BANK");
parameters.put("BANKNAME", "JPMORGAN CHASE BANK");
String checkSum = checkSumServiceHelper.genrateCheckSumGAE(merchantKey, parameters);
Out. println "s====================================ssssss"
OUT. println checkSum
props.put("checkSum", checkSum);
Here is the error when I run this:
javax.script.ScriptException: javax.script.ScriptException: java.security.InvalidKeyException: Invalid AES key length: 17 bytes
I think this error is due to my input values.