Fix typo in TCP and reuse constants in TcpTest 45/2145/2
authorAlissa Bonas <abonas@redhat.com>
Thu, 24 Oct 2013 16:10:15 +0000 (19:10 +0300)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 24 Oct 2013 16:30:09 +0000 (16:30 +0000)
Change-Id: I2f3ff4ed20e8e191234ab30fda3ba60f1d52bc5f
Signed-off-by: Alissa Bonas <abonas@redhat.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java

index c7c7f99..4b2badd 100644 (file)
@@ -21,16 +21,16 @@ import org.apache.commons.lang3.tuple.Pair;
  */
 public class TCP extends Packet {
 
-    private static final String SRCPORT = "SourcePort";
-    private static final String DESTPORT = "DestinationPort";
-    private static final String SEQNUMBER = "SequenceNumber";
-    private static final String ACKNUMBER = "AcknoledgementNumber";
-    private static final String DATAOFFSET = "DataOffset";
-    private static final String RESERVED = "Reserved";
-    private static final String HEADERLENFLAGS = "HeaderLenFlags";
-    private static final String WINDOWSIZE = "WindowSize";
-    private static final String CHECKSUM = "Checksum";
-    private static final String URGENTPOINTER = "UrgentPointer";
+    public static final String SRCPORT = "SourcePort";
+    public static final String DESTPORT = "DestinationPort";
+    public static final String SEQNUMBER = "SequenceNumber";
+    public static final String ACKNUMBER = "AcknowledgementNumber";
+    public static final String DATAOFFSET = "DataOffset";
+    public static final String RESERVED = "Reserved";
+    public static final String HEADERLENFLAGS = "HeaderLenFlags";
+    public static final String WINDOWSIZE = "WindowSize";
+    public static final String CHECKSUM = "Checksum";
+    public static final String URGENTPOINTER = "UrgentPointer";
 
     private static Map<String, Pair<Integer, Integer>> fieldCoordinates = new LinkedHashMap<String, Pair<Integer, Integer>>() {
         private static final long serialVersionUID = 1L;
index 90f963c..48679c3 100644 (file)
@@ -12,7 +12,6 @@ package org.opendaylight.controller.sal.packet;
 import junit.framework.Assert;
 
 import org.junit.Test;
-import org.opendaylight.controller.sal.packet.TCP;
 
 public class TCPTest {
 
@@ -21,7 +20,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpSourcePort = 118;
         tcp.setSourcePort(tcpSourcePort);
-        byte[] sourcePort = tcp.hdrFieldsMap.get("SourcePort");
+        byte[] sourcePort = tcp.hdrFieldsMap.get(TCP.SRCPORT);
         Assert.assertTrue(sourcePort[0] == 0);
         Assert.assertTrue(sourcePort[1] == 118);
 
@@ -32,7 +31,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpDestinationPort = 443;
         tcp.setDestinationPort(tcpDestinationPort);
-        byte[] destinationPort = tcp.hdrFieldsMap.get("DestinationPort");
+        byte[] destinationPort = tcp.hdrFieldsMap.get(TCP.DESTPORT);
         Assert.assertTrue(destinationPort[0] == 1);
         Assert.assertTrue(destinationPort[1] == -69);
 
@@ -43,7 +42,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpSequenceNumber = 700;
         tcp.setSequenceNumber(tcpSequenceNumber);
-        byte[] sequenceNumber = tcp.hdrFieldsMap.get("SequenceNumber");
+        byte[] sequenceNumber = tcp.hdrFieldsMap.get(TCP.SEQNUMBER);
         Assert.assertTrue(sequenceNumber[0] == 0);
         Assert.assertTrue(sequenceNumber[1] == 0);
         Assert.assertTrue(sequenceNumber[2] == 2);
@@ -55,7 +54,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpAckNumber = 697;
         tcp.setAckNumber(tcpAckNumber);
-        byte[] ackNumber = tcp.hdrFieldsMap.get("AcknoledgementNumber");
+        byte[] ackNumber = tcp.hdrFieldsMap.get(TCP.ACKNUMBER);
         Assert.assertTrue(ackNumber[0] == 0);
         Assert.assertTrue(ackNumber[1] == 0);
         Assert.assertTrue(ackNumber[2] == 2);
@@ -67,7 +66,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpFlags = 26;
         tcp.setHeaderLenFlags(tcpFlags);
-        byte[] headerLenFlags = tcp.hdrFieldsMap.get("HeaderLenFlags");
+        byte[] headerLenFlags = tcp.hdrFieldsMap.get(TCP.HEADERLENFLAGS);
         Assert.assertTrue(headerLenFlags[0] == 0);
         Assert.assertTrue(headerLenFlags[1] == 26);
 
@@ -78,7 +77,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpWindowSize = 100;
         tcp.setWindowSize(tcpWindowSize);
-        byte[] windowSize = tcp.hdrFieldsMap.get("WindowSize");
+        byte[] windowSize = tcp.hdrFieldsMap.get(TCP.WINDOWSIZE);
         Assert.assertTrue(windowSize[0] == 0);
         Assert.assertTrue(windowSize[1] == 100);
 
@@ -89,7 +88,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpChecksum = 134;
         tcp.setChecksum(tcpChecksum);
-        byte[] checksum = tcp.hdrFieldsMap.get("Checksum");
+        byte[] checksum = tcp.hdrFieldsMap.get(TCP.CHECKSUM);
         Assert.assertTrue(checksum[0] == 0);
         Assert.assertTrue(checksum[1] == -122);
 
@@ -100,7 +99,7 @@ public class TCPTest {
         TCP tcp = new TCP();
         short tcpUrgentPointer = 25098;
         tcp.setUrgentPointer(tcpUrgentPointer);
-        byte[] urgentPointer = tcp.hdrFieldsMap.get("UrgentPointer");
+        byte[] urgentPointer = tcp.hdrFieldsMap.get(TCP.URGENTPOINTER);
         Assert.assertTrue(urgentPointer[0] == 98);
         Assert.assertTrue(urgentPointer[1] == 10);