### Question:
Packet implements Freezable<Packet>, Sizeable { void addLastSegment(Segment segment) { if (segments.size() >= MAX_DATAS_PER_PACKET) throw new IndexOutOfBoundsException("Cannot add more than " + MAX_DATAS_PER_PACKET + " segments to packet!"); segments.addLast(segment); } Packet(); List<Segment> getSegments(); Segment getFirstSegment(); Segment getLastSegment(); Short getTransmissionAck(); long getPrecedingTransmissionAcks(); @Override String toString(); String toDebugString(); static void writeExternalStatic(Packet packet, ObjectOutput out); static Packet readExternalStatic(ObjectInput in); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in); @Override Packet clone(); @Override int getSize(); static final transient int MAX_DATAS_PER_PACKET; }### Answer:
@Test(expected = IndexOutOfBoundsException.class) public final void testExceptions() { Packet packet = new Packet(); for (int i = 0; i <= Packet.MAX_DATAS_PER_PACKET; ++i) { packet.addLastSegment(new Segment()); } }