A ComputerSpecific osztály megállapítja, hol fut egy teszt
package customcode;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* A ComputerSpecific megállapítja a hosztnevet, amelyen a teszt fut, beírja
* üzenetként a hosztnevet és IP címet a tesztnaplóba, és a hosztnév alapján
* különféle karaktersorozatokat ad vissza.
*/
/**
* @author IBM Custom Code Samples
*/
public class ComputerSpecific implements
com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {
/**
* Ennek példányai a no-arg konstruktor használatával kerülnek létrehozásra.
*/
public ComputerSpecific() {
}
public String exec(ITestExecutionServices tes, String[] args) {
String hostName = "Unknown";
String hostAddress = "Unknown";
try {
hostName = InetAddress.getLocalHost().getHostName();
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
tes.getTestLogManager().reportMessage(
"Hosztinformációk nem kérhetők le");
return null;
}
tes.getTestLogManager().reportMessage("A hosztnév: " + hostName +
"; IP cím: " + hostAddress);
if (hostName.equals("host-1234"))
return "Special";
else
return "Normal";
}
}