diff --git a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java index 0b5a1c03..1a99debd 100644 --- a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java +++ b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java @@ -3,9 +3,12 @@ package net.hyperic.sigar.test; import java.io.PrintStream; import junit.framework.TestCase; +import net.hyperic.sigar.Sigar; + //helper to add optional tracing. public abstract class SigarTestCase extends TestCase { + private Sigar sigar = null; private static boolean verbose = false; private static PrintStream out = System.out; @@ -13,6 +16,16 @@ public abstract class SigarTestCase extends TestCase { 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) { verbose = value; }