### Question:
TXIPv4Packet extends XBeeAPIPacket { public byte[] getData() { if (data == null) return null; return Arrays.copyOf(data, data.length); } TXIPv4Packet(int frameID, Inet4Address destAddress, int destPort, int sourcePort,
			IPProtocol protocol, int transmitOptions, byte[] data); static TXIPv4Packet createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); Inet4Address getDestAddress(); void setDestAddress(Inet4Address destAddress); int getDestPort(); void setDestPort(int destPort); int getSourcePort(); void setSourcePort(int sourcePort); IPProtocol getProtocol(); void setProtocol(IPProtocol protocol); int getTransmitOptions(); void setTransmitOptions(int transmitOptions); byte[] getData(); void setData(byte[] data); @Override LinkedHashMap<String, String> getAPIPacketParameters(); static final int OPTIONS_CLOSE_SOCKET; static final int OPTIONS_LEAVE_SOCKET_OPEN; }### Answer:
@Test public final void testGetDataNullData() { data = null; TXIPv4Packet packet = new TXIPv4Packet(frameID, destAddress, destPort, sourcePort, protocol, transmitOptions, data); byte[] result = packet.getData(); assertThat("Data must be the same", result, is(equalTo(data))); assertThat("Data must be null", result, is(nullValue(byte[].class))); }
@Test public final void testGetDataValidData() { TXIPv4Packet packet = new TXIPv4Packet(frameID, destAddress, destPort, sourcePort, protocol, transmitOptions, data); byte[] result = packet.getData(); assertThat("Data must be the same", result, is(equalTo(data))); assertThat("Data must not be the same object", result.hashCode(), is(not(equalTo(data.hashCode())))); }