I am trying to create a jmeter jmx file using the jmeter java api. This is what I have done,
- gui.jmx
Use the jmeter gui application to create a reference jmx file against which I can compare. To the test plan, I only add a thread group and a java sampler within the thread group. All values are default.
- code.jmx
Using the jmeter java api, I create a jmx file containing a test plan, thread group and java sampler. All values are set as per the case 1.
After creating the jmx file from code, I note the following differences,
1) The nodes in gui.jmx is replaced by the following in code.jmx
<org.apache.jorphan.collections.HashTree>
Though this is not an issue, is it possible to somehow generate the following tag as the GUI saves it
<hashTree>
2) Test element nodes contain the attributes 'guiClass' and 'testClass' in gui.jmx e.g. These attributes are not generated in code.jmx and neither did I find any API to explicitly set them -> Due to this the generated code.jmx does not open in the jmeter gui console. Which probably means that the generated jmx can be used in no console mode only. Is this by design? Is there some way by which these attributes can be added via code using the jmeter apis? (not using DOM as a hack)
3) The xml structure of gui.jmx is as follows,
<hashTree>
<TestPlan ...>
...
</TestPlan>
<hashTree>
<ThreadGroup ...>
...
</ThreadGroup>
**<hashTree/>**
</hashTree>
</hashTree>
Note the nesting of the HashTree elements. When this opens up in the JMeter GUI, the elements are nested within each other.
The xml structure of code.jmx is as follows,
<org.apache.jorphan.collections.HashTree>
<TestPlan ...>
...
</TestPlan>
**<org.apache.jorphan.collections.HashTree/>**
<ThreadGroup ...>
...
</ThreadGroup>
**<org.apache.jorphan.collections.HashTree/>**
</org.apache.jorphan.collections.HashTree>
Note the difference in placement of tags. There is no nesting. They are all at the same level. Why does this happen. What is the proper way to add test elements using jmx api so that the hash tree elements are nested within each other as in the first case?