avignon
Class AvignonTestState

java.lang.Object
  extended byavignon.AvignonTestState
Direct Known Subclasses:
ShuntedTestState

public class AvignonTestState
extends java.lang.Object

Maintains state information through the life of a test script file.


Constructor Summary
AvignonTestState()
          Constructs an instance with no tags on the stack.
AvignonTestState(AvignonTagHandler[] handlers)
          Constructs an instance with an initial tag stack.
 
Method Summary
 boolean anyErrors()
          Checks if there are any errors for any tests in the current error log.
 boolean anyErrorsForTest(java.lang.String testName)
          Determines if any errors have been appended to the error log for the given test.
 void appendErrorMessage(java.lang.String message)
          Appends the current test name and the given message to the error log.
 void appendErrorMessage(java.lang.Throwable exception)
          Appends the current test name and the stack trace of the given exception to the error log.
 void closeApplication()
          Deprecated. Deprecated in favor of keeping the application in a handler.
 java.awt.Frame getApplication()
          Deprecated. Deprecated in favor of keeping the application in a handler.
protected  java.lang.String getAppStart()
          Deprecated. Deprecated in favor of having individual tags to start the different kinds of applications.
 com.meterware.httpunit.WebRequest getCurrentFormRequest()
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 org.w3c.dom.Document getCurrentResponse()
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 java.lang.String getErrorMessages()
          Returns the text of the current error log.
 com.meterware.httpunit.WebRequest getFormRequest(java.lang.String frameName, java.lang.String button, java.lang.String value)
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 org.w3c.dom.Document getFrameContents(java.lang.String frame)
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 java.lang.String getPageDescriptionDirectory()
          Returns the directory in which to look for page descriptions.
 AvignonTagHandler getStackTop()
           
 java.lang.String getTestName()
          Returns the current test name.
 void initializeApplication()
          Deprecated. Deprecated in favor of keeping the application in a handler.
 java.lang.String loadPageFromItemClick(java.lang.String frame, java.lang.String linkText)
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 java.lang.String loadPageFromPageClick(java.lang.String itemText)
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 AvignonTagHandler peek(java.lang.Class target)
          Searches the element stack for a handler to which the target is assignable.
 AvignonTagHandler[] peekAll(java.lang.Class target)
          Finds all the handlers on the stack that are instances of the given class.
protected  void pop()
           
protected  void push(AvignonTagHandler handler, org.xml.sax.Attributes attributes)
          Pushes an AvignonTagHandler onto the element stack.
 void setTestName(java.lang.String value)
          Sets the current test name.
 java.lang.String submitRequest(com.meterware.httpunit.WebRequest request)
          Deprecated. Deprecated in favor of the avignon.handlers.browser classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvignonTestState

public AvignonTestState()
Constructs an instance with no tags on the stack.


AvignonTestState

public AvignonTestState(AvignonTagHandler[] handlers)
Constructs an instance with an initial tag stack. Only used for unit testing.

Parameters:
handlers - The handlers that will be on the stack at construction. The first element is at the bottom of the stack.
Method Detail

peekAll

public AvignonTagHandler[] peekAll(java.lang.Class target)
Finds all the handlers on the stack that are instances of the given class. Can be used by handlers written in different languages to get a set of handlers to search. (See the peek operation in Avignon.NET, for example.)

Parameters:
target - The class of handler for which to search.
Returns:
An array (possibly empty) of AvignonTagHandlers that are instances of the given Class. Lower indicies are higher on the stack (i.e., will be peeked first).

anyErrorsForTest

public boolean anyErrorsForTest(java.lang.String testName)
Determines if any errors have been appended to the error log for the given test.

Parameters:
testName - Name of the test to search for.
Returns:
True if any errors exist for the specified test.

initializeApplication

public void initializeApplication()
Deprecated. Deprecated in favor of keeping the application in a handler.

Loads the web page or Java application defined by the AppStart property.


getAppStart

protected java.lang.String getAppStart()
Deprecated. Deprecated in favor of having individual tags to start the different kinds of applications.

Gets the value of the AppStart property.

Returns:
The value of the AppStart property in the current avignon.properties file.

closeApplication

public void closeApplication()
Deprecated. Deprecated in favor of keeping the application in a handler.

Disposes of the Frame if using a Java application.


getApplication

public java.awt.Frame getApplication()
Deprecated. Deprecated in favor of keeping the application in a handler.

Returns the Java application currently being tested.

Returns:
The Java application currently being tested or null if another type of application is being tested.

appendErrorMessage

public void appendErrorMessage(java.lang.String message)
Appends the current test name and the given message to the error log.

Parameters:
message - Text of the message to be appended.

appendErrorMessage

public void appendErrorMessage(java.lang.Throwable exception)
Appends the current test name and the stack trace of the given exception to the error log.

Parameters:
exception - Exception to append to the error output.

anyErrors

public boolean anyErrors()
Checks if there are any errors for any tests in the current error log.

Returns:
True if any errors at all have been recorded in this test state.

getErrorMessages

public java.lang.String getErrorMessages()
Returns the text of the current error log.

Returns:
The full text of all error messages that have been added to this instance.

getTestName

public java.lang.String getTestName()
Returns the current test name.

Returns:
The name of the test currently being run.

setTestName

public void setTestName(java.lang.String value)
Sets the current test name.

Parameters:
value - The name to use for the current test.

push

protected void push(AvignonTagHandler handler,
                    org.xml.sax.Attributes attributes)
Pushes an AvignonTagHandler onto the element stack. Generally used for unit testing. Should not be used directly in production code unless you're writing a new acceptance test parser. Pushing an element onto the stack causes the handler's start method to be called after the handler is pushed onto the physical stack.

Parameters:
attributes - The attributes to pass to the handler's start method.
handler - The handler to push onto the stack.

getStackTop

public AvignonTagHandler getStackTop()

pop

protected void pop()

peek

public AvignonTagHandler peek(java.lang.Class target)
Searches the element stack for a handler to which the target is assignable. Throws an exception if no handler is found that could be assigned to the target class.

Parameters:
target -
Returns:

loadPageFromPageClick

public java.lang.String loadPageFromPageClick(java.lang.String itemText)
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Clicks a link in the _top frame.

Parameters:
itemText - Text of the link to click.
Returns:
Text of the resulting page.

loadPageFromItemClick

public java.lang.String loadPageFromItemClick(java.lang.String frame,
                                              java.lang.String linkText)
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Clicks a link in the given frame.

Parameters:
frame - Frame in which to search for the link.
linkText - Text of the link to click.
Returns:
Text of the resulting page.

getCurrentFormRequest

public com.meterware.httpunit.WebRequest getCurrentFormRequest()
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Gets a web request for the form in the _top frame.

Returns:

getFormRequest

public com.meterware.httpunit.WebRequest getFormRequest(java.lang.String frameName,
                                                        java.lang.String button,
                                                        java.lang.String value)
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Gets a web request.

Parameters:
frameName - Name of the frame in which to search for the form.
button - Name of the submit button used on the form.
value - Value to use for the submit button.
Returns:

submitRequest

public java.lang.String submitRequest(com.meterware.httpunit.WebRequest request)
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Submits a web request, returning the resulting page.

Parameters:
request - Request to submit.
Returns:
Text of the resulting page.

getPageDescriptionDirectory

public java.lang.String getPageDescriptionDirectory()
Returns the directory in which to look for page descriptions.

Returns:

getCurrentResponse

public org.w3c.dom.Document getCurrentResponse()
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Gets a Document of the current page.

Returns:

getFrameContents

public org.w3c.dom.Document getFrameContents(java.lang.String frame)
Deprecated. Deprecated in favor of the avignon.handlers.browser classes.

Gets the Document of a named frame.

Parameters:
frame - Name of the frame whose Document is desired.
Returns:

SourceForge.net Logo