Fix remaining checkstyle violations in openflowjava 40/67640/1
authorTom Pantelis <tompantelis@gmail.com>
Sat, 27 Jan 2018 17:24:44 +0000 (12:24 -0500)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 27 Jan 2018 17:24:44 +0000 (12:24 -0500)
Change-Id: I720977b96996a462946c5b6114a6b6b7dd1285bc
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java
openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java
openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java
openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java
openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java

index 412eff7f85561f179cb6d5082677215b90c5d46c..1e40a8a2fdfc4cbfdb741a6da2d99164e23e1356 100644 (file)
@@ -64,6 +64,7 @@ public interface SerializerRegistry {
     boolean isGroupAddModEnabled();
 
     /**
+     * Sets whether or not group add mod messages are enabled.
      *
      * @param isGroupAddModEnabled true if group add mod messages are enabled
      */
index a747df745d3141a87a4d8860ba954979f9930133..3300d8ede33efa773c90753a44959f22f48eb1bd 100644 (file)
@@ -14,6 +14,7 @@ import java.util.Deque;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import org.junit.After;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
@@ -40,6 +41,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * End-to-end integration test.
+ *
  * @author michal.polkorab
  * @author timotej.kubas
  */
@@ -57,13 +60,13 @@ public class IntegrationTest {
     private SwitchConnectionProviderImpl switchConnectionProvider;
     private ConnectionConfigurationImpl connConfig;
 
-    private Thread t;
+    private Thread thread;
+
+    private enum ClientType {
+        SIMPLE,
+        LISTENING
+    }
 
-    private enum ClientType {SIMPLE, LISTENING}
-    /**
-     * @param protocol communication protocol to be used during test
-     * @throws Exception
-     */
     public void setUp(final TransportProtocol protocol) throws Exception {
         LOGGER.debug("\n starting test -------------------------------");
 
@@ -77,7 +80,8 @@ public class IntegrationTest {
                     "/selfSignedController", PathType.CLASSPATH,
                     new ArrayList<String>());
         }
-        connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true, false);
+        connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration,
+                SWITCH_IDLE_TIMEOUT, true, false);
         connConfig.setTransferProtocol(protocol);
         mockPlugin = new MockPlugin();
 
@@ -93,9 +97,6 @@ public class IntegrationTest {
         }
     }
 
-    /**
-     * @throws Exception
-     */
     @After
     public void tearDown() throws Exception {
         switchConnectionProvider.close();
@@ -103,8 +104,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library integration and communication test with handshake
-     * @throws Exception
+     * Library integration and communication test with handshake.
      */
     @Test
     public void testHandshake() throws Exception {
@@ -112,7 +112,8 @@ public class IntegrationTest {
         final int amountOfCLients = 1;
         final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
         final ScenarioHandler handler = new ScenarioHandler(scenario);
-        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE);
+        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler,
+                TransportProtocol.TCP, ClientType.SIMPLE);
         final OFClient firstClient = clients.get(0);
         firstClient.getScenarioDone().get();
         Thread.sleep(1000);
@@ -121,8 +122,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library integration and secured communication test with handshake
-     * @throws Exception
+     * Library integration and secured communication test with handshake.
      */
     @Test
     public void testTlsHandshake() throws Exception {
@@ -130,7 +130,8 @@ public class IntegrationTest {
         final int amountOfCLients = 1;
         final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
         final ScenarioHandler handler = new ScenarioHandler(scenario);
-        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
+        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler,
+                TransportProtocol.TLS, ClientType.SIMPLE);
         final OFClient firstClient = clients.get(0);
         firstClient.getScenarioDone().get();
         Thread.sleep(1000);
@@ -139,8 +140,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library integration and communication test with handshake + echo exchange
-     * @throws Exception
+     * Library integration and communication test with handshake + echo exchange.
      */
     @Test
     public void testHandshakeAndEcho() throws Exception {
@@ -152,7 +152,8 @@ public class IntegrationTest {
         scenario.addFirst(new SleepEvent(1000));
         scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
         final ScenarioHandler handler = new ScenarioHandler(scenario);
-        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE);
+        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler,
+                TransportProtocol.TCP, ClientType.SIMPLE);
         final OFClient firstClient = clients.get(0);
         firstClient.getScenarioDone().get();
 
@@ -160,8 +161,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library integration and secured communication test with handshake + echo exchange
-     * @throws Exception
+     * Library integration and secured communication test with handshake + echo exchange.
      */
     @Test
     public void testTlsHandshakeAndEcho() throws Exception {
@@ -173,7 +173,8 @@ public class IntegrationTest {
         scenario.addFirst(new SleepEvent(1000));
         scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
         final ScenarioHandler handler = new ScenarioHandler(scenario);
-        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
+        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler,
+                TransportProtocol.TLS, ClientType.SIMPLE);
         final OFClient firstClient = clients.get(0);
         firstClient.getScenarioDone().get();
 
@@ -181,8 +182,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library udp integration and communication test with handshake + echo exchange
-     * @throws Exception
+     * Library udp integration and communication test with handshake + echo exchange.
      */
     @Test
     public void testUdpHandshakeAndEcho() throws Exception {
@@ -194,7 +194,8 @@ public class IntegrationTest {
         scenario.addFirst(new SleepEvent(1000));
         scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
         final ScenarioHandler handler = new ScenarioHandler(scenario);
-        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE);
+        final List<OFClient> clients = createAndStartClient(amountOfCLients, handler,
+                TransportProtocol.UDP, ClientType.SIMPLE);
         final OFClient firstClient = clients.get(0);
         firstClient.getScenarioDone().get();
 
@@ -202,8 +203,7 @@ public class IntegrationTest {
     }
 
     /**
-     * Library integration and communication test (with virtual machine)
-     * @throws Exception
+     * Library integration and communication test (with virtual machine).
      */
     //@Test
     public void testCommunicationWithVM() throws Exception {
@@ -211,13 +211,16 @@ public class IntegrationTest {
     }
 
     /**
-     * @param amountOfCLients
+     * Creates and start a client.
+     *
+     * @param amountOfCLients number of clients
      * @param protocol true if encrypted connection should be used
      * @return new clients up and running
      * @throws ExecutionException if some client could not start
      */
     private List<OFClient> createAndStartClient(final int amountOfCLients, final ScenarioHandler scenarioHandler,
-            final TransportProtocol protocol, final ClientType clientType) throws ExecutionException {
+            final TransportProtocol protocol, final ClientType clientType)
+                    throws ExecutionException, InterruptedException, TimeoutException {
         final List<OFClient> clientsHorde = new ArrayList<>();
         for (int i = 0; i < amountOfCLients; i++) {
             LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress());
@@ -244,23 +247,15 @@ public class IntegrationTest {
             sc.setScenarioHandler(scenarioHandler);
             clientsHorde.add(sc);
             //sc.run();
-            t = new Thread(sc);
-            t.start();
+            thread = new Thread(sc);
+            thread.start();
         }
         for (final OFClient sc : clientsHorde) {
-            try {
-                sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
-            } catch (final Exception e) {
-                LOGGER.error("createAndStartClient: Something borked ... ", e.getMessage(), e);
-                throw new ExecutionException(e);
-            }
+            sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
         }
         return clientsHorde;
     }
 
-    /**
-     * @throws Exception
-     */
     @Test
     public void testInitiateConnection() throws Exception {
         setUp(TransportProtocol.TCP);
index dadfa73c1907b91ed3472218e002bacf03ca3b27..cef1255a1ff8725b59bd81d7ac3639735755e659 100644 (file)
@@ -8,13 +8,13 @@
 
 package org.opendaylight.openflowjava.protocol.it.integration;
 
+import com.google.common.util.concurrent.SettableFuture;
 import java.net.InetAddress;
 import java.util.Arrays;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
@@ -43,21 +43,19 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
- * @author michal.polkorab
+ * Mock plugin.
  *
+ * @author michal.polkorab
  */
 public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler,
         SystemNotificationsListener, ConnectionReadyListener {
 
     protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class);
     protected volatile ConnectionAdapter adapter;
-    private SettableFuture<Void> finishedFuture;
+    private final SettableFuture<Void> finishedFuture;
     private int idleCounter = 0;
 
-    /** Creates MockPlugin */
     public MockPlugin() {
         LOGGER.trace("Creating MockPlugin");
         finishedFuture = SettableFuture.create();
@@ -83,18 +81,15 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     @Override
     public void onEchoRequestMessage(final EchoRequestMessage notification) {
         LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter);
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
-                EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
-                replyBuilder.setVersion((short) 4);
-                replyBuilder.setXid(notification.getXid());
-                EchoReplyInput echoReplyInput = replyBuilder.build();
-                adapter.echoReply(echoReplyInput);
-                LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
-                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
-            }
+        new Thread(() -> {
+            LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
+            EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
+            replyBuilder.setVersion((short) 4);
+            replyBuilder.setXid(notification.getXid());
+            EchoReplyInput echoReplyInput = replyBuilder.build();
+            adapter.echoReply(echoReplyInput);
+            LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
+            LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
         }).start();
     }
 
@@ -118,23 +113,15 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 
     @Override
     public void onHelloMessage(HelloMessage notification) {
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                LOGGER.debug("MockPlugin.onHelloMessage().run() Hello message received");
-                HelloInputBuilder hib = new HelloInputBuilder();
-                hib.setVersion((short) 4);
-                hib.setXid(2L);
-                HelloInput hi = hib.build();
-                adapter.hello(hi);
-                LOGGER.debug("hello msg sent");
-                new Thread(new Runnable() {
-                    @Override
-                    public void run() {
-                        getSwitchFeatures();
-                    }
-                }).start();
-            }
+        new Thread(() -> {
+            LOGGER.debug("MockPlugin.onHelloMessage().run() Hello message received");
+            HelloInputBuilder hib = new HelloInputBuilder();
+            hib.setVersion((short) 4);
+            hib.setXid(2L);
+            HelloInput hi = hib.build();
+            adapter.hello(hi);
+            LOGGER.debug("hello msg sent");
+            new Thread(() -> getSwitchFeatures()).start();
         }).start();
 
     }
@@ -161,18 +148,15 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         }
     }
 
-    protected void shutdown() {
-        try {
-            LOGGER.debug("MockPlugin.shutdown() sleeping 5... : {}", System.identityHashCode(this));
-            Thread.sleep(500);
-            if (adapter != null) {
-                Future<Boolean> disconnect = adapter.disconnect();
-                disconnect.get();
-                LOGGER.debug("MockPlugin.shutdown() Disconnected");
-            }
-        } catch (Exception e) {
-            LOGGER.error("MockPlugin.shutdown() exception caught: ", e.getMessage(), e);
+    protected void shutdown() throws InterruptedException, ExecutionException {
+        LOGGER.debug("MockPlugin.shutdown() sleeping 5... : {}", System.identityHashCode(this));
+        Thread.sleep(500);
+        if (adapter != null) {
+            Future<Boolean> disconnect = adapter.disconnect();
+            disconnect.get();
+            LOGGER.debug("MockPlugin.shutdown() Disconnected");
         }
+
         finishedFuture.set(null);
     }
 
@@ -206,9 +190,6 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         LOGGER.debug("disconnection occured: {}", notification.getInfo());
     }
 
-    /**
-     * @return finishedFuture object
-     */
     public SettableFuture<Void> getFinishedFuture() {
         return finishedFuture;
     }
@@ -220,7 +201,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     }
 
     /**
-     * @return number of occured idleEvents
+     * Returns number of occurred idleEvents.
      */
     public int getIdleCounter() {
         return idleCounter;
@@ -232,8 +213,9 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     }
 
     /**
-     * Initiates connection to device
-     * @param switchConnectionProvider
+     * Initiates connection to device.
+     *
+     * @param switchConnectionProvider the SwitchConnectionProviderImpl
      * @param host - host IP
      * @param port - port number
      */
index 0837399ef41791376b10b81a3094665bcf02fbc3..549d7dd71959e4793e28f0d44c59be8488fb5beb 100644 (file)
@@ -9,42 +9,47 @@
 
 package org.opendaylight.openflowjava.protocol.spi.connection;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
+ * Provides handling for a swicth connection.
+ *
  * @author mirehak
  * @author michal.polkorab
- *
  */
 public interface SwitchConnectionProvider extends AutoCloseable,
         SerializerExtensionProvider, DeserializerExtensionProvider {
 
     /**
-     * return the connection configuration
+     * Returns the connection configuration.
+     *
      * @return configuration [protocol, port, address and supported features]
      */
     ConnectionConfiguration getConfiguration();
 
     /**
-     * start listening to switches, but please don't forget to do
-     * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first
+     * Start listening to switches, but please don't forget to do
+     * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first.
+     *
      * @return future, triggered to true, when listening channel is up and running
      */
     ListenableFuture<Boolean> startup();
 
     /**
-     * stop listening to switches
+     * Stop listening to switches.
+     *
      * @return future, triggered to true, when all listening channels are down
      */
     ListenableFuture<Boolean> shutdown();
 
     /**
+     * Sets the SwitchConnectionHandler.
+     *
      * @param switchConHandler instance being informed when new switch connects
      */
     void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler);
-}
\ No newline at end of file
+}
index 3779a5ebe3b3f2218495b455b3ebff35ba1d6272..89a831e5bd8e699cf44ced49340bec91c8951170 100644 (file)
@@ -9,20 +9,19 @@
 package org.opendaylight.openflowjava.protocol.spi.statistics;
 
 /**
- * Used for JConsole service
+ * Used for JConsole service.
  *
  * @author michal.polkorab
  */
 public interface StatisticsHandler {
 
     /**
-     * Resets all counters
+     * Resets all counters.
      */
-    public void resetCounters();
+    void resetCounters();
 
     /**
-     * Prints statistics
-     * @return statistics
+     * Returns statistics.
      */
-    public String printStatistics();
-}
\ No newline at end of file
+    String printStatistics();
+}