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.NetInfo;
import org.hyperic.sigar.NetInterfaceConfig; import org.hyperic.sigar.NetInterfaceConfig;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarPermissionDeniedException;
public class TestNetInfo extends SigarTestCase { public class TestNetInfo extends SigarTestCase {
@ -39,8 +40,14 @@ public class TestNetInfo extends SigarTestCase {
int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP; int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP;
NetConnection[] connections = NetConnection[] connections;
getSigar().getNetConnectionList(flags);
try {
connections =
getSigar().getNetConnectionList(flags);
} catch (SigarPermissionDeniedException e) {
return;
}
for (int i=0; i<connections.length; i++) { for (int i=0; i<connections.length; i++) {
long port = connections[i].getLocalPort(); 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.NetStat;
import org.hyperic.sigar.Sigar; import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException; import org.hyperic.sigar.SigarNotImplementedException;
import org.hyperic.sigar.SigarPermissionDeniedException;
public class TestNetStat extends SigarTestCase { public class TestNetStat extends SigarTestCase {
@ -38,6 +39,8 @@ public class TestNetStat extends SigarTestCase {
netstat = sigar.getNetStat(); netstat = sigar.getNetStat();
} catch (SigarNotImplementedException e) { } catch (SigarNotImplementedException e) {
return; return;
} catch (SigarPermissionDeniedException e) {
return;
} }
traceln(""); traceln("");

View File

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

View File

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