catch SigarPermissionDeniedException

This commit is contained in:
Doug MacEachern 2008-07-14 01:11:05 +00:00
parent aa509c7a83
commit 91925050b6
4 changed files with 18 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import org.hyperic.sigar.NetFlags;
import org.hyperic.sigar.NetInfo;
import org.hyperic.sigar.NetInterfaceConfig;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarPermissionDeniedException;
public class TestNetInfo extends SigarTestCase {
@ -39,8 +40,14 @@ public class TestNetInfo extends SigarTestCase {
int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP;
NetConnection[] connections =
getSigar().getNetConnectionList(flags);
NetConnection[] connections;
try {
connections =
getSigar().getNetConnectionList(flags);
} catch (SigarPermissionDeniedException e) {
return;
}
for (int i=0; i<connections.length; i++) {
long port = connections[i].getLocalPort();

View File

@ -23,6 +23,7 @@ import org.hyperic.sigar.NetFlags;
import org.hyperic.sigar.NetStat;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException;
import org.hyperic.sigar.SigarPermissionDeniedException;
public class TestNetStat extends SigarTestCase {
@ -38,6 +39,8 @@ public class TestNetStat extends SigarTestCase {
netstat = sigar.getNetStat();
} catch (SigarNotImplementedException e) {
return;
} catch (SigarPermissionDeniedException e) {
return;
}
traceln("");

View File

@ -27,6 +27,7 @@ import org.hyperic.sigar.NetInterfaceConfig;
import org.hyperic.sigar.NetStat;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException;
import org.hyperic.sigar.SigarPermissionDeniedException;
public class TestNetStatPort extends SigarTestCase {
@ -45,6 +46,8 @@ public class TestNetStatPort extends SigarTestCase {
netstat = sigar.getNetStat(address.getAddress(), port);
} catch (SigarNotImplementedException e) {
return;
} catch (SigarPermissionDeniedException e) {
return;
}
assertGtEqZeroTrace("AllOutbound", netstat.getAllOutboundTotal());

View File

@ -20,6 +20,7 @@ package org.hyperic.sigar.test;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException;
import org.hyperic.sigar.SigarPermissionDeniedException;
import org.hyperic.sigar.Tcp;
public class TestTcpStat extends SigarTestCase {
@ -36,6 +37,8 @@ public class TestTcpStat extends SigarTestCase {
tcp = sigar.getTcp();
} catch (SigarNotImplementedException e) {
return;
} catch (SigarPermissionDeniedException e) {
return;
}
traceln("");