Skip to content

Monitors

itaiag edited this page Aug 9, 2016 · 1 revision

Monitors

Monitors are processes that are also referred to as threads; these threads are defined per test. The monitor thread process runs during the test execution via a separate thread. The monitor can fail the test if it finds a problem with the monitored object. The monitor thread is a parallel thread to the test itself that enables the user to monitor the device under test (DUT). The service that the framework provides is the ability to control the life cycle of the monitor.

Writing a Monitor

In order to implement a monitor the programmer has to extend the monitor class and implement monitor logic in the run() method.

Monitor Class Code Example

The example illustrates a monitor class; the run method of the monitor class sends a request to the framework for the station system object. The system object then activates a ping operation from the machine represented by the station system object to the address provided by the ping monitor, after performing ping the monitor analyzes ping results.

package com.aqua.services.demo;
import jsystem.framework.monitor.Monitor;
 
public class PingMonitor extends Monitor {
    String pingTo;
    public PingMonitor(String pingTo) {
        super("ping monitor");
        this.pingTo = pingTo;
    }
 
    public void run() {
        WindowsStation station;
        while (true) {
            try {
                station = (WindowsStation)system.getSystemObject("station");
                station.ping(pingTo);
                station.analyze(new FindText(“0% loss”))
                Thread.sleep(1000);
            } catch (Exception e) {
               return;
            }
        }
     }
 }

Clone this wiki locally