Source:
<code>public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; assumeTrue(trace.exists()); try (PcapFile file = trace.getTrace();) { file.seekPacket(36); PcapPacket packet = file.parseNextPacket(); if (packet == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(PcapProtocol.PCAP, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(86567859, packet.hashCode()); assertFalse(packet.equals(null)); assertFalse(packet.equals(file.parseNextPacket())); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); ByteBuffer payload = packet.getPayload(); if (payload == null) { fail("CompletePcapPacketTest has failed!"); return; } <START> assertEquals(fPayload, payload.flip()); <END> assertEquals(36, packet.getIndex()); assertEquals(75, packet.getOriginalLength()); assertEquals(75, packet.getIncludedLength()); assertEquals(1120469632829277L, packet.getTimestamp()); assertFalse(packet.isTruncated()); } }</code><technical_language>This assertion removed. fails getPayload() sets position 0 returning ByteBuffer. flip() ByteBuffer empty (limit=0). called! reset position 0 instead (but this is longer necessary)</technical_language>

Target:
public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; assumeTrue(trace.exists()); try (PcapFile file = trace.getTrace();) { file.seekPacket(36); PcapPacket packet = file.parseNextPacket(); if (packet == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(PcapProtocol.PCAP, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(86567859, packet.hashCode()); assertFalse(packet.equals(null)); assertFalse(packet.equals(file.parseNextPacket())); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); ByteBuffer payload = packet.getPayload(); if (payload == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(36, packet.getIndex()); assertEquals(75, packet.getOriginalLength()); assertEquals(75, packet.getIncludedLength()); assertEquals(1120469632829277L, packet.getTimestamp()); assertFalse(packet.isTruncated()); } }