3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.packet;
12 import junit.framework.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.sal.packet.ICMP;
17 public class ICMPTest {
20 public void testSetTypeCode() {
21 ICMP icmp = new ICMP();
22 short icmpTypeCode = 2;
23 icmp.setTypeCode(icmpTypeCode);
24 byte[] typeCode = icmp.hdrFieldsMap.get("TypeCode");
25 Assert.assertTrue(typeCode[0] == 0);
26 Assert.assertTrue(typeCode[1] == 2);
31 public void testSetChecksum() {
32 ICMP icmp = new ICMP();
33 short icmpChecksum = 200;
34 icmp.setChecksum(icmpChecksum);
35 byte[] checksum = icmp.hdrFieldsMap.get("HeaderChecksum");
36 Assert.assertTrue(checksum[0] == 0);
37 Assert.assertTrue(checksum[1] == -56);
42 public void testSetIdentifier() {
43 ICMP icmp = new ICMP();
44 short icmpIdentifier = 1201;
45 icmp.setIdentifier(icmpIdentifier);
46 byte[] identifier = icmp.hdrFieldsMap.get("Identifier");
47 Assert.assertTrue(identifier[0] == 4);
48 Assert.assertTrue(identifier[1] == -79);
53 public void testSetSequenceNumber() {
54 ICMP icmp = new ICMP();
55 short icmpSequenceNumber = 5000;
56 icmp.setSequenceNumber(icmpSequenceNumber);
57 byte[] sequenceNumber = icmp.hdrFieldsMap.get("SequenceNumber");
58 Assert.assertTrue(sequenceNumber[0] == 19);
59 Assert.assertTrue(sequenceNumber[1] == -120);