Determine where a test is running
The ComputerSpecific class determines where a test is running
package customcode; import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices; import java.net.InetAddress; import java.net.UnknownHostException; /** * The ComputerSpecific class determined the hostname on which the test is * running, prints the hostname and IP address as a message in the test log, * and returns different strings based on the hostname. */ /** * @author IBM Custom Code Samples */ public class ComputerSpecific implements com.ibm.rational.test.lt.kernel.custom.ICustomCode2 { /** * Instances of this will be created using the no-arg constructor. */ 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( "Not able to obtain host information"); return null; } tes.getTestLogManager().reportMessage("The hostname is " + hostName + "; IP address is " + hostAddress); if (hostName.equals("host-1234")) return "Special"; else return "Normal"; }}
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.