by Jan Kronquist - Java, Testing
I have been using JMeter for load testing and I needed to create a custom plugin to handle parsing JSON results but I couldn’t find a simple guide how to do this. I wanted a simple solution that didn’t require manual installation in my repository or a repository manager such as Nexus.
Building a plugin using maven is easy, simply add the following to your pom:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<properties> <jmeter.home>installation directory of jmeter</jmeter.home> </properties> <dependencies> <dependency> <groupId>org.apache.jmeter</groupId> <artifactId>jmeter-core</artifactId> <version>2.3.4</version> <scope>system</scope> <systemPath>${jmeter.home}/lib/ext/ApacheJMeter_core.jar</systemPath> </dependency> <dependency> <groupId>org.apache.jmeter</groupId> <artifactId>jmeter-jorphan</artifactId> <version>2.3.4</version> <scope>system</scope> <systemPath>${jmeter.home}/lib/jorphan.jar</systemPath> </dependency> </dependencies> |
You probably want to put jmeter.home in your settings.xml instead.
Whenever I develop something I want to have a quick build/test cycle. In this case I want to to start the JMeter UI without having to update the JMeter installation or any other manual work. I didn’t get chronos to add my plugin to the UI. It seems chronos copied the jar files to JMETER_HOME/lib/junit and this probably works for running an already created test, but not for creating the test. I also failed to the the maven exec plugin to create the command line arguments I needed. Instead I added a small ant script to start JMeter:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <configuration> <tasks> <property name="runtime_classpath" refid="maven.runtime.classpath" /> <exec executable="${jmeter.home}/bin/jmeter.bat"> <arg value="-Jsearch_paths=${runtime_classpath}" /> </exec> </tasks> </configuration> </plugin> </plugins> </build> |
To run the jmeter gui simply run mvn antrun:run. This only works for Windows, I leave other platforms as an exercise to the reader :-).
I ended up copying the plugin jar and dependencies to the JMeter installation and used then this modified JMeter distribution when performing the tests. The reason was that I didn’t have maven installed on some of the test clients. To copy dependencies you can use mvn dependency:copy-dependencies.
If you want to run JMeter using maven you probably want to look at chronos (although it is not released it seems to work fine):
I succeeded, but unfortunately I never got the time to package and release the code.
Hi Jan
Did you succeed to build JSON parser plugin?
If yes are you will to share it with as, Because I looking for this kind of plugin…
Thanks
eBenda