Exemplo n.º 1
0
 /** Test next null ptr handling. */
 public void testNextNullPtrHandling() {
   Pcap pcap = Pcap.openOffline(fname, errbuf);
   try {
     pcap.next((PcapHeader) null, null);
     fail("Expected a NULL pointer exception.");
   } catch (NullPointerException e) {
     // OK
   } finally {
     pcap.close();
   }
 }
Exemplo n.º 2
0
  /** Test open offline and next. */
  public void testOpenOfflineAndNext() {

    Pcap pcap = Pcap.openOffline(fname, errbuf);
    assertNotNull(errbuf.toString(), pcap);
    PcapPktHdr hdr = new PcapPktHdr();

    ByteBuffer buffer = pcap.next(hdr);

    assertEquals(114, buffer.capacity()); // length of the packet should match
    assertEquals(114, hdr.getCaplen()); // Should match within the header too
    assertEquals(114, hdr.getLen()); // Should match within the header too

    // System.out.println(new Date(hdr.getSeconds() * 1000).toString());

    pcap.close();
  }