Framework - catchall package for broadly used methods
Shane P. McCarron <shane@aptest.com>
Copyright 2001-2011 Applied Testing and Technology, Inc. All Rights Reserved.
use Framework ;
my $safe = uri_encode(string)
returns a string with non-portable characters URI-escaped.
my $orig = uri_decode(string);
returns a string with URI-escaped content unescaped.
my $safe = cgi_encode(string)
returns a string with non-portable characters URI-escaped.
my $orig = cgi_decode(string);
returns a string with URI-escaped content unescaped.
my $textOutput = HTMLtoText($string) ;
REReturns output formatted.
my $htmlOutput = textToHTML($string) ;
Returns output marked up as "formatted".
my $safe = shell_encode($string) ;
Returns a string that has non-safe shell chars for the current operating system escaped.
See Report::checkTemplate for documentation.
my $suite = checkSuite(userInfo, suite, select) ;
$version = suiteVersion(suite [, version]) ;
my $status = isSuiteLocked(suite);
my $h = lockSuite(suite) ;
my $status = unlockSuite(suite, handle);
my $clean = csvClean(string) ;
my $out = js_qescape(string) ;
my $out = xml_qdecode(string);
my $out = xml_qencode(string);
my $out = xml_decode(string);
my $out = xml_encode(string) ;
my $token = Framework::authToken ;
Harvests the authentication token from the cookie.
This is actually a no op.
my $path = sandboxDir(suite, session [, testnum [, user]]) ;
my $path = sessionDir(suite, session [, uname]) ;
Returns the path to the session.
my $name = Framework::sessionName($sessNum) ;
Returns a zero-filled name.
my $path = sessionPath(suite, session [, uname]) ;
Returns a path that is usable as a URI.
my $path = testLogDir(suite, session, test [, stamp [, uname]]) ;
stamp is a unique stamp to use (e.g. a time). If it is -1, then an autoincrementing number is assigned.
Returns the path to the directory, creating the directory if needed.
my $path = testLogDir(suite, session, test [, stamp [, uname]]) ;
stamp is a unique stamp to use (e.g. a time). If it is -1, then an autoincrementing number is assigned.
Returns the web path to the directory, creating the directory if needed.
$reference = Framework::fetch(path) ;
Retrieves the data and returns a reference to it. Returns undef if path is not available.
$status = Framework::save(reference, path);
Stores the data identified by reference into the file named by path. The data is portable among systems.
my @list = setGroupList(suite [, setGroup]) ;
suite is the name of a test suite
setGroup is an optional name of a parent set Group. Note that the setGroup name must NOT contain the .grp suffix.
Returns a list of groups at the top level or within the specified setGroup.
my @list = setList(suite [, setGroup]) ;
Returns the list of sets either at the top level or within the specified setGroup.
my @list = allSetList(suite [, group [, includeGroup]]) ;
group is the optional name of a group to search within.
if includeGroup is true, then the group name is included along with the set name. The default for includeGroup is false.
my $json = Framework::getGroupList( suite ) ;
suite - the name of the suite to traverse
Returns a json structure with test set information suitable for use with jsTree
$path = Framework::templateDir(suite, profile) ;
suite is a suite to work with.
profile is a profile to work with.
Returns the path to the template collection for the suite or the profile.
If both suite and profile are defined, returns undef.
$contents = Framework::getTemplate(suite, template, strip, profile);
suite is the name of a suite to load from.
template is the name of the template to load.
strip is a flag that indicates whether to strip off comments or not. Defaults to false.
profile is the name of a profile to operate on instead of a suite.
Returns the contents of the referenced template. Returns undef if the template does not exist. Returns undef if both a suite and a profile are specified.
$path = Framework::templatePath(suite, template[, library]);
suite is the test suite - if undefined, then go to the master templates
template is the template to load
profile is the optional profile from which to load the template. Note that this ONLY applies if suite is not defined.
Automatically references the "REPORTS" subfolder for things that end in ".rpt".
Returns the path to the template file, or undef if the file cannot be found
my $top = absTop() ;
my $dir = imageDir() ;
my $dir = scriptDir() ;
my $dir = setGroupDir(suite, setGroup [, user]) ;
my $dir = testsetDir(suite, set [, user]) ;
my $fname = fullname() ;
my $uname = Framework::username() ;
Returns the username of the current user, or 'ATMuser' if the current user is not defined.
If called with a parameter, and if the current username is not already set, attempts to create a UserInfo object for that user. If that succeeds, the new user information is remembered and the username is returned.
my $uObj = userInfo() ;
my $path = userDir( [name] ) ;
name is the username of a user. If not supplied, defaults to the current user.
Returns a relative path to the private data area for this user. Note that this method is DEPRECATED.
my $status = reqActive(suite [, profile] ) ;
suite is the name of a test suite.
profile is the optional name of a test suite profile to use instead of a test suite.
my $dir = reqDir(suite [, subdir]) ;
my $dir = cacheDir( user, session) ;
my $dir = dataDir( [suite] ) ;
my $tmp = tmpDir() ;
my $webdir = webReqDir(suite [, subdir]) ;
my $path = webSuiteDir(suite) ;
my $tmp = webTmpDir() ;
my @list = getSuiteList() ; my $listRef = getSuiteList() ;
my $list = suiteList(vname, current) ;
vname if the name of a variable to use for the selection list.
current is the current selection, if any.
my $dir = suiteDir( [suite] ) ;
my $fixed = fixName( string ) ;
my $fixed = fixPath(orig) ;
bailOut(error) ;
Does some cleanup, logs the error message, then redirects to the error reporting page.
errorOut(error);
Logs the error, then redirects to the error_message page.
my $time - isoTime(stamp [, needTime [, separator [, needSecs ]]])
stamp is a perl time in seconds since the epoch. If not provided, it defaults to 0.
needTime is a boolean that, if true, means the time should be included as well as the date. If not defined, defaults to false.
separator is the separator to use between components of the time. Defaults to a space.
needSecs is a boolean that, if true, means the seconds are provided with the time. The default is false.
my $time - fmtTime(stamp [, needTime [, separator [, needSecs [, today ]]]])
stamp is a perl time in seconds since the epoch. If not provided, will return "".
needTime is a boolean that, if true, means the time should be included as well as the date. If not defined, defaults to false.
separator is the separator to use between components of the time. Defaults to a space.
needSecs is a boolean that, if true, means the seconds are provided with the time. The default is false.
today is a boolean that, if true, means the day should be omitted if the stamp is today. The default is false.
Returns the date (and time) in the user's timezone.
my $time - fmtTimeThisYear(stamp ) ;
stamp is a perl time in seconds since the epoch. If not provided, it defaults to 0.
Returns the date (and time) in the user's timezone. The year is left off if it is the same as the current year.
Note that the configuration parameter ATMConfig::showYear can be set to override so that the year is ALWAYS displayed.
my $locale = userLocale() ;
my $style = userTimeStyle() ;
my $locale = defaultLocale ;
my $listRef = localeList() ;
my $tz = localTimeZone( [noUser] ) ;
If noUser is true, then return the tz of the server.
my $str = lorem(length) ;
Returns a string of length words based upon the classic lorem ipsum pattern,
$output = error($string)
$output = warning($string)
updateActivityLog(username, message)
note that the suite name and session ID are retrived from the Framework package, and are initialized by the autohandler in the setGlobals sub-component.
logic here: if there is a level 1 problem, put that in the log no matter what.
otherwise, if debugging is turned on to a certain level, only record things below that.
updateLog(level, message)
note that the suite name and session ID are retrived from the Framework package, and are initialized by the autohandler in the setGlobals sub-component.
my $nextItem = Framework::nextID(path [,val] ) ;
path - a directory in which there is a .nextid file.
val - set the value to val
Returns the next incrementable number.
my $status = notify(address, subject, message) ;
($head, $body, $foot) = Framework::parseTemplate(suite, template, stripComments, profile);
returns the portion before any thead, the thead portion, the body portion, and the tfoot portion of the template so they can be used in the various portions of a template driven screen
$status = checkPathLength($path) ;
returns true if it will fit, and false if it will not
Returns 1 if we are, 0 if we are not.
$uuid = Framework::makeUUID();
$res = Framework::compare( ref1, ref2 );
Returns 1 if the data in ref1 matches the data in ref2. Returns 0 otherwise.
$res = Framework::calcPct(num, den, includeSuffix)
num is the numerator of the fraction
den is the denominator of the fraction
includeSuffix is true if the percent suffix should be attached. If not, then the value that is returned is a true integer.
Returns a two digit percentage value. If the denominator is 0 or undefined, returns 00.
Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.