Source:
<code>public void CompleteEthernetIIPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; assumeTrue(trace.exists()); <START> PcapFile dummy = trace.getTrace(); <END> ByteBuffer byteBuffer = fPacket; if (byteBuffer == null) { fail("GenericPacketTest has failed!"); return; } EthernetIIPacket packet = new EthernetIIPacket(dummy, null, byteBuffer); assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(-653947816, packet.hashCode()); assertFalse(packet.equals(null)); assertEquals(new EthernetIIPacket(dummy, null, byteBuffer), packet); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Src: 10:f8:82:b3:44:78 , Dst: 34:67:0c:d2:91:51", packet.getLocalSummaryString()); assertEquals("Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51", packet.getGlobalSummaryString()); assertEquals(new EthernetIIEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new EthernetIIEndpoint(packet, false), packet.getDestinationEndpoint()); fPacket.position(14); byte[] payload = new byte[1]; fPacket.get(payload); assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); assertTrue(Arrays.equals(packet.getSourceMacAddress(), Arrays.copyOfRange(fPacket.array(), EthernetIIValues.MAC_ADDRESS_SIZE, EthernetIIValues.MAC_ADDRESS_SIZE + EthernetIIValues.MAC_ADDRESS_SIZE))); assertTrue(Arrays.equals(packet.getDestinationMacAddress(), Arrays.copyOfRange(fPacket.array(), 0, 0 + EthernetIIValues.MAC_ADDRESS_SIZE))); assertEquals(0xA256, packet.getEthertype()); }</code><technical_language>I try</technical_language>

Target:
public void CompleteEthernetIIPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP; assumeTrue(trace.exists()); try (PcapFile dummy = trace.getTrace();) { ByteBuffer byteBuffer = fPacket; if (byteBuffer == null) { fail("GenericPacketTest has failed!"); return; } EthernetIIPacket packet = new EthernetIIPacket(dummy, null, byteBuffer); assertEquals(PcapProtocol.ETHERNET_II, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.ETHERNET_II)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(-653947816, packet.hashCode()); assertFalse(packet.equals(null)); assertEquals(new EthernetIIPacket(dummy, null, byteBuffer), packet); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Src: 10:f8:82:b3:44:78 , Dst: 34:67:0c:d2:91:51", packet.getLocalSummaryString()); assertEquals("Source MAC: 10:f8:82:b3:44:78 , Destination MAC: 34:67:0c:d2:91:51", packet.getGlobalSummaryString()); assertEquals(new EthernetIIEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new EthernetIIEndpoint(packet, false), packet.getDestinationEndpoint()); fPacket.position(14); byte[] payload = new byte[1]; fPacket.get(payload); assertEquals(ByteBuffer.wrap(payload), packet.getPayload()); assertTrue(Arrays.equals(packet.getSourceMacAddress(), Arrays.copyOfRange(fPacket.array(), EthernetIIValues.MAC_ADDRESS_SIZE, EthernetIIValues.MAC_ADDRESS_SIZE + EthernetIIValues.MAC_ADDRESS_SIZE))); assertTrue(Arrays.equals(packet.getDestinationMacAddress(), Arrays.copyOfRange(fPacket.array(), 0, 0 + EthernetIIValues.MAC_ADDRESS_SIZE))); assertEquals(0xA256, packet.getEthertype()); } }