add getSigar method that enables logging if verbose

This commit is contained in:
Doug MacEachern 2004-07-06 01:12:06 +00:00
parent 579cb164af
commit 99cc7b2f68
1 changed files with 13 additions and 0 deletions

View File

@ -3,9 +3,12 @@ package net.hyperic.sigar.test;
import java.io.PrintStream; import java.io.PrintStream;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.hyperic.sigar.Sigar;
//helper to add optional tracing. //helper to add optional tracing.
public abstract class SigarTestCase extends TestCase { public abstract class SigarTestCase extends TestCase {
private Sigar sigar = null;
private static boolean verbose = false; private static boolean verbose = false;
private static PrintStream out = System.out; private static PrintStream out = System.out;
@ -13,6 +16,16 @@ public abstract class SigarTestCase extends TestCase {
super(name); super(name);
} }
public Sigar getSigar() {
if (this.sigar == null) {
this.sigar = new Sigar();
if (getVerbose()) {
this.sigar.enableLogging(true);
}
}
return this.sigar;
}
public static void setVerbose(boolean value) { public static void setVerbose(boolean value) {
verbose = value; verbose = value;
} }