public class JMeterUtils extends Object implements UnitTestManager
Modifier and Type | Field and Description |
---|---|
static String |
RES_KEY_PFX |
Constructor and Description |
---|
JMeterUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addLocaleChangeListener(LocaleChangeListener listener) |
static void |
applyHiDPI(JTable table)
Apply HiDPI mode management to
JTable |
static void |
clearMatcherMemory(org.apache.oro.text.regex.Perl5Matcher matcher,
org.apache.oro.text.regex.Pattern pattern)
Hack to make matcher clean the two internal buffers it keeps in memory which size is equivalent to
the unzipped page size
|
static JButton |
createButton(String name,
ActionListener listener)
Deprecated.
(3.0) not used
|
static JButton |
createSimpleButton(String name,
ActionListener listener)
Deprecated.
(3.0) not used
|
static List<String> |
findClassesThatExtend(Class<?> superClass)
Convenience method for
ClassFinder.findClassesThatExtend(String[], Class[], boolean)
with the option to include inner classes in the search set to false
and the path list is derived from JMeterUtils.getSearchPaths(). |
static File |
findFile(String fileName)
Find a file in the current directory or in the JMeter bin directory.
|
static int |
findInArray(String[] array,
String value)
Deprecated.
(3.0) not used
|
static Hashtable<String,String> |
getAlias(Properties properties)
Deprecated.
(3.0) not used
|
static Vector<Object> |
getControllers(Properties properties)
Deprecated.
(3.0) not used + pre-java 1.2 collection
|
static String |
getDelimiter(String delimiterValue)
Return delimiterValue handling the TAB case
|
static Hashtable<String,String> |
getHashtable(Properties properties,
String prefix)
Deprecated.
(3.0) not used
|
static boolean |
getHiDPIMode()
Provide info, whether we run in HiDPI mode
|
static double |
getHiDPIScaleFactor()
Provide info about the HiDPI scale factor
|
static ImageIcon |
getImage(String name)
This looks for the requested image in the classpath under
org.apache.jmeter.images.
|
static ImageIcon |
getImage(String name,
String description)
This looks for the requested image in the classpath under
org.apache.jmeter.images.
|
static String |
getJMeterBinDir()
Get the JMeter bin directory - does not include the trailing separator.
|
static String |
getJMeterCopyright()
Gets the JMeter copyright.
|
static String |
getJMeterHome()
Get the JMeter home directory - does not include the trailing separator.
|
static Properties |
getJMeterProperties()
This gets the currently defined appProperties.
|
static String |
getJMeterVersion()
Gets the JMeter Version.
|
static Locale |
getLocale()
Gets the current locale.
|
static String |
getLocaleString(String locale)
Get the locale name as a resource.
|
static String |
getLocalHostFullName()
Returns the cached result from calling
InetAddress.getLocalHost().getCanonicalHostName()
|
static String |
getLocalHostIP()
Returns the cached result from calling
InetAddress.getLocalHost().getHostAddress()
|
static String |
getLocalHostName()
Returns the cached result from calling
InetAddress.getLocalHost().getHostName()
|
static org.apache.oro.text.regex.Perl5Matcher |
getMatcher()
Gets Perl5Matcher for this thread.
|
static String |
getParsedLabel(String key)
To get I18N label from properties file
|
static org.apache.oro.text.regex.Pattern |
getPattern(String expression)
Get a compiled expression from the pattern cache (READ_ONLY).
|
static org.apache.oro.text.regex.Pattern |
getPattern(String expression,
int options)
Get a compiled expression from the pattern cache.
|
static org.apache.oro.text.PatternCacheLRU |
getPatternCache() |
static boolean |
getPropDefault(String propName,
boolean defaultVal)
Get a boolean value with default if not present.
|
static float |
getPropDefault(String propName,
float defaultVal)
Get a float value with default if not present.
|
static int |
getPropDefault(String propName,
int defaultVal)
Get a int value with default if not present.
|
static long |
getPropDefault(String propName,
long defaultVal)
Get a long value with default if not present.
|
static String |
getPropDefault(String propName,
String defaultVal)
Get a String value with default if not present.
|
static Properties |
getProperties(String file)
This method is used by the init method to load the property file that may
even reside in the user space, or in the classpath under
org.apache.jmeter.jmeter.properties.
|
static String |
getProperty(String propName)
Get the value of a JMeter property.
|
static int |
getRandomInt(int r)
Provide random numbers
|
static String |
getResourceFileAsText(String name) |
static String |
getResString(String key)
Gets the resource string for this key.
|
static String |
getResString(String key,
Locale forcedLocale)
Gets the resource string for this key in Locale.
|
static String |
getResString(String key,
String defaultValue)
Deprecated.
Only intended for use in development; use
getResString(String) normally
|
static String[] |
getSearchPaths()
Generate a list of paths to search.
|
static String[] |
getTestSamples(Properties properties,
String name)
Deprecated.
(3.0) not used
|
static Vector<Object> |
getTimers(Properties properties)
Deprecated.
(3.0) not used + pre-java 1.2 collection
|
static Vector<String> |
getVector(Properties properties,
String name)
Creates a vector of strings for all the properties that start with a
common prefix.
|
static Vector<Object> |
getVisualizers(Properties properties)
Deprecated.
(3.0) not used + pre-java 1.2 collection
|
static XMLReader |
getXMLParser()
Deprecated.
(3.0) was only called by UserParameterXMLParser.getXMLParameters which has been removed in 3.0
|
static void |
helpGC()
Help GC by triggering GC and finalization
|
void |
initializeProperties(String file)
Your implementation will be handed the filename that was provided to
AllTests as a configuration file.
|
static void |
initLocale()
Initialise the JMeter Locale
|
static void |
initLogging()
Initialise JMeter logging
|
static Object |
instantiate(String className,
String impls)
Deprecated.
(3.0) not used out of this class
|
static Vector<Object> |
instantiate(Vector<String> v,
String className)
Deprecated.
(3.0) not used out of this class
|
static boolean |
isExpertMode()
Determine whether we are in 'expert' mode.
|
static boolean |
isTestRunning() |
static void |
loadJMeterProperties(String file)
Load the JMeter properties file; if not found, then
default to "org/apache/jmeter/jmeter.properties" from the classpath
c.f. loadProperties
|
static Properties |
loadProperties(String file)
This method loads a property file that may reside in the user space, or
in the classpath
|
static Properties |
loadProperties(String file,
Properties defaultProps)
This method loads a property file that may reside in the user space, or
in the classpath
|
static LinkedHashMap<String,String> |
parseHeaders(String headers)
Split line into name/value pairs and remove colon ':'
|
static void |
removeLocaleChangeListener(LocaleChangeListener listener) |
static void |
reportErrorToUser(String errorMsg)
Report an error through a dialog box.
|
static void |
reportErrorToUser(String errorMsg,
String titleMsg)
Report an error through a dialog box.
|
static void |
runSafe(boolean synchronous,
Runnable runnable)
Run the runnable in AWT Thread if current thread is not AWT thread
otherwise runs call
SwingUtilities.invokeAndWait(Runnable) |
static void |
runSafe(Runnable runnable)
Run the runnable in AWT Thread if current thread is not AWT thread
otherwise runs call
SwingUtilities.invokeAndWait(Runnable) |
static void |
selJComboBoxItem(Properties properties,
JComboBox<?> combo,
Vector<?> namVec,
String name)
Deprecated.
|
static void |
setJMeterHome(String home) |
static void |
setLocale(Locale loc)
Changes the current locale: re-reads resource strings and notifies
listeners.
|
static Object |
setProperty(String propName,
String propValue)
Set a String value
|
static String |
unsplit(Object[] splittee,
Object splitChar)
Takes an array of strings and a tokenizer character, and returns a string
of all the strings concatenated with the tokenizer string in between each
one.
|
static String |
unsplit(Object[] splittee,
Object splitChar,
String def)
Takes an array of strings and a tokenizer character, and returns a string
of all the strings concatenated with the tokenizer string in between each
one.
|
public static final String RES_KEY_PFX
public static org.apache.oro.text.regex.Perl5Matcher getMatcher()
Perl5Matcher
for this threadpublic static Properties getProperties(String file)
file
- the file to loadgetJMeterProperties()
,
loadJMeterProperties(String)
,
initLogging()
,
initLocale()
public static void initLogging()
public static void initLocale()
public static void loadJMeterProperties(String file)
c.f. loadProperties
file
- Name of the file from which the JMeter properties should be loadedpublic static Properties loadProperties(String file)
file
- the file to loadpublic static Properties loadProperties(String file, Properties defaultProps)
file
- the file to loaddefaultProps
- a set of default propertiespublic static org.apache.oro.text.PatternCacheLRU getPatternCache()
public static org.apache.oro.text.regex.Pattern getPattern(String expression) throws org.apache.oro.text.MalformedCachePatternException
expression
- regular expression to be looked uporg.apache.oro.text.MalformedCachePatternException
- (Runtime)
This should be caught for expressions that may vary (e.g. user input)public static org.apache.oro.text.regex.Pattern getPattern(String expression, int options) throws org.apache.oro.text.MalformedCachePatternException
expression
- REoptions
- e.g. READ_ONLY_MASK
org.apache.oro.text.MalformedCachePatternException
- (Runtime)
This should be caught for expressions that may vary (e.g. user input)public void initializeProperties(String file)
UnitTestManager
initializeProperties
in interface UnitTestManager
file
- path to the configuration filepublic static List<String> findClassesThatExtend(Class<?> superClass) throws IOException
ClassFinder.findClassesThatExtend(String[], Class[], boolean)
with the option to include inner classes in the search set to false
and the path list is derived from JMeterUtils.getSearchPaths().superClass
- - single class to search forIOException
- when the used ClassFinder
throws one while searching for the classpublic static String[] getSearchPaths()
public static int getRandomInt(int r)
r
- -
the upper bound (exclusive)int
public static void setLocale(Locale loc)
loc
- -
new localepublic static Locale getLocale()
public static void addLocaleChangeListener(LocaleChangeListener listener)
public static void removeLocaleChangeListener(LocaleChangeListener listener)
public static String getResString(String key)
key
- the key in the resource filepublic static String getResString(String key, Locale forcedLocale)
key
- the key in the resource fileforcedLocale
- Force a particular locale@Deprecated public static String getResString(String key, String defaultValue)
key
- the key in the resource filedefaultValue
- -
the default valuepublic static String getParsedLabel(String key)
key
- in messages.propertiespublic static String getLocaleString(String locale)
locale
- namepublic static Properties getJMeterProperties()
getProperties(String)
or loadJMeterProperties(String)
method has been called.loadJMeterProperties(String)
has not been calledgetProperties(String)
,
loadJMeterProperties(String)
public static ImageIcon getImage(String name)
name
- Description of Parameterpublic static ImageIcon getImage(String name, String description)
name
- the name of the imagedescription
- the description of the image@Deprecated public static Vector<Object> getTimers(Properties properties)
properties
- Description of Parameter@Deprecated public static Vector<Object> getVisualizers(Properties properties)
properties
- Description of Parameter@Deprecated public static Vector<Object> getControllers(Properties properties)
properties
- The properties with information about the samplers@Deprecated public static String[] getTestSamples(Properties properties, String name)
properties
- The properties with info about the samples.name
- The name of the sampler controller.@Deprecated public static XMLReader getXMLParser()
@Deprecated public static Hashtable<String,String> getAlias(Properties properties)
The properties will be filtered by all values starting with
alias.
. The matching entries will be used for the new
Hashtable
while the prefix alias.
will be stripped
of the keys.
properties
- the input valuespublic static Vector<String> getVector(Properties properties, String name)
properties
- Description of Parametername
- Description of Parameter@Deprecated public static Hashtable<String,String> getHashtable(Properties properties, String prefix)
So if you have Properties
prop
with two entries, say
prefix
this, the
result would be a new Hashtable
with one entry, which key would
be test.properties
- input to searchprefix
- to match against propertiespublic static int getPropDefault(String propName, int defaultVal)
propName
- the name of the property.defaultVal
- the default value.public static boolean getPropDefault(String propName, boolean defaultVal)
propName
- the name of the property.defaultVal
- the default value.public static long getPropDefault(String propName, long defaultVal)
propName
- the name of the property.defaultVal
- the default value.public static float getPropDefault(String propName, float defaultVal)
propName
- the name of the property.defaultVal
- the default value.public static String getPropDefault(String propName, String defaultVal)
propName
- the name of the property.defaultVal
- the default value.public static String getProperty(String propName)
propName
- the name of the property.public static Object setProperty(String propName, String propValue)
propName
- the name of the property.propValue
- the value of the property@Deprecated public static void selJComboBoxItem(Properties properties, JComboBox<?> combo, Vector<?> namVec, String name)
properties
- not used at the momentcombo
- JComboBox
to work onnamVec
- List of names, which are displayed in combo
name
- Name, that is to be selected. It has to be in namVec
@Deprecated public static Object instantiate(String className, String impls)
className
- The name of the class to instantiate.impls
- The name of the class it must be an instance of@Deprecated public static Vector<Object> instantiate(Vector<String> v, String className)
v
- Description of ParameterclassName
- Description of Parameter@Deprecated public static JButton createButton(String name, ActionListener listener)
name
- Description of Parameterlistener
- Description of Parameter@Deprecated public static JButton createSimpleButton(String name, ActionListener listener)
name
- Description of Parameterlistener
- Description of Parameterpublic static void reportErrorToUser(String errorMsg)
errorMsg
- - the error message.public static void reportErrorToUser(String errorMsg, String titleMsg)
errorMsg
- - the error message.titleMsg
- - title string@Deprecated public static int findInArray(String[] array, String value)
array
- Array of strings.value
- String to compare to array values.public static String unsplit(Object[] splittee, Object splitChar)
splittee
- Array of Objects to be concatenated.splitChar
- Object to unsplit the strings with.public static String unsplit(Object[] splittee, Object splitChar, String def)
splittee
- Array of Objects to be concatenated.splitChar
- Object to unsplit the strings with.def
- Default value to replace null values in array.public static boolean isTestRunning()
public static String getJMeterHome()
public static String getJMeterBinDir()
public static void setJMeterHome(String home)
public static String getJMeterVersion()
public static String getJMeterCopyright()
public static boolean isExpertMode()
public static File findFile(String fileName)
fileName
- the name of the file to findpublic static String getLocalHostIP()
public static String getLocalHostName()
public static String getLocalHostFullName()
public static LinkedHashMap<String,String> parseHeaders(String headers)
headers
- multi-line string headerspublic static void runSafe(Runnable runnable)
SwingUtilities.invokeAndWait(Runnable)
runnable
- Runnable
public static void runSafe(boolean synchronous, Runnable runnable)
SwingUtilities.invokeAndWait(Runnable)
synchronous
- flag, whether we will wait for the AWT Thread to finish its job.runnable
- Runnable
public static void helpGC()
public static void clearMatcherMemory(org.apache.oro.text.regex.Perl5Matcher matcher, org.apache.oro.text.regex.Pattern pattern)
matcher
- Perl5Matcher
pattern
- Patternpublic static boolean getHiDPIMode()
true
if we run in HiDPI mode, false
otherwisepublic static double getHiDPIScaleFactor()
public static void applyHiDPI(JTable table)
JTable
table
- the JTable
which should be adapted for HiDPI modepublic static String getDelimiter(String delimiterValue)
delimiterValue
- Delimited valueJMeterError
- if delimiterValue has a length different from 1Copyright © 1998-2016 Apache Software Foundation. All Rights Reserved.