Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-jmeter Wiki" 
for change notification.

The "JMeterMavenPlugin" page has been changed by JochenStiepel.
The comment on this change is: new link to ronnies wiki.
http://wiki.apache.org/jakarta-jmeter/JMeterMavenPlugin?action=diff&rev1=7&rev2=8

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

+ A more recent version of this wiki page can be found here
+ 
+ https://github.com/Ronnie76er/jmeter-maven-plugin/wiki
+ 
  This is a Maven 2 plugin that allows you to run JMeter tests as part of the 
build.  I am using this with [[http://jchav.blogspot.com/|JChav]] and 
[[http://maven.apache.org/continuum/|Continuum]] to automate the running of a 
suite of JMeter load tests, and publish the results to a web page.  Sorry this 
is not more polished.  It could use some TLC to make it more user-friendly to 
actually plug it into a project.  I just thought I'd stick the code out there 
as quickly as possible and see if anyone is interested in it before I went any 
further with it.
  
- To build and use the plugin:<<BR>> <<BR>>
+ To build and use the plugin:<<BR>> <<BR>> '''Remote Repository'''
- '''Remote Repository'''
+ 
-   * Create a locally hosted remote Maven repository, if you don't already 
have one.
+  * Create a locally hosted remote Maven repository, if you don't already have 
one.
-   * Configure your pom to utilize this remote repository.
+  * Configure your pom to utilize this remote repository.
  
  '''Deploy JMeter Jar'''
+ 
-   * Deploy the attached [[attachment:jmeter-2.2.jar|JMeter jar]] and 
[[attachment:jmeter-2.2.pom|POM]] to your remote repository (note that you do 
not need to have JMeter separately installed). For example: {{{
+  * Deploy the attached [[attachment:jmeter-2.2.jar|JMeter jar]] and 
[[attachment:jmeter-2.2.pom|POM]] to your remote repository (note that you do 
not need to have JMeter separately installed). For example:
+  {{{
  mvn deploy:deploy-file -DgroupId=org.apache.jmeter -DartifactId=jmeter 
-Dversion=2.2 -Dpackaging=jar 
-Dfile=c://downloads//jmeter//jmeterPlugin/jmeter-2.2.jar 
-DpomFile=c://downloads//jmeter//jmeterPlugin/jmeter-2.2.pom 
-Durl=file:////myRepoHost.com/FileShare/ProductDevelopment/ApplicationDevelopment/maven2repository
 -DrepositoryId=my-repo
  }}}
  
  '''Deploy Dependencies'''
+ 
-   * Add the jar files that are referenced in the JMeter POM to your local 
repository, via the deploy plugin, if they are not on ibiblio.
+  * Add the jar files that are referenced in the JMeter POM to your local 
repository, via the deploy plugin, if they are not on ibiblio.
  
  '''Install the Plugin'''
+ 
-   * Download the attached [[attachment:maven-jmeter-plugin-src.tar.gz|Maven 
JMeter Plugin source tarball]].  Untar it.
+  * Download the attached [[attachment:maven-jmeter-plugin-src.tar.gz|Maven 
JMeter Plugin source tarball]].  Untar it.
-   * Run "mvn install" to build and install the plugin.
+  * Run "mvn install" to build and install the plugin.
-   * In your project's pom.xml, add a dependency on this plugin: {{{
+  * In your project's pom.xml, add a dependency on this plugin:
+  {{{
  <dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>maven-jmeter-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
- </dependency>}}}
+ </dependency>
+ }}}
  
  '''Configure the Plugin'''
+ 
-   * Create a src/test/jmeter directory, and place your JMeter load tests 
there.
+  * Create a src/test/jmeter directory, and place your JMeter load tests there.
-   * Create a jmeter.properties file in src/test/jmeter.  It's fine to just 
copy the default properties file from the JMeter install if you want.
+  * Create a jmeter.properties file in src/test/jmeter.  It's fine to just 
copy the default properties file from the JMeter install if you want.
-   * Optionally configure includes and excludes in your pom.xml for which 
tests to run.  If you don't, it will just run **/*.jmx.  For example: {{{
+  * Optionally configure includes and excludes in your pom.xml for which tests 
to run.  If you don't, it will just run **/*.jmx.  For example:
+  {{{
    <build>
      <plugins>
        <plugin>
@@ -42, +54 @@

          </configuration>
        </plugin>
      </plugins>
-   </build> }}}
+   </build>
+ }}}
  
-   * The default reports directory is 'jmeter-reports' which is created in the 
base folder ( usually where maven is run from )
+  * The default reports directory is 'jmeter-reports' which is created in the 
base folder ( usually where maven is run from )
-   * Changing the reports directory : Add a reportDir setting to the plugin 
configuration. for example: {{{
+  * Changing the reports directory : Add a reportDir setting to the plugin 
configuration. for example:
+  {{{
    <build>
      <plugins>
        <plugin>
@@ -60, +74 @@

          </configuration>
        </plugin>
      </plugins>
-   </build> }}}
+   </build>
+ }}}
  
  '''Executing the Plugin'''
+ 
-   * Run "mvn org.apache.jmeter:maven-jmeter-plugin:jmeter" to run the tests.
+  * Run "mvn org.apache.jmeter:maven-jmeter-plugin:jmeter" to run the tests.
  
  '''Change to the plugin - by Peter Andersen / not committed!'''
  
@@ -75, +91 @@

  
  The problem is that maven hang after the test has ended.
  
+ Some debugging shows that the maven-jmeter-plugin call to jmeter course 
jmeter to leak threads, I have done the following change to the 
maven-jmeter-plugin that fixes the problem, using checkForEndOfTest method 
below.
- Some debugging shows that the maven-jmeter-plugin call to jmeter course 
jmeter to leak threads,
- I have done the following change to the maven-jmeter-plugin that fixes the 
problem, using checkForEndOfTest method below.
  
  Hope someone can use this to improve the plugin.
  
  Code changes to org.apache.jmeter.JMeterMojo.java:
  
  {{{
-       private void executeTest(File test) throws MojoExecutionException {
+         private void executeTest(File test) throws MojoExecutionException {
-               /...    cut out from mail
-                       try {
+                 /...    cut out from mail
+                         try {
-                               // This mess is necessary because the only way 
to know when JMeter
+                                 // This mess is necessary because the only 
way to know when JMeter
-                               // is done is to wait for all of the threads 
that it spawned to exit.
+                                 // is done is to wait for all of the threads 
that it spawned to exit.
-                               new JMeter().start(args.toArray(new 
String[]{}));
+                                 new JMeter().start(args.toArray(new 
String[]{}));
-                               BufferedReader in = new BufferedReader(new 
FileReader(jmeterLog));
+                                 BufferedReader in = new BufferedReader(new 
FileReader(jmeterLog));
-                               while (!checkForEndOfTest(in)) {
-                                       try {
-                                               Thread.sleep(1000);
-                                       } catch (InterruptedException e) {
-                                               break;
-                                       }
-                               }
-                               in.close();
-                       } catch (ExitException e) {
-                               if (e.getCode() != 0) {
-                                       throw new MojoExecutionException("Test 
failed", e);
-                               }
-                       } finally {
-                               System.setSecurityManager(oldManager);
+                                 while (!checkForEndOfTest(in)) {
+                                         try {
+                                                 Thread.sleep(1000);
+                                         } catch (InterruptedException e) {
+                                                 break;
+                                         }
+                                 }
+                                 in.close();
+                         } catch (ExitException e) {
+                                 if (e.getCode() != 0) {
+                                         throw new 
MojoExecutionException("Test failed", e);
+                                 }
+                         } finally {
+                                 System.setSecurityManager(oldManager);
-                               
Thread.setDefaultUncaughtExceptionHandler(oldHandler);
+                                 
Thread.setDefaultUncaughtExceptionHandler(oldHandler);
-                       }
-               } catch (IOException e) {
+                         }
+                 } catch (IOException e) {
-                       throw new MojoExecutionException("Can't execute test", 
e);
+                         throw new MojoExecutionException("Can't execute 
test", e);
-               }
-       }
+                 }
+         }
  
-       private boolean checkForEndOfTest(BufferedReader in) throws 
MojoExecutionException {
+         private boolean checkForEndOfTest(BufferedReader in) throws 
MojoExecutionException {
-               boolean testEnded = false;
-               try {
-                       String line;
+                 boolean testEnded = false;
+                 try {
+                         String line;
-                       while ( (line = in.readLine()) != null) {
+                         while ( (line = in.readLine()) != null) {
-                               if (line.indexOf("Test has ended") != -1) {
-                                       testEnded = true;
-                                       break;
-                               }
-                       }
-               } catch (IOException e) {
+                                 if (line.indexOf("Test has ended") != -1) {
+                                         testEnded = true;
+                                         break;
+                                 }
+                         }
+                 } catch (IOException e) {
-                       throw new MojoExecutionException("Can't read log file", 
e);
+                         throw new MojoExecutionException("Can't read log 
file", e);
+                 }
+                 return testEnded;
+         }
-               }
-               return testEnded;
-       }
- 
- 
  }}}
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to