diff --git a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java index 8c07e12b..d65be791 100644 --- a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java +++ b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java @@ -80,6 +80,10 @@ public abstract class SigarTestCase extends TestCase { return out; } + public long getInvalidPid() { + return 666666; + } + public void traceln(String msg) { if (getVerbose()) { getWriter().println(msg); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java b/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java index eaa46b77..cee57fd8 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java @@ -1,6 +1,7 @@ package net.hyperic.sigar.test; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarNotImplementedException; public class TestProcArgs extends SigarTestCase { @@ -28,6 +29,11 @@ public class TestProcArgs extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcArgs(getInvalidPid()); + } catch (SigarException e) { + } + try { String[] args = sigar.getProcArgs(sigar.getPid()); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcEnv.java b/bindings/java/src/net/hyperic/sigar/test/TestProcEnv.java index 79b37e2c..74143c8d 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcEnv.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcEnv.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.Map; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarNotImplementedException; public class TestProcEnv extends SigarTestCase { @@ -15,6 +16,11 @@ public class TestProcEnv extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcEnv(getInvalidPid()); + } catch (SigarException e) { + } + long pid = sigar.getPid(); try { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java b/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java index 14b41fb9..65e7ef85 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java @@ -3,6 +3,7 @@ package net.hyperic.sigar.test; import java.io.File; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.ProcExe; import net.hyperic.sigar.SigarNotImplementedException; @@ -15,6 +16,11 @@ public class TestProcExe extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcExe(getInvalidPid()); + } catch (SigarException e) { + } + try { ProcExe exe = sigar.getProcExe(sigar.getPid()); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcFd.java b/bindings/java/src/net/hyperic/sigar/test/TestProcFd.java index d44008a3..1aaf5e7f 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcFd.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcFd.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileInputStream; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarLoader; import net.hyperic.sigar.SigarNotImplementedException; @@ -16,6 +17,11 @@ public class TestProcFd extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcFd(getInvalidPid()); + } catch (SigarException e) { + } + try { long pid = sigar.getPid(); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java b/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java index 101b2c0f..7b5a20bf 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcMem.java @@ -1,6 +1,7 @@ package net.hyperic.sigar.test; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.ProcMem; public class TestProcMem extends SigarTestCase { @@ -12,6 +13,11 @@ public class TestProcMem extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcMem(getInvalidPid()); + } catch (SigarException e) { + } + ProcMem procMem = sigar.getProcMem(sigar.getPid()); assertTrue(procMem.getSize() > 0); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcModules.java b/bindings/java/src/net/hyperic/sigar/test/TestProcModules.java index 0b6fc763..2c690ab3 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcModules.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcModules.java @@ -30,6 +30,11 @@ public class TestProcModules extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + printModules(sigar, getInvalidPid()); + } catch (SigarException e) { + } + try { printModules(sigar, sigar.getPid()); } catch (SigarNotImplementedException e) { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcStat.java b/bindings/java/src/net/hyperic/sigar/test/TestProcStat.java index 53aeb02f..7bcb3bdc 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcStat.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcStat.java @@ -1,6 +1,7 @@ package net.hyperic.sigar.test; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.ProcStat; public class TestProcStat extends SigarTestCase { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcState.java b/bindings/java/src/net/hyperic/sigar/test/TestProcState.java index 24f6d0d9..ef844183 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcState.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcState.java @@ -1,6 +1,7 @@ package net.hyperic.sigar.test; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.ProcState; public class TestProcState extends SigarTestCase { @@ -12,6 +13,11 @@ public class TestProcState extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); + try { + sigar.getProcState(getInvalidPid()); + } catch (SigarException e) { + } + ProcState procState = sigar.getProcState(sigar.getPid()); assertTrue(procState.getState() == 'R'); diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java b/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java index 937f2b47..6977ad2d 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java @@ -1,6 +1,7 @@ package net.hyperic.sigar.test; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; import net.hyperic.sigar.ProcTime; public class TestProcTime extends SigarTestCase { @@ -12,6 +13,11 @@ public class TestProcTime extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = new Sigar(); + try { + sigar.getProcTime(getInvalidPid()); + } catch (SigarException e) { + } + ProcTime procTime = sigar.getProcTime(sigar.getPid()); assertGtEqZeroTrace("StartTime", procTime.getStartTime());