[ONOS-3494] Add test case for TCPFlags Criterion
Change-Id: I2575e52dc316039e528ff6216cec7c1d3195fe81
Showing
2 changed files
with
177 additions
and
62 deletions
| ... | @@ -28,92 +28,136 @@ public interface Criterion { | ... | @@ -28,92 +28,136 @@ public interface Criterion { |
| 28 | enum Type { | 28 | enum Type { |
| 29 | /** Switch input port. */ | 29 | /** Switch input port. */ |
| 30 | IN_PORT, | 30 | IN_PORT, |
| 31 | + | ||
| 31 | /** Switch physical input port. */ | 32 | /** Switch physical input port. */ |
| 32 | IN_PHY_PORT, | 33 | IN_PHY_PORT, |
| 34 | + | ||
| 33 | /** Metadata passed between tables. */ | 35 | /** Metadata passed between tables. */ |
| 34 | METADATA, | 36 | METADATA, |
| 37 | + | ||
| 35 | /** Ethernet destination address. */ | 38 | /** Ethernet destination address. */ |
| 36 | ETH_DST, | 39 | ETH_DST, |
| 40 | + | ||
| 37 | /** Ethernet source address. */ | 41 | /** Ethernet source address. */ |
| 38 | ETH_SRC, | 42 | ETH_SRC, |
| 43 | + | ||
| 39 | /** Ethernet frame type. */ | 44 | /** Ethernet frame type. */ |
| 40 | ETH_TYPE, | 45 | ETH_TYPE, |
| 46 | + | ||
| 41 | /** VLAN id. */ | 47 | /** VLAN id. */ |
| 42 | VLAN_VID, | 48 | VLAN_VID, |
| 49 | + | ||
| 43 | /** VLAN priority. */ | 50 | /** VLAN priority. */ |
| 44 | VLAN_PCP, | 51 | VLAN_PCP, |
| 52 | + | ||
| 45 | /** IP DSCP (6 bits in ToS field). */ | 53 | /** IP DSCP (6 bits in ToS field). */ |
| 46 | IP_DSCP, | 54 | IP_DSCP, |
| 55 | + | ||
| 47 | /** IP ECN (2 bits in ToS field). */ | 56 | /** IP ECN (2 bits in ToS field). */ |
| 48 | IP_ECN, | 57 | IP_ECN, |
| 58 | + | ||
| 49 | /** IP protocol. */ | 59 | /** IP protocol. */ |
| 50 | IP_PROTO, | 60 | IP_PROTO, |
| 61 | + | ||
| 51 | /** IPv4 source address. */ | 62 | /** IPv4 source address. */ |
| 52 | IPV4_SRC, | 63 | IPV4_SRC, |
| 64 | + | ||
| 53 | /** IPv4 destination address. */ | 65 | /** IPv4 destination address. */ |
| 54 | IPV4_DST, | 66 | IPV4_DST, |
| 67 | + | ||
| 55 | /** TCP source port. */ | 68 | /** TCP source port. */ |
| 56 | TCP_SRC, | 69 | TCP_SRC, |
| 70 | + | ||
| 57 | /** TCP destination port. */ | 71 | /** TCP destination port. */ |
| 58 | TCP_DST, | 72 | TCP_DST, |
| 73 | + | ||
| 59 | /** UDP source port. */ | 74 | /** UDP source port. */ |
| 60 | UDP_SRC, | 75 | UDP_SRC, |
| 76 | + | ||
| 61 | /** UDP destination port. */ | 77 | /** UDP destination port. */ |
| 62 | UDP_DST, | 78 | UDP_DST, |
| 79 | + | ||
| 63 | /** SCTP source port. */ | 80 | /** SCTP source port. */ |
| 64 | SCTP_SRC, | 81 | SCTP_SRC, |
| 82 | + | ||
| 65 | /** SCTP destination port. */ | 83 | /** SCTP destination port. */ |
| 66 | SCTP_DST, | 84 | SCTP_DST, |
| 85 | + | ||
| 67 | /** ICMP type. */ | 86 | /** ICMP type. */ |
| 68 | ICMPV4_TYPE, | 87 | ICMPV4_TYPE, |
| 88 | + | ||
| 69 | /** ICMP code. */ | 89 | /** ICMP code. */ |
| 70 | ICMPV4_CODE, | 90 | ICMPV4_CODE, |
| 91 | + | ||
| 71 | /** ARP opcode. */ | 92 | /** ARP opcode. */ |
| 72 | ARP_OP, | 93 | ARP_OP, |
| 94 | + | ||
| 73 | /** ARP source IPv4 address. */ | 95 | /** ARP source IPv4 address. */ |
| 74 | ARP_SPA, | 96 | ARP_SPA, |
| 97 | + | ||
| 75 | /** ARP target IPv4 address. */ | 98 | /** ARP target IPv4 address. */ |
| 76 | ARP_TPA, | 99 | ARP_TPA, |
| 100 | + | ||
| 77 | /** ARP source hardware address. */ | 101 | /** ARP source hardware address. */ |
| 78 | ARP_SHA, | 102 | ARP_SHA, |
| 103 | + | ||
| 79 | /** ARP target hardware address. */ | 104 | /** ARP target hardware address. */ |
| 80 | ARP_THA, | 105 | ARP_THA, |
| 106 | + | ||
| 81 | /** IPv6 source address. */ | 107 | /** IPv6 source address. */ |
| 82 | IPV6_SRC, | 108 | IPV6_SRC, |
| 109 | + | ||
| 83 | /** IPv6 destination address. */ | 110 | /** IPv6 destination address. */ |
| 84 | IPV6_DST, | 111 | IPV6_DST, |
| 112 | + | ||
| 85 | /** IPv6 Flow Label. */ | 113 | /** IPv6 Flow Label. */ |
| 86 | IPV6_FLABEL, | 114 | IPV6_FLABEL, |
| 115 | + | ||
| 87 | /** ICMPv6 type. */ | 116 | /** ICMPv6 type. */ |
| 88 | ICMPV6_TYPE, | 117 | ICMPV6_TYPE, |
| 118 | + | ||
| 89 | /** ICMPv6 code. */ | 119 | /** ICMPv6 code. */ |
| 90 | ICMPV6_CODE, | 120 | ICMPV6_CODE, |
| 121 | + | ||
| 91 | /** Target address for ND. */ | 122 | /** Target address for ND. */ |
| 92 | IPV6_ND_TARGET, | 123 | IPV6_ND_TARGET, |
| 124 | + | ||
| 93 | /** Source link-layer for ND. */ | 125 | /** Source link-layer for ND. */ |
| 94 | IPV6_ND_SLL, | 126 | IPV6_ND_SLL, |
| 127 | + | ||
| 95 | /** Target link-layer for ND. */ | 128 | /** Target link-layer for ND. */ |
| 96 | IPV6_ND_TLL, | 129 | IPV6_ND_TLL, |
| 130 | + | ||
| 97 | /** MPLS label. */ | 131 | /** MPLS label. */ |
| 98 | MPLS_LABEL, | 132 | MPLS_LABEL, |
| 133 | + | ||
| 99 | /** MPLS TC. */ | 134 | /** MPLS TC. */ |
| 100 | MPLS_TC, | 135 | MPLS_TC, |
| 101 | - /** MPLS BoS bit. */ | 136 | + |
| 137 | + /** MPLS BoS bit. */ | ||
| 102 | MPLS_BOS, | 138 | MPLS_BOS, |
| 139 | + | ||
| 103 | /** PBB I-SID. */ | 140 | /** PBB I-SID. */ |
| 104 | PBB_ISID, | 141 | PBB_ISID, |
| 142 | + | ||
| 105 | /** Logical Port Metadata. */ | 143 | /** Logical Port Metadata. */ |
| 106 | TUNNEL_ID, | 144 | TUNNEL_ID, |
| 145 | + | ||
| 107 | /** IPv6 Extension Header pseudo-field. */ | 146 | /** IPv6 Extension Header pseudo-field. */ |
| 108 | IPV6_EXTHDR, | 147 | IPV6_EXTHDR, |
| 148 | + | ||
| 109 | /** Unassigned value: 40. */ | 149 | /** Unassigned value: 40. */ |
| 110 | UNASSIGNED_40, | 150 | UNASSIGNED_40, |
| 151 | + | ||
| 111 | /** PBB UCA header field. */ | 152 | /** PBB UCA header field. */ |
| 112 | PBB_UCA, | 153 | PBB_UCA, |
| 154 | + | ||
| 113 | /** TCP flags. */ | 155 | /** TCP flags. */ |
| 114 | TCP_FLAGS, | 156 | TCP_FLAGS, |
| 157 | + | ||
| 115 | /** Output port from action set metadata. */ | 158 | /** Output port from action set metadata. */ |
| 116 | ACTSET_OUTPUT, | 159 | ACTSET_OUTPUT, |
| 160 | + | ||
| 117 | /** Packet type value. */ | 161 | /** Packet type value. */ |
| 118 | PACKET_TYPE, | 162 | PACKET_TYPE, |
| 119 | 163 | ||
| ... | @@ -123,16 +167,17 @@ public interface Criterion { | ... | @@ -123,16 +167,17 @@ public interface Criterion { |
| 123 | // | 167 | // |
| 124 | /** Optical channel signal ID (lambda). */ | 168 | /** Optical channel signal ID (lambda). */ |
| 125 | OCH_SIGID, | 169 | OCH_SIGID, |
| 170 | + | ||
| 126 | /** Optical channel signal type (fixed or flexible). */ | 171 | /** Optical channel signal type (fixed or flexible). */ |
| 127 | OCH_SIGTYPE, | 172 | OCH_SIGTYPE, |
| 173 | + | ||
| 128 | /** ODU (Optical channel Data Unit) signal ID. */ | 174 | /** ODU (Optical channel Data Unit) signal ID. */ |
| 129 | ODU_SIGID, | 175 | ODU_SIGID, |
| 176 | + | ||
| 130 | /** ODU (Optical channel Data Unit) signal type. */ | 177 | /** ODU (Optical channel Data Unit) signal type. */ |
| 131 | ODU_SIGTYPE, | 178 | ODU_SIGTYPE, |
| 132 | 179 | ||
| 133 | - /** | 180 | + /** An empty criterion. */ |
| 134 | - * An empty criterion. | ||
| 135 | - */ | ||
| 136 | DUMMY | 181 | DUMMY |
| 137 | } | 182 | } |
| 138 | 183 | ||
| ... | @@ -182,4 +227,41 @@ public interface Criterion { | ... | @@ -182,4 +227,41 @@ public interface Criterion { |
| 182 | return this.value; | 227 | return this.value; |
| 183 | } | 228 | } |
| 184 | } | 229 | } |
| 230 | + | ||
| 231 | + enum TCPFlags { | ||
| 232 | + | ||
| 233 | + /** ECN-nonce concealment protection. */ | ||
| 234 | + NS((short) (1 << 0)), | ||
| 235 | + /** Congestion Window Reduced. */ | ||
| 236 | + CWR((short) (1 << 1)), | ||
| 237 | + /** ECN-Echo. **/ | ||
| 238 | + ECE((short) (1 << 2)), | ||
| 239 | + /** Urgent pointer field is significant. */ | ||
| 240 | + URG((short) (1 << 3)), | ||
| 241 | + /** Acknowledgment field is significant. */ | ||
| 242 | + ACK((short) (1 << 4)), | ||
| 243 | + /** Push the buffered data to the receiving application. */ | ||
| 244 | + PSH((short) (1 << 5)), | ||
| 245 | + /** Reset the connection. */ | ||
| 246 | + RST((short) (1 << 6)), | ||
| 247 | + /** Synchronize sequence numbers. */ | ||
| 248 | + SYN((short) (1 << 7)), | ||
| 249 | + /** No more data from sender. */ | ||
| 250 | + FIN((short) (1 << 8)); | ||
| 251 | + | ||
| 252 | + private short value; | ||
| 253 | + | ||
| 254 | + TCPFlags(short value) { | ||
| 255 | + this.value = value; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + /** | ||
| 259 | + * Gets the value as an integer. | ||
| 260 | + * | ||
| 261 | + * @return the value as an integer | ||
| 262 | + */ | ||
| 263 | + public short getValue() { | ||
| 264 | + return this.value; | ||
| 265 | + } | ||
| 266 | + } | ||
| 185 | } | 267 | } | ... | ... |
| ... | @@ -42,6 +42,7 @@ import org.onosproject.net.OduSignalType; | ... | @@ -42,6 +42,7 @@ import org.onosproject.net.OduSignalType; |
| 42 | import org.onosproject.net.PortNumber; | 42 | import org.onosproject.net.PortNumber; |
| 43 | 43 | ||
| 44 | import com.google.common.testing.EqualsTester; | 44 | import com.google.common.testing.EqualsTester; |
| 45 | + | ||
| 45 | /** | 46 | /** |
| 46 | * Unit tests for the Criteria class and its subclasses. | 47 | * Unit tests for the Criteria class and its subclasses. |
| 47 | */ | 48 | */ |
| ... | @@ -135,6 +136,24 @@ public class CriteriaTest { | ... | @@ -135,6 +136,24 @@ public class CriteriaTest { |
| 135 | Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1); | 136 | Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1); |
| 136 | Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2); | 137 | Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2); |
| 137 | 138 | ||
| 139 | + | ||
| 140 | + int tcpFlags1 = | ||
| 141 | + Criterion.TCPFlags.NS.getValue() | | ||
| 142 | + Criterion.TCPFlags.CWR.getValue() | | ||
| 143 | + Criterion.TCPFlags.ECE.getValue() | | ||
| 144 | + Criterion.TCPFlags.URG.getValue() | | ||
| 145 | + Criterion.TCPFlags.ACK.getValue() | | ||
| 146 | + Criterion.TCPFlags.PSH.getValue() | | ||
| 147 | + Criterion.TCPFlags.RST.getValue() | | ||
| 148 | + Criterion.TCPFlags.SYN.getValue(); | ||
| 149 | + | ||
| 150 | + int tcpFlags2 = tcpFlags1 | | ||
| 151 | + Criterion.TCPFlags.FIN.getValue(); | ||
| 152 | + | ||
| 153 | + Criterion matchTcpFlags1 = Criteria.matchTcpFlags(tcpFlags1); | ||
| 154 | + Criterion sameAsmatchTcpFlags1 = Criteria.matchTcpFlags(tcpFlags1); | ||
| 155 | + Criterion matchTcpFlags2 = Criteria.matchTcpFlags(tcpFlags2); | ||
| 156 | + | ||
| 138 | Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1); | 157 | Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1); |
| 139 | Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1); | 158 | Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1); |
| 140 | Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2); | 159 | Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2); |
| ... | @@ -174,28 +193,28 @@ public class CriteriaTest { | ... | @@ -174,28 +193,28 @@ public class CriteriaTest { |
| 174 | private Ip6Address ip6TargetAddress1 = Ip6Address.valueOf(IPV6_ADDR1); | 193 | private Ip6Address ip6TargetAddress1 = Ip6Address.valueOf(IPV6_ADDR1); |
| 175 | private Ip6Address ip6TargetAddress2 = Ip6Address.valueOf(IPV6_ADDR2); | 194 | private Ip6Address ip6TargetAddress2 = Ip6Address.valueOf(IPV6_ADDR2); |
| 176 | Criterion matchIpv6TargetAddr1 = | 195 | Criterion matchIpv6TargetAddr1 = |
| 177 | - Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); | 196 | + Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
| 178 | Criterion sameAsMatchIpv6TargetAddr1 = | 197 | Criterion sameAsMatchIpv6TargetAddr1 = |
| 179 | - Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); | 198 | + Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
| 180 | Criterion matchIpv6TargetAddr2 = | 199 | Criterion matchIpv6TargetAddr2 = |
| 181 | - Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2); | 200 | + Criteria.matchIPv6NDTargetAddress(ip6TargetAddress2); |
| 182 | 201 | ||
| 183 | private static final String LL_MAC1 = "00:00:00:00:00:01"; | 202 | private static final String LL_MAC1 = "00:00:00:00:00:01"; |
| 184 | private static final String LL_MAC2 = "00:00:00:00:00:02"; | 203 | private static final String LL_MAC2 = "00:00:00:00:00:02"; |
| 185 | private MacAddress llMac1 = MacAddress.valueOf(LL_MAC1); | 204 | private MacAddress llMac1 = MacAddress.valueOf(LL_MAC1); |
| 186 | private MacAddress llMac2 = MacAddress.valueOf(LL_MAC2); | 205 | private MacAddress llMac2 = MacAddress.valueOf(LL_MAC2); |
| 187 | Criterion matchSrcLlAddr1 = | 206 | Criterion matchSrcLlAddr1 = |
| 188 | - Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); | 207 | + Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
| 189 | Criterion sameAsMatchSrcLlAddr1 = | 208 | Criterion sameAsMatchSrcLlAddr1 = |
| 190 | - Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); | 209 | + Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
| 191 | Criterion matchSrcLlAddr2 = | 210 | Criterion matchSrcLlAddr2 = |
| 192 | - Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2); | 211 | + Criteria.matchIPv6NDSourceLinkLayerAddress(llMac2); |
| 193 | Criterion matchTargetLlAddr1 = | 212 | Criterion matchTargetLlAddr1 = |
| 194 | - Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); | 213 | + Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
| 195 | Criterion sameAsMatchTargetLlAddr1 = | 214 | Criterion sameAsMatchTargetLlAddr1 = |
| 196 | - Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); | 215 | + Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
| 197 | Criterion matchTargetLlAddr2 = | 216 | Criterion matchTargetLlAddr2 = |
| 198 | - Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2); | 217 | + Criteria.matchIPv6NDTargetLinkLayerAddress(llMac2); |
| 199 | 218 | ||
| 200 | MplsLabel mpls1 = MplsLabel.mplsLabel(1); | 219 | MplsLabel mpls1 = MplsLabel.mplsLabel(1); |
| 201 | MplsLabel mpls2 = MplsLabel.mplsLabel(2); | 220 | MplsLabel mpls2 = MplsLabel.mplsLabel(2); |
| ... | @@ -219,13 +238,13 @@ public class CriteriaTest { | ... | @@ -219,13 +238,13 @@ public class CriteriaTest { |
| 219 | Criterion.IPv6ExthdrFlags.HOP.getValue() | | 238 | Criterion.IPv6ExthdrFlags.HOP.getValue() | |
| 220 | Criterion.IPv6ExthdrFlags.UNREP.getValue(); | 239 | Criterion.IPv6ExthdrFlags.UNREP.getValue(); |
| 221 | int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 | | 240 | int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 | |
| 222 | - Criterion.IPv6ExthdrFlags.UNSEQ.getValue(); | 241 | + Criterion.IPv6ExthdrFlags.UNSEQ.getValue(); |
| 223 | Criterion matchIpv6ExthdrFlags1 = | 242 | Criterion matchIpv6ExthdrFlags1 = |
| 224 | - Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | 243 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
| 225 | Criterion sameAsMatchIpv6ExthdrFlags1 = | 244 | Criterion sameAsMatchIpv6ExthdrFlags1 = |
| 226 | - Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | 245 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
| 227 | Criterion matchIpv6ExthdrFlags2 = | 246 | Criterion matchIpv6ExthdrFlags2 = |
| 228 | - Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2); | 247 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2); |
| 229 | 248 | ||
| 230 | Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); | 249 | Criterion matchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); |
| 231 | Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); | 250 | Criterion sameAsMatchOchSignalType1 = Criteria.matchOchSignalType(OchSignalType.FIXED_GRID); |
| ... | @@ -242,8 +261,8 @@ public class CriteriaTest { | ... | @@ -242,8 +261,8 @@ public class CriteriaTest { |
| 242 | Criterion matchOchSignal2 = | 261 | Criterion matchOchSignal2 = |
| 243 | Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 4, 8)); | 262 | Criteria.matchLambda(Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 4, 8)); |
| 244 | 263 | ||
| 245 | - final OduSignalId odu1 = oduSignalId(1, 80, new byte [] {1, 1, 2, 2, 1, 2, 2, 1, 2, 2}); | 264 | + final OduSignalId odu1 = oduSignalId(1, 80, new byte[]{1, 1, 2, 2, 1, 2, 2, 1, 2, 2}); |
| 246 | - final OduSignalId odu2 = oduSignalId(3, 8, new byte [] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}); | 265 | + final OduSignalId odu2 = oduSignalId(3, 8, new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}); |
| 247 | Criterion matchOduSignalId1 = Criteria.matchOduSignalId(odu1); | 266 | Criterion matchOduSignalId1 = Criteria.matchOduSignalId(odu1); |
| 248 | Criterion sameAsMatchOduSignalId1 = Criteria.matchOduSignalId(odu1); | 267 | Criterion sameAsMatchOduSignalId1 = Criteria.matchOduSignalId(odu1); |
| 249 | Criterion matchOduSignalId2 = Criteria.matchOduSignalId(odu2); | 268 | Criterion matchOduSignalId2 = Criteria.matchOduSignalId(odu2); |
| ... | @@ -259,9 +278,9 @@ public class CriteriaTest { | ... | @@ -259,9 +278,9 @@ public class CriteriaTest { |
| 259 | * it to the proper type. | 278 | * it to the proper type. |
| 260 | * | 279 | * |
| 261 | * @param criterion Criterion object to convert | 280 | * @param criterion Criterion object to convert |
| 262 | - * @param type Enumerated type value for the Criterion class | 281 | + * @param type Enumerated type value for the Criterion class |
| 263 | - * @param clazz Desired Criterion class | 282 | + * @param clazz Desired Criterion class |
| 264 | - * @param <T> The type the caller wants returned | 283 | + * @param <T> The type the caller wants returned |
| 265 | * @return converted object | 284 | * @return converted object |
| 266 | */ | 285 | */ |
| 267 | @SuppressWarnings("unchecked") | 286 | @SuppressWarnings("unchecked") |
| ... | @@ -297,6 +316,7 @@ public class CriteriaTest { | ... | @@ -297,6 +316,7 @@ public class CriteriaTest { |
| 297 | assertThatClassIsImmutable(IPCriterion.class); | 316 | assertThatClassIsImmutable(IPCriterion.class); |
| 298 | assertThatClassIsImmutable(TcpPortCriterion.class); | 317 | assertThatClassIsImmutable(TcpPortCriterion.class); |
| 299 | assertThatClassIsImmutable(UdpPortCriterion.class); | 318 | assertThatClassIsImmutable(UdpPortCriterion.class); |
| 319 | + assertThatClassIsImmutable(TcpFlagsCriterion.class); | ||
| 300 | assertThatClassIsImmutable(SctpPortCriterion.class); | 320 | assertThatClassIsImmutable(SctpPortCriterion.class); |
| 301 | assertThatClassIsImmutable(IcmpTypeCriterion.class); | 321 | assertThatClassIsImmutable(IcmpTypeCriterion.class); |
| 302 | assertThatClassIsImmutable(IcmpCodeCriterion.class); | 322 | assertThatClassIsImmutable(IcmpCodeCriterion.class); |
| ... | @@ -395,8 +415,8 @@ public class CriteriaTest { | ... | @@ -395,8 +415,8 @@ public class CriteriaTest { |
| 395 | Criterion matchEthDst = Criteria.matchEthDst(mac1); | 415 | Criterion matchEthDst = Criteria.matchEthDst(mac1); |
| 396 | EthCriterion ethCriterion = | 416 | EthCriterion ethCriterion = |
| 397 | checkAndConvert(matchEthDst, | 417 | checkAndConvert(matchEthDst, |
| 398 | - Criterion.Type.ETH_DST, | 418 | + Criterion.Type.ETH_DST, |
| 399 | - EthCriterion.class); | 419 | + EthCriterion.class); |
| 400 | assertThat(ethCriterion.mac(), is(equalTo(mac1))); | 420 | assertThat(ethCriterion.mac(), is(equalTo(mac1))); |
| 401 | } | 421 | } |
| 402 | 422 | ||
| ... | @@ -461,8 +481,8 @@ public class CriteriaTest { | ... | @@ -461,8 +481,8 @@ public class CriteriaTest { |
| 461 | Criterion matchVlanId = Criteria.matchVlanId(vlanId1); | 481 | Criterion matchVlanId = Criteria.matchVlanId(vlanId1); |
| 462 | VlanIdCriterion vlanIdCriterion = | 482 | VlanIdCriterion vlanIdCriterion = |
| 463 | checkAndConvert(matchVlanId, | 483 | checkAndConvert(matchVlanId, |
| 464 | - Criterion.Type.VLAN_VID, | 484 | + Criterion.Type.VLAN_VID, |
| 465 | - VlanIdCriterion.class); | 485 | + VlanIdCriterion.class); |
| 466 | assertThat(vlanIdCriterion.vlanId(), is(equalTo(vlanId1))); | 486 | assertThat(vlanIdCriterion.vlanId(), is(equalTo(vlanId1))); |
| 467 | } | 487 | } |
| 468 | 488 | ||
| ... | @@ -487,8 +507,8 @@ public class CriteriaTest { | ... | @@ -487,8 +507,8 @@ public class CriteriaTest { |
| 487 | Criterion matchVlanPcp = Criteria.matchVlanPcp(vlanPcp1); | 507 | Criterion matchVlanPcp = Criteria.matchVlanPcp(vlanPcp1); |
| 488 | VlanPcpCriterion vlanPcpCriterion = | 508 | VlanPcpCriterion vlanPcpCriterion = |
| 489 | checkAndConvert(matchVlanPcp, | 509 | checkAndConvert(matchVlanPcp, |
| 490 | - Criterion.Type.VLAN_PCP, | 510 | + Criterion.Type.VLAN_PCP, |
| 491 | - VlanPcpCriterion.class); | 511 | + VlanPcpCriterion.class); |
| 492 | assertThat(vlanPcpCriterion.priority(), is(equalTo(vlanPcp1))); | 512 | assertThat(vlanPcpCriterion.priority(), is(equalTo(vlanPcp1))); |
| 493 | } | 513 | } |
| 494 | 514 | ||
| ... | @@ -513,8 +533,8 @@ public class CriteriaTest { | ... | @@ -513,8 +533,8 @@ public class CriteriaTest { |
| 513 | Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1); | 533 | Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1); |
| 514 | IPDscpCriterion ipDscpCriterion = | 534 | IPDscpCriterion ipDscpCriterion = |
| 515 | checkAndConvert(matchIPDscp, | 535 | checkAndConvert(matchIPDscp, |
| 516 | - Criterion.Type.IP_DSCP, | 536 | + Criterion.Type.IP_DSCP, |
| 517 | - IPDscpCriterion.class); | 537 | + IPDscpCriterion.class); |
| 518 | assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1))); | 538 | assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1))); |
| 519 | } | 539 | } |
| 520 | 540 | ||
| ... | @@ -539,8 +559,8 @@ public class CriteriaTest { | ... | @@ -539,8 +559,8 @@ public class CriteriaTest { |
| 539 | Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1); | 559 | Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1); |
| 540 | IPEcnCriterion ipEcnCriterion = | 560 | IPEcnCriterion ipEcnCriterion = |
| 541 | checkAndConvert(matchIPEcn, | 561 | checkAndConvert(matchIPEcn, |
| 542 | - Criterion.Type.IP_ECN, | 562 | + Criterion.Type.IP_ECN, |
| 543 | - IPEcnCriterion.class); | 563 | + IPEcnCriterion.class); |
| 544 | assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1))); | 564 | assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1))); |
| 545 | } | 565 | } |
| 546 | 566 | ||
| ... | @@ -565,8 +585,8 @@ public class CriteriaTest { | ... | @@ -565,8 +585,8 @@ public class CriteriaTest { |
| 565 | Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1); | 585 | Criterion matchIPProtocol = Criteria.matchIPProtocol(protocol1); |
| 566 | IPProtocolCriterion ipProtocolCriterion = | 586 | IPProtocolCriterion ipProtocolCriterion = |
| 567 | checkAndConvert(matchIPProtocol, | 587 | checkAndConvert(matchIPProtocol, |
| 568 | - Criterion.Type.IP_PROTO, | 588 | + Criterion.Type.IP_PROTO, |
| 569 | - IPProtocolCriterion.class); | 589 | + IPProtocolCriterion.class); |
| 570 | assertThat(ipProtocolCriterion.protocol(), is(equalTo(protocol1))); | 590 | assertThat(ipProtocolCriterion.protocol(), is(equalTo(protocol1))); |
| 571 | } | 591 | } |
| 572 | 592 | ||
| ... | @@ -604,8 +624,8 @@ public class CriteriaTest { | ... | @@ -604,8 +624,8 @@ public class CriteriaTest { |
| 604 | Criterion matchIPDst = Criteria.matchIPDst(ip1); | 624 | Criterion matchIPDst = Criteria.matchIPDst(ip1); |
| 605 | IPCriterion ipCriterion = | 625 | IPCriterion ipCriterion = |
| 606 | checkAndConvert(matchIPDst, | 626 | checkAndConvert(matchIPDst, |
| 607 | - Criterion.Type.IPV4_DST, | 627 | + Criterion.Type.IPV4_DST, |
| 608 | - IPCriterion.class); | 628 | + IPCriterion.class); |
| 609 | assertThat(ipCriterion.ip(), is(equalTo(ip1))); | 629 | assertThat(ipCriterion.ip(), is(equalTo(ip1))); |
| 610 | } | 630 | } |
| 611 | 631 | ||
| ... | @@ -617,8 +637,8 @@ public class CriteriaTest { | ... | @@ -617,8 +637,8 @@ public class CriteriaTest { |
| 617 | Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61); | 637 | Criterion matchIpv6Src = Criteria.matchIPv6Src(ipv61); |
| 618 | IPCriterion ipCriterion = | 638 | IPCriterion ipCriterion = |
| 619 | checkAndConvert(matchIpv6Src, | 639 | checkAndConvert(matchIpv6Src, |
| 620 | - Criterion.Type.IPV6_SRC, | 640 | + Criterion.Type.IPV6_SRC, |
| 621 | - IPCriterion.class); | 641 | + IPCriterion.class); |
| 622 | assertThat(ipCriterion.ip(), is(ipv61)); | 642 | assertThat(ipCriterion.ip(), is(ipv61)); |
| 623 | } | 643 | } |
| 624 | 644 | ||
| ... | @@ -630,8 +650,8 @@ public class CriteriaTest { | ... | @@ -630,8 +650,8 @@ public class CriteriaTest { |
| 630 | Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61); | 650 | Criterion matchIPv6Dst = Criteria.matchIPv6Dst(ipv61); |
| 631 | IPCriterion ipCriterion = | 651 | IPCriterion ipCriterion = |
| 632 | checkAndConvert(matchIPv6Dst, | 652 | checkAndConvert(matchIPv6Dst, |
| 633 | - Criterion.Type.IPV6_DST, | 653 | + Criterion.Type.IPV6_DST, |
| 634 | - IPCriterion.class); | 654 | + IPCriterion.class); |
| 635 | assertThat(ipCriterion.ip(), is(equalTo(ipv61))); | 655 | assertThat(ipCriterion.ip(), is(equalTo(ipv61))); |
| 636 | } | 656 | } |
| 637 | 657 | ||
| ... | @@ -674,8 +694,8 @@ public class CriteriaTest { | ... | @@ -674,8 +694,8 @@ public class CriteriaTest { |
| 674 | Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1); | 694 | Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1); |
| 675 | TcpPortCriterion tcpPortCriterion = | 695 | TcpPortCriterion tcpPortCriterion = |
| 676 | checkAndConvert(matchTcpDst, | 696 | checkAndConvert(matchTcpDst, |
| 677 | - Criterion.Type.TCP_DST, | 697 | + Criterion.Type.TCP_DST, |
| 678 | - TcpPortCriterion.class); | 698 | + TcpPortCriterion.class); |
| 679 | assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1))); | 699 | assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1))); |
| 680 | } | 700 | } |
| 681 | 701 | ||
| ... | @@ -713,8 +733,8 @@ public class CriteriaTest { | ... | @@ -713,8 +733,8 @@ public class CriteriaTest { |
| 713 | Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1); | 733 | Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1); |
| 714 | UdpPortCriterion udpPortCriterion = | 734 | UdpPortCriterion udpPortCriterion = |
| 715 | checkAndConvert(matchUdpDst, | 735 | checkAndConvert(matchUdpDst, |
| 716 | - Criterion.Type.UDP_DST, | 736 | + Criterion.Type.UDP_DST, |
| 717 | - UdpPortCriterion.class); | 737 | + UdpPortCriterion.class); |
| 718 | assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1))); | 738 | assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1))); |
| 719 | } | 739 | } |
| 720 | 740 | ||
| ... | @@ -729,6 +749,19 @@ public class CriteriaTest { | ... | @@ -729,6 +749,19 @@ public class CriteriaTest { |
| 729 | .testEquals(); | 749 | .testEquals(); |
| 730 | } | 750 | } |
| 731 | 751 | ||
| 752 | + // TcpFlagsCriterion class | ||
| 753 | + | ||
| 754 | + /** | ||
| 755 | + * Test the equals() method of the TcpFlagsCriterion class. | ||
| 756 | + */ | ||
| 757 | + @Test | ||
| 758 | + public void testTcpFlagsCriterionEquals() { | ||
| 759 | + new EqualsTester() | ||
| 760 | + .addEqualityGroup(matchTcpFlags1, sameAsmatchTcpFlags1) | ||
| 761 | + .addEqualityGroup(matchTcpFlags2) | ||
| 762 | + .testEquals(); | ||
| 763 | + } | ||
| 764 | + | ||
| 732 | // SctpPortCriterion class | 765 | // SctpPortCriterion class |
| 733 | 766 | ||
| 734 | /** | 767 | /** |
| ... | @@ -752,8 +785,8 @@ public class CriteriaTest { | ... | @@ -752,8 +785,8 @@ public class CriteriaTest { |
| 752 | Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1); | 785 | Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1); |
| 753 | SctpPortCriterion sctpPortCriterion = | 786 | SctpPortCriterion sctpPortCriterion = |
| 754 | checkAndConvert(matchSctpDst, | 787 | checkAndConvert(matchSctpDst, |
| 755 | - Criterion.Type.SCTP_DST, | 788 | + Criterion.Type.SCTP_DST, |
| 756 | - SctpPortCriterion.class); | 789 | + SctpPortCriterion.class); |
| 757 | assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1))); | 790 | assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1))); |
| 758 | } | 791 | } |
| 759 | 792 | ||
| ... | @@ -911,7 +944,7 @@ public class CriteriaTest { | ... | @@ -911,7 +944,7 @@ public class CriteriaTest { |
| 911 | @Test | 944 | @Test |
| 912 | public void testMatchIPv6NDTargetAddressMethod() { | 945 | public void testMatchIPv6NDTargetAddressMethod() { |
| 913 | Criterion matchTargetAddress = | 946 | Criterion matchTargetAddress = |
| 914 | - Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); | 947 | + Criteria.matchIPv6NDTargetAddress(ip6TargetAddress1); |
| 915 | IPv6NDTargetAddressCriterion targetAddressCriterion = | 948 | IPv6NDTargetAddressCriterion targetAddressCriterion = |
| 916 | checkAndConvert(matchTargetAddress, | 949 | checkAndConvert(matchTargetAddress, |
| 917 | Criterion.Type.IPV6_ND_TARGET, | 950 | Criterion.Type.IPV6_ND_TARGET, |
| ... | @@ -940,11 +973,11 @@ public class CriteriaTest { | ... | @@ -940,11 +973,11 @@ public class CriteriaTest { |
| 940 | @Test | 973 | @Test |
| 941 | public void testMatchIPv6NDSourceLinkLayerAddressMethod() { | 974 | public void testMatchIPv6NDSourceLinkLayerAddressMethod() { |
| 942 | Criterion matchSrcLlAddr = | 975 | Criterion matchSrcLlAddr = |
| 943 | - Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); | 976 | + Criteria.matchIPv6NDSourceLinkLayerAddress(llMac1); |
| 944 | IPv6NDLinkLayerAddressCriterion srcLlCriterion = | 977 | IPv6NDLinkLayerAddressCriterion srcLlCriterion = |
| 945 | checkAndConvert(matchSrcLlAddr, | 978 | checkAndConvert(matchSrcLlAddr, |
| 946 | - Criterion.Type.IPV6_ND_SLL, | 979 | + Criterion.Type.IPV6_ND_SLL, |
| 947 | - IPv6NDLinkLayerAddressCriterion.class); | 980 | + IPv6NDLinkLayerAddressCriterion.class); |
| 948 | assertThat(srcLlCriterion.mac(), is(equalTo(llMac1))); | 981 | assertThat(srcLlCriterion.mac(), is(equalTo(llMac1))); |
| 949 | } | 982 | } |
| 950 | 983 | ||
| ... | @@ -954,11 +987,11 @@ public class CriteriaTest { | ... | @@ -954,11 +987,11 @@ public class CriteriaTest { |
| 954 | @Test | 987 | @Test |
| 955 | public void testMatchIPv6NDTargetLinkLayerAddressMethod() { | 988 | public void testMatchIPv6NDTargetLinkLayerAddressMethod() { |
| 956 | Criterion matchTargetLlAddr = | 989 | Criterion matchTargetLlAddr = |
| 957 | - Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); | 990 | + Criteria.matchIPv6NDTargetLinkLayerAddress(llMac1); |
| 958 | IPv6NDLinkLayerAddressCriterion targetLlCriterion = | 991 | IPv6NDLinkLayerAddressCriterion targetLlCriterion = |
| 959 | checkAndConvert(matchTargetLlAddr, | 992 | checkAndConvert(matchTargetLlAddr, |
| 960 | - Criterion.Type.IPV6_ND_TLL, | 993 | + Criterion.Type.IPV6_ND_TLL, |
| 961 | - IPv6NDLinkLayerAddressCriterion.class); | 994 | + IPv6NDLinkLayerAddressCriterion.class); |
| 962 | assertThat(targetLlCriterion.mac(), is(equalTo(llMac1))); | 995 | assertThat(targetLlCriterion.mac(), is(equalTo(llMac1))); |
| 963 | } | 996 | } |
| 964 | 997 | ||
| ... | @@ -988,8 +1021,8 @@ public class CriteriaTest { | ... | @@ -988,8 +1021,8 @@ public class CriteriaTest { |
| 988 | Criterion matchMplsLabel = Criteria.matchMplsLabel(mpls1); | 1021 | Criterion matchMplsLabel = Criteria.matchMplsLabel(mpls1); |
| 989 | MplsCriterion mplsCriterion = | 1022 | MplsCriterion mplsCriterion = |
| 990 | checkAndConvert(matchMplsLabel, | 1023 | checkAndConvert(matchMplsLabel, |
| 991 | - Criterion.Type.MPLS_LABEL, | 1024 | + Criterion.Type.MPLS_LABEL, |
| 992 | - MplsCriterion.class); | 1025 | + MplsCriterion.class); |
| 993 | assertThat(mplsCriterion.label(), is(equalTo(mpls1))); | 1026 | assertThat(mplsCriterion.label(), is(equalTo(mpls1))); |
| 994 | } | 1027 | } |
| 995 | 1028 | ||
| ... | @@ -1025,10 +1058,10 @@ public class CriteriaTest { | ... | @@ -1025,10 +1058,10 @@ public class CriteriaTest { |
| 1025 | */ | 1058 | */ |
| 1026 | @Test | 1059 | @Test |
| 1027 | public void testTunnelIdCriterionEquals() { | 1060 | public void testTunnelIdCriterionEquals() { |
| 1028 | - new EqualsTester() | 1061 | + new EqualsTester() |
| 1029 | - .addEqualityGroup(matchTunnelId1, sameAsMatchTunnelId1) | 1062 | + .addEqualityGroup(matchTunnelId1, sameAsMatchTunnelId1) |
| 1030 | - .addEqualityGroup(matchTunnelId2) | 1063 | + .addEqualityGroup(matchTunnelId2) |
| 1031 | - .testEquals(); | 1064 | + .testEquals(); |
| 1032 | } | 1065 | } |
| 1033 | 1066 | ||
| 1034 | // IPv6ExthdrFlagsCriterion class | 1067 | // IPv6ExthdrFlagsCriterion class |
| ... | @@ -1039,11 +1072,11 @@ public class CriteriaTest { | ... | @@ -1039,11 +1072,11 @@ public class CriteriaTest { |
| 1039 | @Test | 1072 | @Test |
| 1040 | public void testMatchIPv6ExthdrFlagsMethod() { | 1073 | public void testMatchIPv6ExthdrFlagsMethod() { |
| 1041 | Criterion matchExthdrFlags = | 1074 | Criterion matchExthdrFlags = |
| 1042 | - Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | 1075 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); |
| 1043 | IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = | 1076 | IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = |
| 1044 | checkAndConvert(matchExthdrFlags, | 1077 | checkAndConvert(matchExthdrFlags, |
| 1045 | - Criterion.Type.IPV6_EXTHDR, | 1078 | + Criterion.Type.IPV6_EXTHDR, |
| 1046 | - IPv6ExthdrFlagsCriterion.class); | 1079 | + IPv6ExthdrFlagsCriterion.class); |
| 1047 | assertThat(exthdrFlagsCriterion.exthdrFlags(), | 1080 | assertThat(exthdrFlagsCriterion.exthdrFlags(), |
| 1048 | is(equalTo(ipv6ExthdrFlags1))); | 1081 | is(equalTo(ipv6ExthdrFlags1))); |
| 1049 | } | 1082 | } | ... | ... |
-
Please register or login to post a comment