Fix build broken due to Checkstyle, and prepare for more CS to come 48/42348/2
authorMichael Vorburger <vorburger@redhat.com>
Fri, 22 Jul 2016 22:41:08 +0000 (00:41 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 22 Jul 2016 23:30:01 +0000 (01:30 +0200)
preparing for https://git.opendaylight.org/gerrit/#/c/41305/ with:
* Utility classes should have private constructor
* potential future problems re. hidden fields
* inner assignments

and also for the just merged
https://git.opendaylight.org/gerrit/#/c/40957/, which I think that
something here just got added and missed in the verification for
c/40957, so was about to cause build failures - so this one urgently
needs to get merged ASAP!

Change-Id: I4b608fa1501ff758527672fdd9569afe36933cfd
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AclServiceOFFlowBuilder.java
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/utils/AclConstants.java
vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/VirtualSubnet.java
vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/utils/Ipv6Constants.java
vpnservice/ipv6service/impl/src/test/java/org/opendaylight/netvirt/ipv6service/Ipv6PktHandlerTest.java
vpnservice/ipv6service/impl/src/test/java/org/opendaylight/netvirt/ipv6service/utils/Ipv6ServiceUtilsTest.java

index 9cab158419d0b088969d0771897e254daf91cf94..3046b779afe3ae602796b56eab146d51a526996d 100644 (file)
@@ -27,6 +27,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fiel
 
 public class AclServiceOFFlowBuilder {
 
+    private AclServiceOFFlowBuilder() {
+    }
+
     /**
      * Converts IP matches into flows.
      * @param matches the matches
index 40962448a3925f65ee59f7e16472cccb83edeead..4dfcfb7e7592c281d2d5634ff826b95526d4edaf 100644 (file)
@@ -24,4 +24,7 @@ public final class AclConstants {
     public static final short INGRESS_ACL_NEXT_TABLE_ID = 252;
     public static final short INGRESS_ACL_SERVICE_PRIORITY = 10;
     public static final short INGRESS_ACL_DEFAULT_FLOW_PRIORITY = 1;
+
+    private AclConstants() {
+    }
 }
index a08f0ff7d171942ee097364430d44486a1ecbc06..3624ed57f4acac58a641482c395acc4d0a71a576 100644 (file)
@@ -84,6 +84,7 @@ public class VirtualSubnet  {
         return gatewayIp;
     }
 
+    @SuppressWarnings("checkstyle:HiddenField")
     public VirtualSubnet setIPVersion(String ipVersion) {
         this.ipVersion = ipVersion;
         return this;
index 05194ccc37d2fb82f3cdfa10a651fa1aae55a16a..a46d39bd7565fe45745b8ac5adeef400a1d467fe 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.netvirt.ipv6service.utils;
 
 public class Ipv6Constants {
+
     public static final int IP_V6_ETHTYPE = 34525;
     public static final int ICMP_V6 = 1;
 
@@ -45,4 +46,8 @@ public class Ipv6Constants {
     public static final String IP_VERSION_V4 = "IPv4";
     public static final String IP_VERSION_V6 = "IPv6";
     public static final String NETWORK_ROUTER_INTERFACE = "network:router_interface";
+
+    private Ipv6Constants() {
+    }
+
 }
index b2b06003a22f75dff1fa7c72e720033795ce0cc2..e4e03c8625280eefc0abdf5596c025a8bdcc18fa 100644 (file)
@@ -9,7 +9,10 @@
 package org.opendaylight.netvirt.ipv6service;
 
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -62,7 +65,7 @@ public class Ipv6PktHandlerTest {
     public void testOnPacketReceivedWithInvalidPacket() throws Exception {
         pktHandler.onPacketReceived(null);
         verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
-        byte pktArray[] = {};
+        byte[] pktArray = {};
         PacketReceived packet = new PacketReceivedBuilder().setPayload(pktArray).build();
         pktHandler.onPacketReceived(packet);
         verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
@@ -231,26 +234,6 @@ public class Ipv6PktHandlerTest {
                 .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
         NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
 
-        byte[] expected_payload = buildPacket(
-                "08 00 27 D4 10 BB",                               // Destination MAC
-                "08 00 27 FE 8F 95",                               // Source MAC
-                "86 DD",                                           // Ethertype - IPv6
-                "60 00 00 00",                                     // Version 6, traffic class 0, no flowlabel
-                "00 20",                                           // Payload length
-                "3A",                                              // Next header is ICMPv6
-                "FF",                                              // Hop limit
-                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Source IP
-                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // Destination IP
-                "88",                                              // ICMPv6 neighbor advertisement.
-                "00",                                              // Code
-                "17 D6",                                           // Checksum (valid)
-                "E0 00 00 00",                                     // Flags
-                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Target Address
-                "02",                                              // Type: Target Link-Layer Option
-                "01",                                              // Option length
-                "08 00 27 FE 8F 95"                                // Target Link layer address
-        );
-
         BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
         Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
         MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
@@ -276,9 +259,28 @@ public class Ipv6PktHandlerTest {
         //wait on this thread until the async job is completed in the packet handler.
         waitForPacketProcessing();
         verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
-        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expected_payload).
-                setNode(new NodeRef(ncId)).
-                setEgress(ncRef).build());
+
+        byte[] expectedPayload = buildPacket(
+                "08 00 27 D4 10 BB",                               // Destination MAC
+                "08 00 27 FE 8F 95",                               // Source MAC
+                "86 DD",                                           // Ethertype - IPv6
+                "60 00 00 00",                                     // Version 6, traffic class 0, no flowlabel
+                "00 20",                                           // Payload length
+                "3A",                                              // Next header is ICMPv6
+                "FF",                                              // Hop limit
+                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Source IP
+                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // Destination IP
+                "88",                                              // ICMPv6 neighbor advertisement.
+                "00",                                              // Code
+                "17 D6",                                           // Checksum (valid)
+                "E0 00 00 00",                                     // Flags
+                "FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Target Address
+                "02",                                              // Type: Target Link-Layer Option
+                "01",                                              // Option length
+                "08 00 27 FE 8F 95"                                // Target Link layer address
+        );
+        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload)
+                .setNode(new NodeRef(ncId)).setEgress(ncRef).build());
     }
 
     @Test
@@ -294,8 +296,8 @@ public class Ipv6PktHandlerTest {
         when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8::1"));
 
         VirtualSubnet v6Subnet = new VirtualSubnet();
-        VirtualRouter vRouter = new VirtualRouter();
-        v6Subnet.setRouter(vRouter);
+        VirtualRouter virtualRouter = new VirtualRouter();
+        v6Subnet.setRouter(virtualRouter);
         v6Subnet.setGatewayIp(gwIpAddress);
         v6Subnet.setIpv6AddressMode(Ipv6Constants.IPV6_SLAAC);
         v6Subnet.setIpv6RAMode(Ipv6Constants.IPV6_SLAAC);
@@ -308,7 +310,33 @@ public class Ipv6PktHandlerTest {
         InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
         NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
-        byte[] expected_payload = buildPacket(
+        BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
+        Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
+        MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
+        pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(buildPacket(
+                "33 33 00 00 00 02",                               // Destination MAC
+                "FA 16 3E 69 2C F3",                               // Source MAC
+                "86 DD",                                           // IPv6
+                "60 00 00 00",                                     // Version 6, traffic class E0, no flowlabel
+                "00 10",                                           // Payload length
+                "3A",                                              // Next header is ICMPv6
+                "FF",                                              // Hop limit
+                "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Source IP
+                "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // Destination IP
+                "85",                                              // ICMPv6 router solicitation
+                "00",                                              // Code
+                "B4 47",                                           // Checksum (valid)
+                "00 00 00 00",                                     // ICMPv6 message body
+                "01",                                              // ICMPv6 Option: Source Link Layer Address
+                "01",                                              // Length
+                "FA 16 3E 69 2C F3"                                // Link Layer Address
+        )).setIngress(ncRef).setMatch(matchbuilder.build()).build());
+
+        //wait on this thread until the async job is completed in the packet handler.
+        waitForPacketProcessing();
+        verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
+
+        byte[] expectedPayload = buildPacket(
                 "FA 16 3E 69 2C F3",                               // Destination MAC
                 "FA 16 3E 4E 18 0C",                               // Source MAC
                 "86 DD",                                           // IPv6
@@ -338,35 +366,8 @@ public class Ipv6PktHandlerTest {
                 "00 00 00 00",                                     // Reserved
                 "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 00"  // Prefix
         );
-
-        BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
-        Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
-        MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
-        pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(buildPacket(
-                "33 33 00 00 00 02",                               // Destination MAC
-                "FA 16 3E 69 2C F3",                               // Source MAC
-                "86 DD",                                           // IPv6
-                "60 00 00 00",                                     // Version 6, traffic class E0, no flowlabel
-                "00 10",                                           // Payload length
-                "3A",                                              // Next header is ICMPv6
-                "FF",                                              // Hop limit
-                "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Source IP
-                "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // Destination IP
-                "85",                                              // ICMPv6 router solicitation
-                "00",                                              // Code
-                "B4 47",                                           // Checksum (valid)
-                "00 00 00 00",                                     // ICMPv6 message body
-                "01",                                              // ICMPv6 Option: Source Link Layer Address
-                "01",                                              // Length
-                "FA 16 3E 69 2C F3"                                // Link Layer Address
-        )).setIngress(ncRef).setMatch(matchbuilder.build()).build());
-
-        //wait on this thread until the async job is completed in the packet handler.
-        waitForPacketProcessing();
-        verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
-        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expected_payload).
-                setNode(new NodeRef(ncId)).
-                setEgress(ncRef).build());
+        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload)
+                .setNode(new NodeRef(ncId)).setEgress(ncRef).build());
     }
 
     @Test
@@ -382,22 +383,22 @@ public class Ipv6PktHandlerTest {
         when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8:1111::1"));
 
         VirtualSubnet v6Subnet1 = new VirtualSubnet();
-        VirtualRouter vRouter = new VirtualRouter();
-        v6Subnet1.setRouter(vRouter);
+        VirtualRouter virtualRouter = new VirtualRouter();
+        v6Subnet1.setRouter(virtualRouter);
         v6Subnet1.setGatewayIp(gwIpAddress);
         v6Subnet1.setIpv6AddressMode(Ipv6Constants.IPV6_SLAAC);
         v6Subnet1.setIpv6RAMode(Ipv6Constants.IPV6_SLAAC);
         v6Subnet1.setSubnetCidr(new IpPrefix("2001:db8:1111::/64".toCharArray()));
 
         VirtualSubnet v6Subnet2 = new VirtualSubnet();
-        v6Subnet2.setRouter(vRouter);
+        v6Subnet2.setRouter(virtualRouter);
         v6Subnet2.setGatewayIp(gwIpAddress);
         v6Subnet2.setIpv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATELESS);
         v6Subnet2.setIpv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATELESS);
         v6Subnet2.setSubnetCidr(new IpPrefix("2001:db8:2222::/64".toCharArray()));
 
         VirtualSubnet v6Subnet3 = new VirtualSubnet();
-        v6Subnet3.setRouter(vRouter);
+        v6Subnet3.setRouter(virtualRouter);
         v6Subnet3.setGatewayIp(gwIpAddress);
         v6Subnet3.setIpv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL);
         v6Subnet3.setIpv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL);
@@ -412,7 +413,33 @@ public class Ipv6PktHandlerTest {
         InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
         NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
-        byte[] expected_payload = buildPacket(
+        BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
+        Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
+        MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
+        pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(buildPacket(
+                "33 33 00 00 00 02",                               // Destination MAC
+                "FA 16 3E 69 2C F3",                               // Source MAC
+                "86 DD",                                           // IPv6
+                "60 00 00 00",                                     // Version 6, traffic class E0, no flowlabel
+                "00 10",                                           // Payload length
+                "3A",                                              // Next header is ICMPv6
+                "FF",                                              // Hop limit
+                "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Source IP
+                "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // Destination IP
+                "85",                                              // ICMPv6 router solicitation
+                "00",                                              // Code
+                "B4 47",                                           // Checksum (valid)
+                "00 00 00 00",                                     // ICMPv6 message body
+                "01",                                              // ICMPv6 Option: Source Link Layer Address
+                "01",                                              // Length
+                "FA 16 3E 69 2C F3"                                // Link Layer Address
+        )).setIngress(ncRef).setMatch(matchbuilder.build()).build());
+
+        //wait on this thread until the async job is completed in the packet handler.
+        waitForPacketProcessing();
+        verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
+
+        byte[] expectedPayload = buildPacket(
                 "FA 16 3E 69 2C F3",                               // Destination MAC
                 "50 7B 9D 78 54 F3",                               // Source MAC
                 "86 DD",                                           // IPv6
@@ -459,34 +486,9 @@ public class Ipv6PktHandlerTest {
                 "20 01 0D B8 33 33 00 00 00 00 00 00 00 00 00 00"  // Prefix
         );
 
-        BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
-        Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
-        MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
-        pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(buildPacket(
-                "33 33 00 00 00 02",                               // Destination MAC
-                "FA 16 3E 69 2C F3",                               // Source MAC
-                "86 DD",                                           // IPv6
-                "60 00 00 00",                                     // Version 6, traffic class E0, no flowlabel
-                "00 10",                                           // Payload length
-                "3A",                                              // Next header is ICMPv6
-                "FF",                                              // Hop limit
-                "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Source IP
-                "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // Destination IP
-                "85",                                              // ICMPv6 router solicitation
-                "00",                                              // Code
-                "B4 47",                                           // Checksum (valid)
-                "00 00 00 00",                                     // ICMPv6 message body
-                "01",                                              // ICMPv6 Option: Source Link Layer Address
-                "01",                                              // Length
-                "FA 16 3E 69 2C F3"                                // Link Layer Address
-        )).setIngress(ncRef).setMatch(matchbuilder.build()).build());
-
-        //wait on this thread until the async job is completed in the packet handler.
-        waitForPacketProcessing();
-        verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
-        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expected_payload).
-                setNode(new NodeRef(ncId)).
-                setEgress(ncRef).build());
+        verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload)
+                .setNode(new NodeRef(ncId))
+                .setEgress(ncRef).build());
     }
 
     private void waitForPacketProcessing() throws InterruptedException {
index 698d1e84812ff43a9ba5a2f9ac52417826fe1f99..a2a1380b4f2c644fb3eb06be2ed8d1a7b861071f 100644 (file)
@@ -16,14 +16,14 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 
 /**
- * Unit test fort {@link Ipv6ServiceUtilsTest}
+ * Unit test fort {@link Ipv6ServiceUtilsTest}.
  */
 public class Ipv6ServiceUtilsTest {
     private Ipv6ServiceUtils instance;
 
     @Before
     public void initTest() {
-         instance = Ipv6ServiceUtils.getInstance();
+        instance = Ipv6ServiceUtils.getInstance();
     }
 
     /**
@@ -47,4 +47,4 @@ public class Ipv6ServiceUtilsTest {
         expectedLinkLocalAddress = new Ipv6Address("fe80:0:0:0:527b:9dff:fe78:54f3");
         assertEquals(expectedLinkLocalAddress, instance.getIpv6LinkLocalAddressFromMac(mac));
     }
-}
\ No newline at end of file
+}