ONOS-2711 Replaced short to TpPort for tcp/udp ports

Change-Id: Ibf0474b5369d11d377fd33cf5ab48083cbca3308
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
index f7050ec..b871397 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
@@ -22,15 +22,16 @@
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeMatcher;
 import org.junit.Test;
-import org.onosproject.net.IndexedLambda;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.criteria.Criterion;
 import org.onlab.packet.Ip6Address;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
+import org.onosproject.net.IndexedLambda;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.criteria.Criterion;
 
 import com.google.common.testing.EqualsTester;
 
@@ -196,27 +197,27 @@
         assertThat(selector, hasCriterionWithType(Type.IPV4_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchTcpSrc(shortValue).build();
+                .matchTcpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.TCP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchTcpDst(shortValue).build();
+                .matchTcpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.TCP_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchUdpSrc(shortValue).build();
+                .matchUdpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.UDP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchUdpDst(shortValue).build();
+                .matchUdpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.UDP_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchSctpSrc(shortValue).build();
+                .matchSctpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.SCTP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchSctpDst(shortValue).build();
+                .matchSctpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.SCTP_DST));
 
         selector = DefaultTrafficSelector.builder()
diff --git a/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java b/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
index de60b69..ee294f6 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
@@ -17,15 +17,16 @@
 
 import org.junit.Test;
 import org.onlab.packet.EthType;
+import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ChannelSpacing;
 import org.onosproject.net.GridType;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.PortNumber;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 
 import com.google.common.testing.EqualsTester;
 import org.onosproject.net.OchSignalType;
@@ -122,17 +123,19 @@
     Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
     Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
 
-    Criterion matchTcpPort1 = Criteria.matchTcpSrc(1);
-    Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1);
-    Criterion matchTcpPort2 = Criteria.matchTcpDst(2);
+    private TpPort tpPort1 = TpPort.tpPort(1);
+    private TpPort tpPort2 = TpPort.tpPort(2);
+    Criterion matchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
+    Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
+    Criterion matchTcpPort2 = Criteria.matchTcpDst(tpPort2);
 
-    Criterion matchUdpPort1 = Criteria.matchUdpSrc(1);
-    Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1);
-    Criterion matchUdpPort2 = Criteria.matchUdpDst(2);
+    Criterion matchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
+    Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
+    Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2);
 
-    Criterion matchSctpPort1 = Criteria.matchSctpSrc(1);
-    Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1);
-    Criterion matchSctpPort2 = Criteria.matchSctpDst(2);
+    Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
+    Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
+    Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2);
 
     short icmpType1 = 1;
     short icmpType2 = 2;
@@ -652,12 +655,12 @@
      */
     @Test
     public void testMatchTcpSrcMethod() {
-        Criterion matchTcpSrc = Criteria.matchTcpSrc(1);
+        Criterion matchTcpSrc = Criteria.matchTcpSrc(tpPort1);
         TcpPortCriterion tcpPortCriterion =
                 checkAndConvert(matchTcpSrc,
                                 Criterion.Type.TCP_SRC,
                                 TcpPortCriterion.class);
-        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
+        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -665,12 +668,12 @@
      */
     @Test
     public void testMatchTcpDstMethod() {
-        Criterion matchTcpDst = Criteria.matchTcpDst(1);
+        Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1);
         TcpPortCriterion tcpPortCriterion =
                 checkAndConvert(matchTcpDst,
                         Criterion.Type.TCP_DST,
                         TcpPortCriterion.class);
-        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
+        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -691,12 +694,12 @@
      */
     @Test
     public void testMatchUdpSrcMethod() {
-        Criterion matchUdpSrc = Criteria.matchUdpSrc(1);
+        Criterion matchUdpSrc = Criteria.matchUdpSrc(tpPort1);
         UdpPortCriterion udpPortCriterion =
                 checkAndConvert(matchUdpSrc,
                                 Criterion.Type.UDP_SRC,
                                 UdpPortCriterion.class);
-        assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
+        assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -704,12 +707,12 @@
      */
     @Test
     public void testMatchUdpDstMethod() {
-        Criterion matchUdpDst = Criteria.matchUdpDst(1);
+        Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1);
         UdpPortCriterion udpPortCriterion =
                 checkAndConvert(matchUdpDst,
                         Criterion.Type.UDP_DST,
                         UdpPortCriterion.class);
-        assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
+        assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -730,12 +733,12 @@
      */
     @Test
     public void testMatchSctpSrcMethod() {
-        Criterion matchSctpSrc = Criteria.matchSctpSrc(1);
+        Criterion matchSctpSrc = Criteria.matchSctpSrc(tpPort1);
         SctpPortCriterion sctpPortCriterion =
                 checkAndConvert(matchSctpSrc,
                                 Criterion.Type.SCTP_SRC,
                                 SctpPortCriterion.class);
-        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
+        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -743,12 +746,12 @@
      */
     @Test
     public void testMatchSctpDstMethod() {
-        Criterion matchSctpDst = Criteria.matchSctpDst(1);
+        Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1);
         SctpPortCriterion sctpPortCriterion =
                 checkAndConvert(matchSctpDst,
                         Criterion.Type.SCTP_DST,
                         SctpPortCriterion.class);
-        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
+        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
     }
 
     /**
diff --git a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index e33e9d7f..d365e92 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -16,15 +16,16 @@
 package org.onosproject.net.flow.instructions;
 
 import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ChannelSpacing;
 import org.onosproject.net.GridType;
 import org.onosproject.net.IndexedLambda;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.PortNumber;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 
 import com.google.common.testing.EqualsTester;
 
@@ -638,22 +639,22 @@
 
     // ModTransportPortInstruction
 
-    private final short l4port1 = 1;
-    private final short l4port2 = 2;
-    private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(l4port1);
-    private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(l4port1);
-    private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(l4port2);
+    private final TpPort tpPort1 = TpPort.tpPort(1);
+    private final TpPort tpPort2 = TpPort.tpPort(2);
+    private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
+    private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
+    private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(tpPort2);
 
     /**
      * Test the modTcpSrc() method.
      */
     @Test
     public void testModTcpSrcMethod() {
-        final Instruction instruction = Instructions.modTcpSrc(l4port1);
+        final Instruction instruction = Instructions.modTcpSrc(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.TCP_SRC)));
     }
@@ -663,11 +664,11 @@
      */
     @Test
     public void testModTcpDstMethod() {
-        final Instruction instruction = Instructions.modTcpDst(l4port1);
+        final Instruction instruction = Instructions.modTcpDst(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.TCP_DST)));
     }
@@ -677,11 +678,11 @@
      */
     @Test
     public void testModUdpSrcMethod() {
-        final Instruction instruction = Instructions.modUdpSrc(l4port1);
+        final Instruction instruction = Instructions.modUdpSrc(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.UDP_SRC)));
     }
@@ -691,11 +692,11 @@
      */
     @Test
     public void testModUdpDstMethod() {
-        final Instruction instruction = Instructions.modUdpDst(l4port1);
+        final Instruction instruction = Instructions.modUdpDst(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.UDP_DST)));
     }