public class GenericEngine extends DriverConfiguredSTAFInterfaceClass implements EngineInterface, RuntimeDataInterface, ITestRecordStackable
Modifier and Type | Field and Description |
---|---|
protected GenericProcessConsole |
console
The Console handling IO streams for the engine process.
|
protected java.lang.Process |
process
The Java Process running the engine.
|
protected TestRecordHelper |
testRecordData
Stores the data on the input record we are to process.
|
protected ITestRecordStackable |
testrecordStackable
The ITestRecordStackable used to store 'Test Record' in a FILO.
|
config, customStr, customText, debugStr, debugText, driver, DRIVER_TEMP_PROCESS, failedStr, failedText, genericStr, genericText, launchCount, log, machine, otherStr, otherText, passedStr, passedText, processName, running, SAFS_RESBUN_NAME, servicename, shutdownCount, staf, STAFPROC_EXE, warningStr, warningText, weStartedService, weStartedSTAF
COMMAND_SHUTDOWN_HOOK
Constructor and Description |
---|
GenericEngine()
Constructor for GenericEngine
|
Modifier and Type | Method and Description |
---|---|
protected java.io.File |
deduceBenchFile(java.lang.String filename)
Deduce the absolute full path bench file name.
|
protected java.io.File |
deduceProjectFile(java.lang.String filename)
Deduce the absolute full path to a project-relative file.
|
protected java.io.File |
deduceTestFile(java.lang.String filename)
Deduce the absolute full path test file name.
|
java.lang.String |
getAppMapItem(java.lang.String appMapId,
java.lang.String sectionName,
java.lang.String itemName)
Retrieve the resolved value of an item stored in the App Map chain (SAFSMAPS).
|
java.lang.String |
getEngineName()
Retrieve the name of the Engine.
|
java.lang.String |
getVariable(java.lang.String var)
Retrieve the current runtime value of the global variable (SAFSVARS).
|
boolean |
isToolRunning()
Verifies a STAF tool matching our engine name is running.
|
void |
launchInterface(java.lang.Object configInfo)
Typically expects a DriverInterface object for initialization.
|
protected void |
logMessage(java.lang.String msg,
java.lang.String msgdescription,
int msgtype)
Convenience routine for building the appropriate MessageInfo and logging
a message to our active log.
|
protected java.lang.String |
makeQuotedPath(java.lang.String path,
boolean isFile)
Wraps valid file path in double-quotes if necessary.
|
protected java.lang.String |
makeQuotedString(java.lang.String text)
Wraps the privided text in double-quotes *if* the text contains a space.
|
TestRecordData |
popTestRecord()
Retrieve the Test-Record from the the Stack after the execution of a keyword.
|
protected void |
postShutdownServiceDelay()
Called internally by
shutdownService(String) . |
long |
processRecord(TestRecordHelper testRecordData)
Initiate the event-driven protocol to send the test record to the engine.
|
void |
pushTestRecord(TestRecordData trd)
Push the current 'test record' into the Stack before the execution of a keyword.
|
void |
reset()
Reset or clear any cached information in the underlying tool or service.
|
protected boolean |
resetShutdownSemaphore()
This method is intended to reset the "shutdown" semaphore post hook when it stops.
|
protected java.lang.String |
saveTestRecordScreenToTestDirectory(TestRecordData testRecordData)
Normally called on failure to execute an IBT command.
|
protected long |
setTRDStatus(TestRecordHelper trd,
long status)
Sets TRD statuscode to the provided status and returns the same.
|
boolean |
setVariable(java.lang.String var,
java.lang.String val)
Set a new runtime value of a global variable (SAFSVARS).
|
protected void |
shutdownService(java.lang.String aname)
Shutdown the Engine.
|
protected void |
waitHookShutdownAndReset(int timeoutInSeconds)
Called internally by
shutdownService(String) . |
configureJSTAFServiceEmbeddedJVMOption, extendedGenericMessage, finalize, getCoreInterface, getEmbeddedJVMBinPath, getSTAFHelper, logMessage, setLogUtilities, setLogUtilities, shutdown, simpleGenericMessage, simpleGenericSuccessMessage, simpleGenericWarningMessage, simpleSuccessMessage, simpleSuccessMessage, simpleSuccessUsingMessage, standardErrorMessage, waitForServiceStartCompletion
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCoreInterface, shutdown
protected java.lang.Process process
protected GenericProcessConsole console
protected TestRecordHelper testRecordData
protected ITestRecordStackable testrecordStackable
protected void logMessage(java.lang.String msg, java.lang.String msgdescription, int msgtype)
AbstractLogFacility
public java.lang.String getEngineName()
EngineInterface
getEngineName
in interface EngineInterface
EngineInterface.getEngineName()
public long processRecord(TestRecordHelper testRecordData)
processRecord
in interface EngineInterface
EngineInterface#processRecord()
public void launchInterface(java.lang.Object configInfo)
launchInterface
in interface ConfigurableToolsInterface
launchInterface
in class DriverConfiguredSTAFInterfaceClass
configInfo
- can be whatever the final implementation needs it to be. This
might be a String with configuration information, the name of a class, or an instance
of some object used to provide configuration assets.DriverConfiguredSTAFInterfaceClass.launchInterface(Object)
,
DriverInterface
public boolean isToolRunning()
isToolRunning
in interface GenericToolsInterface
isToolRunning
in class DriverConfiguredSTAFInterfaceClass
GenericToolsInterface.isToolRunning()
protected java.lang.String makeQuotedString(java.lang.String text)
protected java.lang.String makeQuotedPath(java.lang.String path, boolean isFile)
path
- to file or directory. Can be relative to the project root directory.isFile
- true if the path should be a file, instead of a directory.protected long setTRDStatus(TestRecordHelper trd, long status)
public void reset()
GenericToolsInterface
reset
in interface GenericToolsInterface
GenericToolsInterface.reset()
protected java.lang.String saveTestRecordScreenToTestDirectory(TestRecordData testRecordData)
the
- testRecordData containing the test FileID and test LineNumber for unique image naming.protected void shutdownService(java.lang.String aname)
All official engines conform to the "SHUTDOWN_HOOK" TestRecordData method to initiate shutdown. So, this function rarely needs to be overridden.
Following the confirmation that the service or engine is no longer 'running',
this implementation will call postShutdownServiceDelay()
which is intended
to allow subclasses to delay final shutdown of the process by an arbitrary length
of time while internal shutdown activities are completed.
This implementation then resets "running" to false.
Unregistering staf and nulling superclass objects occurs in the finalize() method of the superclass.
shutdownService
in class DriverConfiguredSTAFInterfaceClass
aname
- is not used directly in this implementation.DriverConfiguredSTAFInterfaceClass.shutdownService(String)
protected void waitHookShutdownAndReset(int timeoutInSeconds)
shutdownService(String)
.
This method is intended to wait for the "shutdown" semaphore post by hook when it stops, then try to reset the "shutdown" semaphore. If we don't reset the "shutdown" semaphore, the driver may see this semaphore and consider that the hook is shutdown and return to try other engine/hook. This method can only try its best to reset "shutdown" semaphore, but this is not guaranteed.
timeoutInSeconds,
- int, the timeout in seconds to wait for the "shutdown" semaphoreprotected boolean resetShutdownSemaphore()
This method is intended to reset the "shutdown" semaphore post hook when it stops. Before we reset the "shutdown" semaphore, we should test the condition for resetting. The condition is that only "shutdown" is "posted", the others are "reset".
protected void postShutdownServiceDelay()
shutdownService(String)
.
This method is intended to allow subclasses to delay final shutdown of the process by an arbitrary length of time while internal shutdown activities are completed.
This default implementation provides no delay and immediately returns.
public boolean setVariable(java.lang.String var, java.lang.String val) throws SAFSException
RuntimeDataInterface
setVariable
in interface RuntimeDataInterface
var
- -- Variable names are NOT case-sensitive.val
- -- value to set. Can be an empty string.SAFSException
public java.lang.String getVariable(java.lang.String var) throws SAFSException
RuntimeDataInterface
getVariable
in interface RuntimeDataInterface
var
- -- Variable names are NOT case-sensitive.SAFSException
protected java.io.File deduceTestFile(java.lang.String filename) throws SAFSException
filename,
- String, the test file name.SAFSException
#deduceFile(String, int)}
protected java.io.File deduceBenchFile(java.lang.String filename) throws SAFSException
filename,
- String, the bench file name.SAFSException
#deduceFile(String, int)}
protected java.io.File deduceProjectFile(java.lang.String filename) throws SAFSException
filename,
- String, the test file name. The path is ALWAYS considered relative
to the project root directory regardless of the absence or presence of File.separators
unless the file is already an absolute path.SAFSException
#deduceFile(String, int)}
public java.lang.String getAppMapItem(java.lang.String appMapId, java.lang.String sectionName, java.lang.String itemName) throws SAFSException
RuntimeDataInterface
getAppMapItem
in interface RuntimeDataInterface
appMapId
- -- can be null to get from the "default/current" app map.sectionName
- -- section names are NOT case-sensitive.itemName
- -- item names are NOT case-sensitive.SAFSException
public void pushTestRecord(TestRecordData trd)
Push the current 'test record' into the Stack before the execution of a keyword. This should be called after the 'test record' is properly set.
pushTestRecord
in interface ITestRecordStackable
trd
- TestRecordData, the test record to push into a stackpopTestRecord()
public TestRecordData popTestRecord()
After execution of a keyword, pop the test record from Stack and return is as the result. Replace the class field 'Test Record' by that popped from the stack if they are not same.
popTestRecord
in interface ITestRecordStackable
#pushTestRecord()
Copyright © SAS Institute. All Rights Reserved.