@Test
public void testGetStats() throws Exception {

  if (ph != null) {
    ph.close();
  }
  List<PcapNetworkInterface> nifs = Pcaps.findAllDevs();
  if (nifs.isEmpty()) {
    ph = Pcaps.openDead(DataLinkType.EN10MB, 2048);
    try {
      ph.getStats();
      fail("getStats on a pcap_open_dead pcap_t should throw a PcapNativeException.");
    } catch (PcapNativeException e) {
      assertEquals("Statistics aren't available from a pcap_open_dead pcap_t", e.getMessage());
    }
  } else {
    try {
      ph = nifs.get(0).openLive(55555, PromiscuousMode.PROMISCUOUS, 100);
      PcapStat ps = ph.getStats();
      assertNotNull(ps);
    } catch (PcapNativeException e) {
      assertTrue(
          "The exception should complain about permission to capture.",
          e.getMessage().contains("You don't have permission to capture on that device"));
    }
  }
}