How might I convert this beanshell preprocessor script in jmeter to neoload javascript?
import java.time.Instant;
String epoc = Long.toString(Instant.now().toEpochMilli());
vars.put("sequence", epoc);
In neoload I will use,
context.variableManager.setValue("sequenceNumber",epoc);
but I get error on the use of import statement.
Still have issue, but this is perhaps just a general question of how do use standard java classes like java.time in a neoload script?
Neoload javascript can call Java classes. Export your Java as a jar file and drop it into the lib/jslib folder of your project.
Since java.time.Instant is within Java SE not some custom class (https://docs.oracle.com/javase/8/docs/api/java/time/Insta...) , how can I add just that?
I only dabble with java, but your class imports the Java SE java.time.instant class, when you create a jar I would assume all the dependancies would also be in the jar? then you can just delare your method in the java script.
Not directly related to your question but it seems that your goal is to get the current time in milliseconds. Why don't you use the NeoLoad "current date" variable and choose the milliseconds format from the drop down list?
Did you get this working rob J.? I'm looking to parse an ISO 8601 timestamp and instant is now recommended but I can't see how to import the JAR if it's within Java 8 SE already...