Ok so I have looked and could not find first, why I am getting this error and second, I couldn't find the answer through search.
So basically I am trying to run a test plan using JMeter. I essentially copy/paste the template for both running an existing .JMX file and creating a new Test Plan, all from using purely Java code.
The first code is from the web when running an existing .jmx file
public static void main() throws Exception {
// JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties("/Users/jmoore/Documents/apache-jmeter-2.11/bin/jmeter.properties");
JMeterUtils.setJMeterHome("/Users/jmoore/Documents/apache-jmeter-2.11/bin/jmeter.sh");
JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
FileInputStream in = new FileInputStream("/Users/jmoore/dev/commerce/selenium/jmeter/src/test/testplans/test1.jmx");
HashTree testPlanTree = SaveService.loadTree(in);
in.close();
// Run JMeter Test
jmeter.configure(testPlanTree);
jmeter.run();
}
The second (below), is from trying to create my own Test Plan (sample from the web)
@Test
public void example() {
//JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
//JMeter initialization (properties, log levels, locale, etc)
JMeterUtils.loadJMeterProperties("/Users/jmoore/Documents/apache-jmeter-2.11/bin/jmeter.properties");
JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
// JMeter Test Plan, basic all u JOrphan HashTree
HashTree testPlanTree = new HashTree();
// HTTP Sampler
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setDomain("https:/www.google.com/");
httpSampler.setPort(80);
httpSampler.setPath("/");
httpSampler.setMethod("GET");
// Loop Controller
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.addTestElement(httpSampler);
loopController.setFirst(true);
loopController.initialize();
// Thread Group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// Test Plan
TestPlan testPlan = new TestPlan("Create JMeter Script From Java Code");
// Construct Test Plan from previously initialized elements
testPlanTree.add("testPlan", testPlan);
testPlanTree.add("loopController", loopController);
testPlanTree.add("threadGroup", threadGroup);
testPlanTree.add("httpSampler", httpSampler);
// Run Test Plan
jmeter.configure(testPlanTree);
jmeter.run();
}
First Problem (first code): For trying to run an existing .JMX file, I keep getting the error: "JMeter requires the saveservice properties file to continue"
But the funny thing is in my /bin, there is clearly a saveservice.properties file
Second Problem (second code): It runs fine, the only problem is I do not even see a standard output. When I did some research, (google and through here), it states to uncomment the section regarding the summariser which is located in the "jmeter.properties" file - Great and I did that. I uncommented the following:
summariser.out=true
So my question is why isn't there anything at least being printed out to the screen if it has been uncommented and set to 'true?' I prefer the second way rather than the first because I can customize it more to my needs.
Thank you