445f7211c0f8c3fc50a7f5bb4856ed0e05993565
[controller.git] / opendaylight / sal / api / src / test / java / org / opendaylight / controller / sal / packet / ICMPTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.sal.packet;
11
12 import junit.framework.Assert;
13
14 import org.junit.Test;
15 import org.opendaylight.controller.sal.packet.ICMP;
16
17 public class ICMPTest {
18
19     @Test
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);
27
28     }
29
30     @Test
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);
38
39     }
40
41     @Test
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);
49
50     }
51
52     @Test
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);
60
61     }
62 }