From 224ef34f147069e3b48dff5fb1ee99052ad8ce6f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 11 Nov 2007 16:15:42 +0000 Subject: [PATCH] test ProcCpu.getPercent --- .../java/src/org/hyperic/sigar/test/TestProcTime.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/test/TestProcTime.java b/bindings/java/src/org/hyperic/sigar/test/TestProcTime.java index 24f8c0a4..d0ce5681 100644 --- a/bindings/java/src/org/hyperic/sigar/test/TestProcTime.java +++ b/bindings/java/src/org/hyperic/sigar/test/TestProcTime.java @@ -22,7 +22,7 @@ import java.util.Date; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; -import org.hyperic.sigar.ProcTime; +import org.hyperic.sigar.ProcCpu; public class TestProcTime extends SigarTestCase { @@ -31,14 +31,14 @@ public class TestProcTime extends SigarTestCase { } public void testCreate() throws Exception { - Sigar sigar = new Sigar(); + Sigar sigar = getSigar(); try { sigar.getProcTime(getInvalidPid()); } catch (SigarException e) { } - ProcTime procTime = sigar.getProcTime(sigar.getPid()); + ProcCpu procTime = sigar.getProcCpu(sigar.getPid()); assertGtEqZeroTrace("StartTime", procTime.getStartTime()); traceln("StartDate=" + new Date(procTime.getStartTime())); @@ -51,6 +51,9 @@ public class TestProcTime extends SigarTestCase { assertGtEqZeroTrace("Total", procTime.getTotal()); - sigar.close(); + double value = procTime.getPercent() * 100.0; + traceln("Percent=" + value); + assertTrue(value >= 0.0); + assertTrue(value <= 100.0); } }