test stuff

This commit is contained in:
Doug MacEachern 2007-04-06 14:03:29 +00:00
parent 4a9e360914
commit 84f5dd1ca5
2 changed files with 18 additions and 17 deletions

View File

@ -18,7 +18,10 @@
package org.hyperic.sigar.test; package org.hyperic.sigar.test;
import org.hyperic.sigar.NetConnection;
import org.hyperic.sigar.NetFlags;
import org.hyperic.sigar.NetInfo; import org.hyperic.sigar.NetInfo;
import org.hyperic.sigar.NetInterfaceConfig;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
public class TestNetInfo extends SigarTestCase { public class TestNetInfo extends SigarTestCase {
@ -29,5 +32,20 @@ public class TestNetInfo extends SigarTestCase {
public void testNetInfo() throws SigarException { public void testNetInfo() throws SigarException {
NetInfo info = getSigar().getNetInfo(); NetInfo info = getSigar().getNetInfo();
NetInterfaceConfig config = getSigar().getNetInterfaceConfig(null);
traceln("");
traceln(info.toString());
traceln(config.toString());
int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP;
NetConnection[] connections =
getSigar().getNetConnectionList(flags);
for (int i=0; i<connections.length; i++) {
long port = connections[i].getLocalPort();
traceln("Listen " +
getSigar().getNetListenAddress(port) + ":" + port);
}
} }
} }

View File

@ -25,8 +25,6 @@ import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException; import org.hyperic.sigar.SigarNotImplementedException;
public class TestNetStat extends SigarTestCase { public class TestNetStat extends SigarTestCase {
private static boolean printListeners =
"true".equals(System.getProperty("sigar.netstat.listeners"));
public TestNetStat(String name) { public TestNetStat(String name) {
super(name); super(name);
@ -49,20 +47,5 @@ public class TestNetStat extends SigarTestCase {
for (int i=0; i<NetFlags.TCP_UNKNOWN; i++) { for (int i=0; i<NetFlags.TCP_UNKNOWN; i++) {
assertGtEqZeroTrace(NetConnection.getStateString(i), states[i]); assertGtEqZeroTrace(NetConnection.getStateString(i), states[i]);
} }
if (!printListeners) {
return;
}
int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP;
NetConnection[] connections =
sigar.getNetConnectionList(flags);
for (int i=0; i<connections.length; i++) {
long port = connections[i].getLocalPort();
traceln("Listen " +
sigar.getNetListenAddress(port) + ":" + port);
}
} }
} }