From 99cc7b2f6871fc0bf7a5b0c516da21b36ab26ecb Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 6 Jul 2004 01:12:06 +0000 Subject: [PATCH] add getSigar method that enables logging if verbose --- .../src/net/hyperic/sigar/test/SigarTestCase.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; }