Running Java class with JMeter (Bean Shell) -
i have written java class use in jmeter, packaged project .jar file , moved file lib/ext folder in jmeter directory. have seen documentation on how proceed give contradictory answers.
the first way use beanshell sampler import package , class, create object of class , run methods way. have used method using example classes more simple file structures of class want run. example classes work following beanshell script.
import tools.jmetertools; jmetertools jt = new jmetertools(); jt.foo();
when try use method class want run, states variable declaration error , class cannot found. assume because not understand import exactly, file structure in project little odd.
the second uses beanshell preprocessor add jar class path. method have not been able work @ all, have read many accounts of others finding success. works follows:
addclasspath("directory path jar\lib\ext\foo.jar"); jmetertest jtm = new jmetertest(); jmt.test();
would have knowledge of way work better or ideas on how fix import?
the import have been using in beanshell script following:
import client.jmetertest;
the package line @ top of class following
import com.x.foo.client;
running external classes beanshell should work fine given following preconditions met
- your test dependencies located in jmeter classpath.
- jmeter restart required pick new libraries up
you need provide full package name plus full class name (or wildcard) import.
either
import com.x.foo.client.jmetertest;
or
import com.x.foo.client.*;
and recommended use jsr223 sampler , use "groovy" language. beanshell interpreter has severe performance issues use "light" variable amendment, converting variable property, etc. generating real load use jsr223 , groovy implements compilable interface , hence can achieve performance similar native java code. see beanshell vs jsr223 vs java jmeter scripting: performance-off you've been waiting for! guide detailed explanation, benchmarking , instructions on installation of groovy scripting engine support.
Comments
Post a Comment