Class Index

Classes


Class SystemUtilities

Class Summary
Constructor Attributes Constructor Name and Description
 
A singleton object that provides various utilities for use by the Script.
Field Summary
Field Attributes Field Name and Description
<constant> {integer}  
A constant that can be passed as the "indicator" parameter in calls to the "encodeString" and "decodeString" methods.
<constant> {integer}  
A constant that can be passed as the "indicator" parameter in calls to the "hashString" and "computeHmacString" methods.
<constant> {integer}  
A constant that can be passed as the "indicator" parameter in calls to the "hashString" and "computeHmacString" methods.
Method Summary
Method Attributes Method Name and Description
{String}  
computeHmacString(key, message, hashTypeIndicator)
Computes a Hash-based Message Authentication Code (HMAC) using the specified hash algorithm.
{String}  
decodeString(stringToDecode, decodingTypeIndicator)
Decodes the given string according to the specified encoding scheme.
{String}  
encodeString(stringToEncode, encodingTypeIndicator)
Encodes the given string according to the specified encoding scheme.
{String}  
generateRandomString(length, characterList)
Generates a random string of the specified length, comprised of characters from a given list.
{String}  
Generates a random string of alphabetic characters of the specified length.
{String}  
Generates a random string of alphanumeric characters of the specified length.
{String}  
Generates a random string of decimal digits of the specified length.
{String}  
Generates a random string of hexadecimal digits of the specified length.
{String}  
hashString(stringToHash, hashTypeIndicator)
Computes a hash value for the given string according to the specified hash algorithm.
{String[]}  
readFromURL(url, format, useCache, connectionTimeout, readTimeout)
Reads data from a CSV file (resource) at the specified URL, and returns that data as an array of strings.
Class Detail
SystemUtilities()
A singleton object that provides various utilities for use by the Script.

Accessible through the $util constant.

Field Detail
<constant> {integer} ENCODING_TYPE_BASE64
A constant that can be passed as the "indicator" parameter in calls to the "encodeString" and "decodeString" methods. (See the descriptions of those methods.)

Read only.


<constant> {integer} HASH_TYPE_MD5
A constant that can be passed as the "indicator" parameter in calls to the "hashString" and "computeHmacString" methods. (See the descriptions of those methods.)

Read only.


<constant> {integer} HASH_TYPE_SHA1
A constant that can be passed as the "indicator" parameter in calls to the "hashString" and "computeHmacString" methods. (See the descriptions of those methods.)

Read only.

Method Detail
{String} computeHmacString(key, message, hashTypeIndicator)
Computes a Hash-based Message Authentication Code (HMAC) using the specified hash algorithm.

Example:

var hmacValue = $util.computeHmacString("key", "message", $util.HASH_TYPE_SHA1);

Parameters:
{String} key

The secret key. This parameter cannot be omitted, null, undefined, or the empty string.

{String} message

The message (data) to be authenticated. This parameter cannot be omitted, null, undefined. or the empty string.

{integer} hashTypeIndicator

An indicator as to the hash algorithm to be used. Must be HASH_TYPE_MD5 or HASH_TYPE_SHA1. This parameter cannot be omitted, null, or undefined.

Returns:
{String} The computed HMAC value.

{String} decodeString(stringToDecode, decodingTypeIndicator)
Decodes the given string according to the specified encoding scheme.
Parameters:
{String} stringToDecode

The string to be decoded.

{integer} decodingTypeIndicator

An indicator as to the type of decoding to be done. The only value currently supported is ENCODING_TYPE_BASE64. If this parameter is omitted, null, or undefined, ENCODING_TYPE_BASE64 will be used.

Returns:
{String} The decoded string. Null if the input string was null or undefined.

{String} encodeString(stringToEncode, encodingTypeIndicator)
Encodes the given string according to the specified encoding scheme.
Parameters:
{String} stringToEncode

The string to be encoded.

{integer} encodingTypeIndicator

An indicator as to the type of encoding. The only value currently supported is ENCODING_TYPE_BASE64. If this parameter is omitted, null, or undefined, ENCODING_TYPE_BASE64 will be used.

Returns:
{String} The encoded string. Null if the input string was null or undefined.

{String} generateRandomString(length, characterList)
Generates a random string of the specified length, comprised of characters from a given list.
Parameters:
{integer} length

The length of the string to generate.

{String} characterList

A String containing the pool of characters from which to generate the String. Normally each character would appear exactly once in the list. However, if a character appears multiple times that will give it greater weighting in the random selection and thus that character will tend to appear more often.

Returns:
{String} The generated string.

{String} generateRandomStringAlpha(length)
Generates a random string of alphabetic characters of the specified length. The returned string will contain characters in the ranges A-Z and a-z.
Parameters:
{integer} length

The length of the string to generate.

Returns:
{String} The generated string.

{String} generateRandomStringAlphanumeric(length)
Generates a random string of alphanumeric characters of the specified length. The returned string will contain characters in the ranges A-Z, a-z, 0-9.
Parameters:
{integer} length

The length of the string to generate.

Returns:
{String} The generated string.

{String} generateRandomStringDecimalDigits(length)
Generates a random string of decimal digits of the specified length. The returned string will contain characters in the range 0-9.
Parameters:
{integer} length

The length of the string to generate.

Returns:
{String} The generated string.

{String} generateRandomStringHexDigits(length)
Generates a random string of hexadecimal digits of the specified length. The returned string will contain characters in the ranges A-F and 0-9.
Parameters:
{integer} length

The length of the string to generate.

Returns:
{String} The generated string.

{String} hashString(stringToHash, hashTypeIndicator)
Computes a hash value for the given string according to the specified hash algorithm.

Example:

var hashValue = $util.hashString("Input string", $util.HASH_TYPE_SHA1);
Parameters:
{String} stringToHash

The string for which the hash value is to be computed. This string cannot be null or the empty string.

{integer} hashTypeIndicator

An indicator as to the hash algorithm to be used. Must be HASH_TYPE_MD5 or HASH_TYPE_SHA1. This parameter cannot be omitted, null, or undefined.

Returns:
{String} The computed hash value.

{String[]} readFromURL(url, format, useCache, connectionTimeout, readTimeout)
Reads data from a CSV file (resource) at the specified URL, and returns that data as an array of strings.

Each element in the returned array represents a row in the file. For any row that contains multiple values, the value for that row is a nested array of the values in that row.

Example

To read from a file at "http://host/files/Locations.csv", the following call would be made:

var locationList = $util.readFromURL("http://host/files/Locations.csv");

If the file contained the following lines:

San Francisco,CA,94103
Timbuktu
Caribou,Aroostook County,Maine,USA
Hill Valley,CA,91905

The following array of strings would be returned:

locationList [0] [0] San Francisco
locationList [0] [1] CA
locationList [0] [2] 94103
locationList [1] Timbuktu
locationList [2] [0] Caribou
locationList [2] [1] Aroostook County
locationList [2] [2] Maine
locationList [2] [3] USA
locationList [3] [0] Hill Valley
locationList [3] [1] CA
locationList [3] [2] 91905
Parameters:
{String} url

The URL to read from.

{String} format Optional, Default: "CSV"

Optional, but if specified must be the string "CSV", which is the only value currently supported.

{boolean} useCache Optional, Default: true

Optional. If the value is true, the data that is read is cached in memory, so that subsequent reads from the same URL in the same play of the Composition will retrieve the data from memory rather than re-reading from the URL. If the value is false, the data will be read from the URL on every call. If this parameter is omitted or null, true is assumed.

{integer} connectionTimeout Optional, Default: 600000

Optional. Connection timeout in milliseconds. Must be greater than zero. If this parameter is omitted or null, 600000 milliseconds (ten minutes) will be used.

{integer} readTimeout Optional, Default: 600000

Optional. Read timeout in milliseconds. Must be greater than zero. If this parameter is omitted or null, 600000 milliseconds (ten minutes) will be used.

Returns:
{String[]}

The data read as an array of strings.


SOASTA CloudTest Script Documentation (build 8744.736). Copyright 2006-2011. All rights reserved.