La classe JVM_Info richiama la dimensione heap massima della JVM.
package customcode;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
import java.net.*;
/**
* La classe JVM_Info richiama la dimensione heap massima della JVM.
* Scrive un messaggio nel log di test con il nome host dove la
* JVM è in fase di esecuzione e la dimensione heap massima della JVM è espressa in megabyte.
*/
/**
* @author IBM Custom Code Samples
*/
public class JVM_Info implements
com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {
public JVM_Info() {
}
public String exec(ITestExecutionServices tes, String[] args) {
Runtime rt = Runtime.getRuntime();
long maxMB = rt.maxMemory()/(1024*1024); // maxMemory() size is in bytes
String hostName = "Unknown";
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e1) {
tes.getTestLogManager().reportMessage("Can't get hostname");
return null;
}
tes.getTestLogManager().reportMessage("JVM maximum heap size for host "
+ hostName + " is " + maxMB + " MB");
return null;
}
}