Skip to content
Snippets Groups Projects
Commit b2b1c507 authored by Shudong Zhou's avatar Shudong Zhou
Browse files

Fix packet related tests

parent 641cd435
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ public class ICMPTest {
}
@Test
public void testDeserialize() {
public void testDeserialize() throws PacketParsingException {
IPacket packet = new IPv4();
packet.deserialize(pktSerialized, 0, pktSerialized.length);
byte[] pktSerialized1 = packet.serialize();
......
......@@ -85,7 +85,7 @@ public class IPv4Test {
};
@Test
public void testDeserialize() {
public void testDeserialize() throws PacketParsingException {
IPv4 packet = new IPv4();
packet.deserialize(pktSerialized, 0, pktSerialized.length);
byte[] pktSerialized1 = packet.serialize();
......@@ -93,7 +93,7 @@ public class IPv4Test {
}
@Test
public void testDeserializePadded() {
public void testDeserializePadded() throws PacketParsingException {
// A real TLSv1 packet with crap added to the end
byte[] pktSerializedPadded = new byte[] { 0x45, 0x00,
0x00, 0x2e, 0x41, (byte) 0xbe, 0x40, 0x00, 0x40, 0x06,
......@@ -112,7 +112,7 @@ public class IPv4Test {
}
@Test
public void testDeserializeFragment() {
public void testDeserializeFragment() throws PacketParsingException {
// IP packet with more frag bit set
byte[] pktSerializedFirstFrag = new byte[] { 0x45, 0x00,
0x00, 0x2e, 0x41, (byte) 0xbe, 0x20, 0x00, 0x40, 0x06,
......@@ -145,7 +145,7 @@ public class IPv4Test {
}
@Test
public void testDeserializeDontFragment() {
public void testDeserializeDontFragment() throws PacketParsingException {
// IP packet with more frag bit set
byte[] pktSerializedDontFrag = new byte[] { 0x45, 0x00,
0x00, 0x2e, 0x41, (byte) 0xbe, 0x60, 0x00, 0x40, 0x06,
......
......@@ -100,7 +100,7 @@ public class PacketTest {
this.packets = new IPacket[] { pkt1, pkt2, pkt3, pkt4 };
}
protected void doTestClone(IPacket pkt) {
protected void doTestClone(IPacket pkt) throws PacketParsingException {
if (pkt.getPayload() != null)
doTestClone(pkt.getPayload());
IPacket newPkt = (IPacket)pkt.clone();
......@@ -127,16 +127,16 @@ public class PacketTest {
assertEquals(false, Arrays.equals(newArp.getSenderProtocolAddress(),
arp.getSenderProtocolAddress()));
assertEquals(false, newPkt.equals(pkt));
} else {
byte[] dummyData = dummyPkt.serialize().clone();
newPkt = (IPacket)pkt.clone();
newPkt.deserialize(dummyData, 0, dummyData.length);
assertEquals(false, newPkt.equals(pkt));
}
byte[] dummyData = dummyPkt.serialize().clone();
newPkt = (IPacket)pkt.clone();
newPkt.deserialize(dummyData, 0, dummyData.length);
assertEquals(false, newPkt.equals(pkt));
}
@Test
public void testClone() {
public void testClone() throws PacketParsingException {
for (IPacket pkt: packets) {
doTestClone(pkt);
}
......
......@@ -65,7 +65,7 @@ public class TCPTest {
}
@Test
public void testDeserialize() {
public void testDeserialize() throws PacketParsingException {
IPacket packet = new IPv4();
packet.deserialize(pktSerialized, 0, pktSerialized.length);
byte[] pktSerialized1 = packet.serialize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment