Follow these steps:
lisa-core-8.0.0.jar).
This tells the DevTest Solutions that your class is a custom Java test step.
public class FTPCustJavaNode implements CustJavaNodeInterface { }
This method is called when the DevTest first loads a custom test step during testing.
In this example, the test step needs no initialization, so it simply logs the fact that the initialize method was called.
static protected Log cat = LogFactory.getLog( "com.mycompany.lisa.ext.node.FTPCustJavaNode" ); public void initialize( TestCase test, Element node ) throws TestDefException { cat.debug( "called initialize" ); }
This method specifies the name-value pairs that define the parameters to the custom test step. The simplest way to define the parameter list is to pass one long string of all parameters, with each parameter separated by an ampersand (&). Values that are specified here are used as the default values when the node is defined in the model editor.
public ParameterList getParameters() { ParameterList pl = new ParameterList( "username=&password=&host=ftp.suse.com&path=/pub&file=INDEX" ); return pl; }
The previous example uses ftp.suse.com/pub/INDEX as the file to retrieve. This is a publicly available FTP host that allows an anonymous login. Limit unnecessary hits on the SuSE FTP site.
This method defines the logic that runs when the test step executes. Typically, this method is used to instantiate and validate components of the system under test.
The TestExec parameter provides access to the test environment, such as logs and events. The Map parameter provides access to the current value of the test step parameters. The Object return type allows you to pass data back to the running test, so that you can run assertions and filters on it.
public Object executeNodeLogic( TestExec ts, Map params ) throws TestRunException { ts.log( "We got called with: " + params.toString() ); String host = (String)params.get("host"); String username = (String)params.get("username"); String password = (String)params.get("password"); String path = (String)params.get("path"); String file = (String)params.get("file"); String storedFile = runFTP(ts,host,username,password,path,file); FileDataObject fdo = new FileDataObject(storedFile); return fdo; }
Using a custom data object for the return value is common. This strategy has two benefits:
The previous code uses the FileDataObject custom data object to store only the path to the stored file, rather than passing an open File or FileInputStream. Any filter can perform conditional processing by checking that the type of the result object is FileDataObject.
Copyright © 2014 CA Technologies.
All rights reserved.
|
|