jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikesh Goel" <nikeg...@gmail.com>
Subject Fwd: how to run jmeter from within JAVA program
Date Wed, 11 Jun 2008 14:50:29 GMT
Hi, I am new to this list so please excuse me if you are receiving this
message in duplicate. Please see my question below.
Thanks!!

---------- Forwarded message ----------
From: Nikesh Goel <nikegoel@gmail.com>
Date: Jun 11, 2008 8:12 PM
Subject: Fwd: how to run jmeter from within JAVA program
To: jmeter-user@jakarta.apache.org




---------- Forwarded message ----------
From: Nikesh Goel <nikegoel@gmail.com>
Date: Jun 11, 2008 8:08 PM
Subject: how to run jmeter from within JAVA program
To: jmeter-user-subscribe@jakarta.apache.org



Hi

How can I setup my JAVA code to run the testfile (.JMX file) and collect the
logs in some .xml file ?

The help file (help.txt) which comes along with the installation shows
running the Apache Jmeter in non GUI mode by using the following command on
command prompt

*java -jar ApacheJMeter.jar -n -t test-file [-p property-file] [-l log-file]
*
The same I have to achieve using JAVA code without any script file. I do not
want to run using Runtime.exec(..) as this will spawn a new process. I am
actually running a WAS 5.1 server with database connections and other
resources managed by the server. If a new process spawns, I think it will
not have access to those resources.

So I am trying something like code snippet below but not certain of passing
the testfile and logfile parameters. Kindly suggest something on how to
achieve this.

 Class[] argTypes = new Class[1];

argTypes[0] = String[].class;

try

{

Method mainMethod =
Class.forName("org.apache.jmeter.NewDriver").getDeclaredMethod("main",
argTypes);

String[] argListForInvokedMain = new String[2];

argListForInvokedMain[0] = "-testfile=test.jmx";

argListForInvokedMain[1] = "-logfile=test-1-1-1.xml";

mainMethod.invoke(null, argListForInvokedMain);

}

catch (Exception e) {

e.printStackTrace();

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message