alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

JMeter example source code file (extending.xml)

This example JMeter source code file (extending.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - JMeter tags/keywords

a, apache, gui, gui, it, jmeter, jmeter, license, license, samplercontroller's, testsample, the, the, timers

The JMeter extending.xml source code

<?xml version="1.0"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<document>
  <properties>
    <title>Extending JMeter
  </properties>
<body>
<section name="Extending JMeter">
<font color="red">Note to developers: JMeter is undergoing large changes.  The following
description of JMeter's architecture will likely change in the near future.  If you
would like your changes to work with an upcoming JMeter 1.6, please join our mailing
list, and we will work with you and your modifications.</strong>
<p>Customizing JMeter to suit your needs.

<h3>Extensible Interfaces <p> There are five basic objects in JMeter which provide extensibility: <ul> <li>Visualizers represent the sampling data which is recorded. <li>Timers specify the delay between samples. <li>SamplerControllers hold information about all the test cases to be sampled, and overall information about how the test is conducted.</li> <li>Samplers are the classes that actually do the sampling of a particular protocol. <li>TestSamples hold information about a particular test case to be sampled. </ul> </p> <p> <a name="visualizers"> <h3>Visualizers The <code>Visualizer interface exists in the org.apache.jmeter.visualizers package. JMeter maintains an instance of each visualizer it is aware of for each thread group currently available to the user. A visualizer provides a method of recording the data which JMeter generates. A visualizer may represent the data graphically (GraphVisualizer), persistently (FileVisualizer) or both (TBD). The visualizer contains three methods: <dl> <dt>add(SampleResult result) adds data to the visualization. <dd> JMeter calls the <code>add method to include new data in the visualizer. The visualizer should add the data into its data representation. </dd> <dt>clear() clears all data in the visualizer currently <dd> JMeter calls <code>clear when the user requests that all visualizers be cleared. When the clear method is called the visualizer should clear all data from its representation and re-initialize itself. </dd> <dt>getControlPanel() obtains the GUI for the visualizer <dd> JMeter calls <code>getControlPanel at start up time to prepare the visualizer for display. </dd> </dl> <a name="timers"> </p> <p> <h3>Timers Timers provide a framework for delaying in between samples. This is important in order to obtain a true balanced load on a function rather than a calm-STORM-calm-STORM-calm... pattern. Timers contain two methods: <dl> <dt>delay() wait for a Timer specific amount of time <dd>JMeter calls this function prior to every sample. The Timer should wait for a period of time and then return. <dt>set() prepare for sampling <dd>JMeter calls this function prior to the begining of a test session. The timer should initialize itself, read any values from its UI and prepare for operation. </dd> </dl> </p> <p> <a name="samplercontrollers"> <h3>SamplerControllers The sampler controller is by far the most complicated, but also the most powerful, interface in JMeter. It allows a user to customize what, where and when JMeter tests. It provides six methods: <dl> <dt>start() <dd> JMeter calls this immediatly prior to starting a test. It is most often use to disable the SamplerController's GUI. </dd> <dt>stop() <dd> JMeter calls this when a user requests a stop to a test. It is most often used to re-enable the SamplerController's GUI. </dd> <dt>getControlPanel() Get the GUI for the SamplerController <dd> JMeter calls this at start up to create the its GUI. This is how a user enters information into the SamplerController. </dd> <dt>getName() Get the SamplerController's display name. <dd> JMeter uses this name in the list of SamplerControllers that it displays. </dd> <dt>getDefaultThreadGroups() <dd>Gets the default list of threadgroups. <dt>getSampleThreads(String threadGroup,int numThreads) <dd>When the user hits start, use this method to get all the JMeterThread objects you want for a threadgroup. Each JMeterThread object implements Runnable and it is used to sample the test entries. </dd> </dl> </p> <p> <a name="samplers"> <h3>Samplers Samplers are simple - they are the objects that know the protocol of that which you wish to sample. The HTTPSampler knows how to request a URL from a web server, for instance. The interface for Sampler is as follows: <dl> <dt>public SampleResult sample(Entry e) <dd>JMeterThread implementations will loop through all the test samples given to them, and call the sample method on the Sampler (also given to them) for each test entry. SampleResult is essentially a Map containing information about the sampling (timing data is included, as well as the test response from the url). </dd> </dl> </p> <p> <a name="testsamples"> <h3>TestSample TestSamples are objects that collect information from users about each test sample the user wants to test. The TestSample object is also responsible for serving up its test entries. The interface: <dl> <dt>public java.awt.Container getGUI() <dd>Returns the GUI used to collect information from the user. <dt>public Entry[] getEntries() <dd>Gets a list of entries to be sampled from the TestSample object <dt>public String[] getThreadGroups() <dd>Get all the thread groups the user selected for this TestSample <dt>public void setThreadGroups(String[] threadGroups) <dd>Set the thread groups the user may choose from <dt>public String getName() <dd>Get a name for this TestSample <dt>public void setName(String name) <dd>Set the name for this TestSample <dt>public void reset() <dd>inform the test sample that a sampling run is starting </dl> </p> </section> </body> </document>

Other JMeter examples (source code examples)

Here is a short list of links related to this JMeter extending.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.