Skip to content

Writing System Objects

itaiag edited this page Aug 9, 2016 · 1 revision

Writing System Objects

The Following guidelines provide the necessary steps required to write and implement system objects.

  1. The System object class should extend the class jsystem.framework.system.SystemObjectImpl

  2. The “system object” must have a default constructor.

  3. The system object class members should be exposed with setters and getters.

  4. The system object initialization should be implemented in the public void init() throws Exception method. If there is no need for specific system object initialization, do not implement the method. If it is required then call the super.init() method.

  5. The system Object resource release and finalization should be implemented in the public void close() method. If there is no need to finalize a specific system object, do not implement the method. If it is required call the super.close() method.

  6. All system object operations should be exposed as plain public java methods.

  7. As with java objects, system objects can be initialized directly by developer code, in order to enjoy the SUT independence and lifecycle management services let the system instantiate the system object by calling the system.getSystemObject(“name”) method.

Note: The purpose of the system object is to hide the complexity of SUT interaction, enabling test authors the ability to avoid dealing with these complexities. In order to stream line testing operations only expose simple and well documented methods to the user.

System Object Example

package com.aqua.services.demo;
import jsystem.framework.system.SystemObjectImpl;
import com.aqua.sysobj.conn.CliCommand;
import com.aqua.sysobj.conn.CliConnectionImpl;
import com.aqua.sysobj.conn.WindowsDefaultCliConnection;
    
public class SimpleWindowsStation extends SystemObjectImpl {
    private String host;
    private String userName;
    private String password;
    private CliConnectionImpl cliConnection;
    
    public void init() throws Exception {
        super.init();
        cliConnection = new WindowsDefaultCliConnection(getHost(),getUserName(),getPassword());
        cliConnection.init();
        report.step("In init method");
    }
    
    public void close(){
        report.step("In close method");
        cliConnection.close();
        super.close();
    }
    
    public void mkdir(String folderName) throws Exception {
        CliCommand cmd = new CliCommand("mkdir " + folderName);
        cmd.addErrors("unknown command");
        cliConnection.handleCliCommand("created dir " + folderName, cmd);
        setTestAgainstObject(cliConnection.getTestAgainstObject());
    }
    
    public void dir(String folderName) throws Exception {
        CliCommand cmd = new CliCommand("dir " + folderName);
        cmd.addErrors("unknown command");
        cliConnection.handleCliCommand("dir " + folderName, cmd);
        setTestAgainstObject(cmd.getResult());
    }
    
    public void ping(String host) throws Exception {
        CliCommand cmd = new CliCommand("ping " + host);
        cmd.addErrors("unknown command");
        cliConnection.handleCliCommand("ping " + host, cmd);
        setTestAgainstObject(cliConnection.getTestAgainstObject());
    }
    
    public String getHost() {
        return host;
    }
    
    public void setHost(String host) {
        this.host = host;
    }
    
    public String getUserName() {
        return userName;
    }
    
    public void setUserName(String userName) {
        this.userName = userName;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
}
Clone this wiki locally