org.apache.anteater.test.log
Class LoggerUtils

java.lang.Object
  |
  +--org.apache.anteater.test.log.LoggerUtils

public class LoggerUtils
extends Object

Utility code for use by Loggers.

Version:
$Revision: 1.9 $ $Date: 2003/03/09 15:33:12 $
Author:
Jeff Turner
See Also:
XMLLogger

Field Summary
static String FQCN
          Variable containing fully qualified classname of current task, e.g.
static String GROUP_ID
          Variable containing the 'group identifier', eg 'default', in filesystem-friendly form.
static String GROUP_ID_RAW
          Variable containing the 'group identifier', eg 'default', in unescaped form.
static String LINE_NUM
          Variable containing line number of task that generated this log entry
static String RAW_URL
          "raw-url" Variable containing unmodified request URL, e.g.
static String RAW_URL_NOPARAMS
          Variable containing request URL with request params stripped, e.g.
static String RUN
          Variable containing a counter that ensures the current filename will be unique within its directory.
static String TASKNAME
          "taskname" variable containing name of currently running Task, e.g.
static String URL
          Variable containing a filesystem-friendly rendition of the request URL, minus the request params.
static String VM_COUNT
          Variable containing a counter unique within this Java Virtual Machine.
 
Constructor Summary
LoggerUtils()
           
 
Method Summary
static String baseName(String path)
          Return the file part of a URL.
static int findNextRunCount(File baseDir, Map map, String filenameTemplate)
          Look on the filesystem in directory baseDir for files with a ${run} value of [counter], and return [counter+1].
static Map getAttributes(ActionTask task)
           
static String getPathId(ActionTask task)
          Return a String identification for this HTTP action suitable for inclusion in a filename.
static String makePath(String id)
          Returns a filesystem-friendly equivalent of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_NUM

public static final String LINE_NUM
Variable containing line number of task that generated this log entry

See Also:
Constant Field Values

FQCN

public static final String FQCN
Variable containing fully qualified classname of current task, e.g. org.apache.anteater.test.HttpRequest

See Also:
Constant Field Values

TASKNAME

public static final String TASKNAME
"taskname" variable containing name of currently running Task, e.g. HttpRequest

See Also:
Constant Field Values

RAW_URL

public static final String RAW_URL
"raw-url" Variable containing unmodified request URL, e.g. http://foo.com/server?a=b

See Also:
Constant Field Values

RAW_URL_NOPARAMS

public static final String RAW_URL_NOPARAMS
Variable containing request URL with request params stripped, e.g. http://foo.com/server

See Also:
Constant Field Values

VM_COUNT

public static final String VM_COUNT
Variable containing a counter unique within this Java Virtual Machine. Used to ensure uniqueness for looping test outputs.

See Also:
Constant Field Values

URL

public static final String URL
Variable containing a filesystem-friendly rendition of the request URL, minus the request params. Eg. http___www_bibleportalproject_com_cgi_xml_p8_php

See Also:
Constant Field Values

GROUP_ID_RAW

public static final String GROUP_ID_RAW
Variable containing the 'group identifier', eg 'default', in unescaped form.

See Also:
Constant Field Values

GROUP_ID

public static final String GROUP_ID
Variable containing the 'group identifier', eg 'default', in filesystem-friendly form.

See Also:
Constant Field Values

RUN

public static final String RUN
Variable containing a counter that ensures the current filename will be unique within its directory. Prevents multiple runs of an Anteater script from overwriting a single output file.

See Also:
Constant Field Values
Constructor Detail

LoggerUtils

public LoggerUtils()
Method Detail

getPathId

public static String getPathId(ActionTask task)
Return a String identification for this HTTP action suitable for inclusion in a filename. This is used by the Logger classes to create a log file for each ActionTask.

Parameters:
task - ActionTask to get path id of.
Returns:
A filesystem-safe String that uniquely identifies this instance and invocation of an ActionTask. Currently, string is of the form [task classname].[task url (no params)][count]_line_[task location line num]

getAttributes

public static Map getAttributes(ActionTask task)

findNextRunCount

public static int findNextRunCount(File baseDir,
                                   Map map,
                                   String filenameTemplate)
Look on the filesystem in directory baseDir for files with a ${run} value of [counter], and return [counter+1].

Parameters:
baseDir - log directory
map - Map of attributes for the filenameTemplate
filenameTemplate - A template filename, with uninterpreted ${variables}, one of them being ${run} or ${prefix:run}
Returns:
A counter, such that if the ${run} variable in the template were replaced with it, the filename would be unique within baseDir

makePath

public static String makePath(String id)
Returns a filesystem-friendly equivalent of a string.

Returns:
A string that could safely be used as a filesystem or URL path.

baseName

public static String baseName(String path)
Return the file part of a URL. Eg, given "/home/jeff/test.xml:123", will return "test.xml:123"

Parameters:
path - a File system path string, typically from Task.getLocation()


Ant Functional Tester -- see Project home page for details