org.safs.abbot
Class JVMAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--org.safs.rmi.engine.RemoteRoot
                          |
                          +--org.safs.rmi.engine.AgentImpl
                                |
                                +--org.safs.abbot.JVMAgent
All Implemented Interfaces:
Agent, java.rmi.Remote, java.io.Serializable, SubItemsAgent

public class JVMAgent
extends AgentImpl

This is a concrete extension of a SAFS AgentImpl for Abbot This class is inserted into each JVM by our Bootstrap AgentClassLoader and subsequently communicates with a SAFS localhost RMI server for automated testing.

To insert this class via the AgentClassLoader the following minimum settings must appear in the safsjvmagent.properties file:

safsjvmagent.properties:

See Also:
AgentImpl, ServerImpl, Serialized Form

Inner classes inherited from class org.safs.rmi.engine.AgentImpl
AgentImpl.ServerMonitor, AgentImpl.STAFMonitor
 
Inner classes inherited from class org.safs.rmi.engine.RemoteRoot
RemoteRoot.ShutdownHook
 
Field Summary
static java.lang.String DEFAULT_ABBOT_AGENT
          'SAFSAbbotJVMAgent': Unique Agent remoteType.
 
Fields inherited from class org.safs.rmi.engine.AgentImpl
DEFAULT_RMI_AGENT, DEFAULT_RMI_SERVER, monitor, objID, server, serverName, shutdown, stafHelper, stafmonitor, stafshutdown
 
Fields inherited from class org.safs.rmi.engine.RemoteRoot
_debug, remoteType
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
JVMAgent()
          Constructor for JVMAgent.
 
Method Summary
 java.lang.String getCaption(java.lang.Object object)
          Retrieve the Caption of the object if one exits.
 int getChildCount(java.lang.Object parent)
          Default implementation does nothing at this time.
 java.lang.Object[] getChildren(java.lang.Object parent)
          Default implementation does nothing at this time.
 java.lang.String getClassName(java.lang.Object object)
          Return the class name of the provided object represented as an Integer hashcode previously sent over to the Server object.
protected  java.awt.Component getComponent(java.lang.Integer hashcode)
          Used internally to find the Component matching the stored Integer hashcode.
 java.lang.String getID(java.lang.Object object)
          Retrieve the ID of the object if the object has an ID.
 java.lang.String getName(java.lang.Object object)
          Retrieve the name of the object if the object is named.
 java.lang.String getProperty(java.lang.Object object, java.lang.String property)
          Retrieve the property value of the object if the object has the property.
 java.lang.String[] getPropertyNames(java.lang.Object object)
          Retrieve the list of available properties for the object.
 java.lang.Object getSubItemAtIndex(java.lang.Object object, int index)
          Default no-op simply returns null.
 java.lang.String[] getSuperClassNames(java.lang.Object object)
          Return an Array of the complete superclass hierarchy of the provided object represented as an Integer hashcode previously sent over to the Server object.
 java.lang.String getText(java.lang.Object object)
          Retrieve the displayed text value of the object if the object has a text value.
 int getTopLevelCount()
          Returns the number of Root Windows known to the Abbot WindowTracker or 0 if there are no known Root Windows.
 java.lang.Object[] getTopLevelWindows()
          Return array of Integer hashcodes representing keys to stored ComponentItems.
 boolean isShowing(java.lang.Object object)
          Return true if the specified object is showing/visible.
 boolean isValid(java.lang.Object object)
          Return true if the object is still valid/finadable in the JVM.
 void process(java.lang.Object object, TestRecordData testRecordData)
          An Agent may throw various types of Agent-specific RuntimeExceptions depending upon failure modes.
 void setActiveWindow(java.lang.Object object)
          Return true if the object is still valid/finadable in the JVM.
 
Methods inherited from class org.safs.rmi.engine.AgentImpl
finalize, getAgentID, getAgentName, getLevel, getMatchingPathObject, getStringData, initialize, isMatchingPath, ping, runCommand, shutdown
 
Methods inherited from class org.safs.rmi.engine.RemoteRoot
log, rebindLocalRMIRegistry
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ABBOT_AGENT

public static final java.lang.String DEFAULT_ABBOT_AGENT
'SAFSAbbotJVMAgent': Unique Agent remoteType. Note: Cannot begin with 'SAFS/Abbot' or the SAFS/Abbot engine will not launch due to the implementation of STAFHelper.isToolAvailable().
See Also:
org.safs.STAFHelper#isToolAvailable()
Constructor Detail

JVMAgent

public JVMAgent()
         throws java.rmi.RemoteException
Constructor for JVMAgent.
Throws:
java.rmi.RemoteException -  
Method Detail

getTopLevelCount

public int getTopLevelCount()
                     throws java.rmi.RemoteException,
                            java.lang.Exception
Returns the number of Root Windows known to the Abbot WindowTracker or 0 if there are no known Root Windows.
Overrides:
getTopLevelCount in class AgentImpl
See Also:
Agent.getTopLevelCount()

getTopLevelWindows

public java.lang.Object[] getTopLevelWindows()
                                      throws java.rmi.RemoteException,
                                             java.lang.Exception
Return array of Integer hashcodes representing keys to stored ComponentItems. A zero-length Object array if there are none.
Overrides:
getTopLevelWindows in class AgentImpl
See Also:
Agent.getTopLevelWindows()

getChildCount

public int getChildCount(java.lang.Object parent)
                  throws java.rmi.RemoteException,
                         java.lang.Exception
Description copied from class: AgentImpl
Default implementation does nothing at this time.
Overrides:
getChildCount in class AgentImpl
See Also:
Agent.getChildCount(Object)

getChildren

public java.lang.Object[] getChildren(java.lang.Object parent)
                               throws java.rmi.RemoteException,
                                      java.lang.Exception
Description copied from class: AgentImpl
Default implementation does nothing at this time.
Overrides:
getChildren in class AgentImpl
See Also:
Agent.getChildren(Object)

getComponent

protected java.awt.Component getComponent(java.lang.Integer hashcode)
Used internally to find the Component matching the stored Integer hashcode.
Returns:
Component or null.

getClassName

public java.lang.String getClassName(java.lang.Object object)
                              throws java.rmi.RemoteException,
                                     java.lang.Exception
Return the class name of the provided object represented as an Integer hashcode previously sent over to the Server object.
Overrides:
getClassName in class AgentImpl
See Also:
Agent.getClassName(Object)

getSuperClassNames

public java.lang.String[] getSuperClassNames(java.lang.Object object)
                                      throws java.rmi.RemoteException,
                                             java.lang.Exception
Return an Array of the complete superclass hierarchy of the provided object represented as an Integer hashcode previously sent over to the Server object.
Overrides:
getSuperClassNames in class AgentImpl
See Also:
Agent.getSuperClassNames(Object)

getPropertyNames

public java.lang.String[] getPropertyNames(java.lang.Object object)
                                    throws java.rmi.RemoteException,
                                           java.lang.Exception
Retrieve the list of available properties for the object.
Overrides:
getPropertyNames in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
String[] the names of available properties.

getProperty

public java.lang.String getProperty(java.lang.Object object,
                                    java.lang.String property)
                             throws java.rmi.RemoteException,
                                    java.lang.NoSuchFieldException,
                                    java.lang.Exception
Retrieve the property value of the object if the object has the property.
Overrides:
getProperty in class AgentImpl
Parameters:
object - -- An object from getTopLevelWindows or from a previous call to getChildren.
property - -- the case-sensitive name of the property to seek.
Returns:
String the text value of the object property. Since property values can theoretically legally be zero-length, a null value will be returned if no value exists for the object.

getCaption

public java.lang.String getCaption(java.lang.Object object)
                            throws java.rmi.RemoteException,
                                   java.lang.NoSuchFieldException,
                                   java.lang.Exception
Retrieve the Caption of the object if one exits.
Overrides:
getCaption in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
String the caption of the object.
Throws:
java.lang.NoSuchFieldException - if the object does not provide a caption.

getName

public java.lang.String getName(java.lang.Object object)
                         throws java.rmi.RemoteException,
                                java.lang.NoSuchFieldException,
                                java.lang.Exception
Retrieve the name of the object if the object is named.
Overrides:
getName in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
String the name of the object.
Throws:
java.lang.NoSuchFieldException - if the object does not provide a name.

getID

public java.lang.String getID(java.lang.Object object)
                       throws java.rmi.RemoteException,
                              java.lang.NoSuchFieldException,
                              java.lang.Exception
Retrieve the ID of the object if the object has an ID.
Overrides:
getID in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
String the ID of the object.
Throws:
java.lang.NoSuchFieldException - if the object does not provide an ID.

getText

public java.lang.String getText(java.lang.Object object)
                         throws java.rmi.RemoteException,
                                java.lang.Exception
Retrieve the displayed text value of the object if the object has a text value.
Overrides:
getText in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
String the text value of the object. Since text values can theoretically legally be zero-length, a null value will be returned if no value exists for the object.

isShowing

public boolean isShowing(java.lang.Object object)
                  throws java.rmi.RemoteException,
                         java.lang.Exception
Return true if the specified object is showing/visible.
Overrides:
isShowing in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
boolean

isValid

public boolean isValid(java.lang.Object object)
                throws java.rmi.RemoteException,
                       java.lang.Exception
Return true if the object is still valid/finadable in the JVM.
Overrides:
isValid in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
boolean true if the object is still valid/findable.

setActiveWindow

public void setActiveWindow(java.lang.Object object)
                     throws java.rmi.RemoteException,
                            java.lang.Exception
Return true if the object is still valid/finadable in the JVM.
Overrides:
setActiveWindow in class AgentImpl
Parameters:
object - An object from getTopLevelWindows or from a previous call to getChildren.
Returns:
boolean true if the object is still valid/findable.

process

public void process(java.lang.Object object,
                    TestRecordData testRecordData)
             throws java.rmi.RemoteException,
                    java.lang.Exception
An Agent may throw various types of Agent-specific RuntimeExceptions depending upon failure modes. A Server should catch the RemoteException and Exception but test for subclasses of RuntimeException and possibly let them through.
Overrides:
process in class AgentImpl
Throws:
SAFSObjectNotFoundRuntimeException - if the specified Object is not found to exist in the JVM.
See Also:
Agent.process(Object,TestRecordData)

getSubItemAtIndex

public java.lang.Object getSubItemAtIndex(java.lang.Object object,
                                          int index)
                                   throws java.rmi.RemoteException,
                                          java.lang.Exception
Description copied from class: AgentImpl
Default no-op simply returns null. Implementation must be completed in subclasses.
Overrides:
getSubItemAtIndex in class AgentImpl
Parameters:
object - reference (Integer) from which to locate the subitem.
index - of the subitem to retrieve.
Returns:
subitem object or String
Throws:
java.lang.IndexOutOfBoundsException - if index is invalid
SAFSObjectNotFoundException - if subitem at index cannot be retrieved or if the specified object itself cannot be found.
SAFSSubItemsAgentUnsupportedException - as necessay.
See Also:
SubItemsAgent.getSubItemAtIndex(Object,int)