Fix checkstyle warnings for impl/connection package and OpenFlowPluginProviderImpl 62/62362/3
authormiroslav.macko <miroslav.macko@pantheon.tech>
Mon, 28 Aug 2017 12:47:12 +0000 (14:47 +0200)
committerTomas Slusny <tomas.slusny@pantheon.tech>
Thu, 14 Sep 2017 11:47:51 +0000 (13:47 +0200)
See also: bug 8607

Change-Id: I6d9e1fcf02d3c282f7e640ab6e30858d79b02289
Signed-off-by: miroslav.macko <miroslav.macko@pantheon.tech>
16 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/ConnectionReadyListenerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/OutboundQueueProviderImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/testutil/MsgGeneratorTestUtils.java

index 184d2304a232982651c87febd79f4ef7dc68d1db..ff68aba29cc369a912d72452937143d8133edc58 100644 (file)
@@ -89,7 +89,8 @@ public class OpenFlowPluginProviderImpl implements
                     MessageIntelligenceAgencyMXBean.class.getPackage().getName(),
                     MessageIntelligenceAgencyMXBean.class.getSimpleName());
 
-    private final HashedWheelTimer hashedWheelTimer = new HashedWheelTimer(TICK_DURATION, TimeUnit.MILLISECONDS, TICKS_PER_WHEEL);
+    private final HashedWheelTimer hashedWheelTimer =
+            new HashedWheelTimer(TICK_DURATION, TimeUnit.MILLISECONDS, TICKS_PER_WHEEL);
     private final NotificationPublishService notificationPublishService;
     private final ExtensionConverterManager extensionConverterManager;
     private final DataBroker dataBroker;
@@ -162,15 +163,16 @@ public class OpenFlowPluginProviderImpl implements
     }
 
     private ListenableFuture<List<Boolean>> shutdownSwitchConnections() {
-        final ListenableFuture<List<Boolean>> listListenableFuture = Futures.allAsList(switchConnectionProviders.stream().map(switchConnectionProvider -> {
-            // Revert deserializers to their original state
-            if (config.isUseSingleLayerSerialization()) {
-                DeserializerInjector.revertDeserializers(switchConnectionProvider);
-            }
+        final ListenableFuture<List<Boolean>> listListenableFuture =
+                Futures.allAsList(switchConnectionProviders.stream().map(switchConnectionProvider -> {
+                    // Revert deserializers to their original state
+                    if (config.isUseSingleLayerSerialization()) {
+                        DeserializerInjector.revertDeserializers(switchConnectionProvider);
+                    }
 
-            // Shutdown switch connection provider
-            return switchConnectionProvider.shutdown();
-        }).collect(Collectors.toSet()));
+                    // Shutdown switch connection provider
+                    return switchConnectionProvider.shutdown();
+                }).collect(Collectors.toSet()));
 
         Futures.addCallback(listListenableFuture, new FutureCallback<List<Boolean>>() {
             @Override
@@ -272,6 +274,7 @@ public class OpenFlowPluginProviderImpl implements
         unregisterMXBean(MESSAGE_INTELLIGENCE_AGENCY_MX_BEAN_NAME);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private static void gracefulShutdown(final AutoCloseable closeable) {
         if (Objects.isNull(closeable)) {
             return;
@@ -291,7 +294,7 @@ public class OpenFlowPluginProviderImpl implements
 
         try {
             timer.stop();
-        } catch (Exception e) {
+        } catch (IllegalStateException e) {
             LOG.warn("Failed to shutdown {} gracefully.", timer);
         }
     }
@@ -303,7 +306,7 @@ public class OpenFlowPluginProviderImpl implements
 
         try {
             threadPoolExecutor.shutdownNow();
-        } catch (Exception e) {
+        } catch (SecurityException e) {
             LOG.warn("Failed to shutdown {} gracefully.", threadPoolExecutor);
         }
     }
index 1f2af070b6db5f12578988bc5de9edb8e4cdbbf4..cc21a7e8fb9f8feda9bb533dcad66124d378d556 100644 (file)
@@ -36,9 +36,6 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class ConnectionContextImpl implements ConnectionContext {
 
     private final ConnectionAdapter connectionAdapter;
@@ -54,7 +51,9 @@ public class ConnectionContextImpl implements ConnectionContext {
     private List<PortStatusMessage> portStatusMessages = new ArrayList<>();
 
     /**
-     * @param connectionAdapter
+     * Constructor.
+     *
+     * @param connectionAdapter - connection adapter
      */
     public ConnectionContextImpl(final ConnectionAdapter connectionAdapter) {
         this.connectionAdapter = connectionAdapter;
@@ -114,13 +113,8 @@ public class ConnectionContextImpl implements ConnectionContext {
     private void closeHandshakeContext() {
         LOG.debug("Trying closing handshake context for node {}", getSafeNodeIdForLOG());
         if (handshakeContext != null) {
-            try {
-                handshakeContext.close();
-            } catch (Exception e) {
-                LOG.error("handshake context closing failed:{} ", e);
-            } finally {
-                handshakeContext = null;
-            }
+            handshakeContext.close();
+            handshakeContext = null;
         }
     }
 
@@ -131,7 +125,8 @@ public class ConnectionContextImpl implements ConnectionContext {
 
     private void disconnectDevice(final boolean propagate,
                                   final boolean forced) {
-        final String device = Objects.nonNull(nodeId) ? nodeId.getValue() : getConnectionAdapter().getRemoteAddress().toString();
+        final String device =
+                Objects.nonNull(nodeId) ? nodeId.getValue() : getConnectionAdapter().getRemoteAddress().toString();
         final short auxiliaryId = Optional
                 .ofNullable(getFeatures())
                 .flatMap(features -> Optional
@@ -181,7 +176,8 @@ public class ConnectionContextImpl implements ConnectionContext {
     }
 
     /**
-     * This method returns safe nodeId for logging
+     * Get safe nodeId for logging.
+     *
      * @return string value od nodeId or string "null"
      */
     @Override
@@ -190,7 +186,8 @@ public class ConnectionContextImpl implements ConnectionContext {
     }
 
     @Override
-    public void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration) {
+    public void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider>
+                                                               outboundQueueHandlerRegistration) {
         this.outboundQueueHandlerRegistration = outboundQueueHandlerRegistration;
     }
 
@@ -260,16 +257,16 @@ public class ConnectionContextImpl implements ConnectionContext {
     }
 
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object object) {
+        if (this == object) {
             return true;
         }
 
-        if (o == null || getClass() != o.getClass()) {
+        if (object == null || getClass() != object.getClass()) {
             return false;
         }
 
-        ConnectionContextImpl that = (ConnectionContextImpl) o;
+        ConnectionContextImpl that = (ConnectionContextImpl) object;
 
         if (!connectionAdapter.equals(that.connectionAdapter)) {
             return false;
@@ -340,21 +337,21 @@ public class ConnectionContextImpl implements ConnectionContext {
         }
 
         @Override
-        public boolean equals(Object o) {
-            if (this == o) {
+        public boolean equals(Object object) {
+            if (this == object) {
                 return true;
             }
 
-            if (o == null || getClass() != o.getClass()) {
+            if (object == null || getClass() != object.getClass()) {
                 return false;
             }
 
-            DeviceInfoImpl that = (DeviceInfoImpl) o;
+            DeviceInfoImpl that = (DeviceInfoImpl) object;
 
-            return  (nodeId.equals(that.nodeId) &&
-                    nodeII.equals(that.nodeII) &&
-                    version.equals(that.version) &&
-                    datapathId.equals(that.datapathId));
+            return  (nodeId.equals(that.nodeId)
+                    && nodeII.equals(that.nodeII)
+                    && version.equals(that.version)
+                    && datapathId.equals(that.datapathId));
 
         }
 
index cd9db49634427e1f93b89c29802f53a7d1a0142e..b09b6f9eee6918026dc5b8351a9963752863ace6 100644 (file)
@@ -30,9 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class ConnectionManagerImpl implements ConnectionManager {
 
     private static final Logger LOG = LoggerFactory.getLogger(ConnectionManagerImpl.class);
index 1efadcc18b3a70c5a1c432201b5b4da13f129b14..eca6c1574822f0d122953625820f0aa1e3d62dc2 100644 (file)
@@ -11,16 +11,15 @@ import java.util.concurrent.ThreadPoolExecutor;
 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager;
 
-/**
- *
- */
 public class HandshakeContextImpl implements HandshakeContext {
     private ThreadPoolExecutor handshakePool;
     private HandshakeManager handshakeManager;
 
     /**
-     * @param handshakePool
-     * @param handshakeManager
+     * Constructor.
+     *
+     * @param handshakePool - pool
+     * @param handshakeManager - manager
      */
     public HandshakeContextImpl(ThreadPoolExecutor handshakePool, HandshakeManager handshakeManager) {
         this.handshakePool = handshakePool;
index b74e59944761baa4507c646bc8faf3d31ed5ad80..90607c6f50a9675c9aa9c6dd0febccfd36509739 100644 (file)
@@ -16,7 +16,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * oneshot listener - once connection is ready, initiate handshake (if not already started by device)
+ * Oneshot listener - once connection is ready, initiate handshake (if not already started by device).
  */
 public class ConnectionReadyListenerImpl implements ConnectionReadyListener {
 
@@ -26,18 +26,20 @@ public class ConnectionReadyListenerImpl implements ConnectionReadyListener {
     private HandshakeContext handshakeContext;
 
     /**
-     * @param connectionContext
-     * @param handshakeContext
+     * Constructor.
+     *
+     * @param connectionContext - connection context
+     * @param handshakeContext - handshake context
      */
-    public ConnectionReadyListenerImpl(ConnectionContext connectionContext,
-            HandshakeContext handshakeContext) {
-                this.connectionContext = connectionContext;
-                this.handshakeContext = handshakeContext;
+    public ConnectionReadyListenerImpl(ConnectionContext connectionContext, HandshakeContext handshakeContext) {
+        this.connectionContext = connectionContext;
+        this.handshakeContext = handshakeContext;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void onConnectionReady() {
-        if(LOG.isDebugEnabled()) {
+        if (LOG.isDebugEnabled()) {
             LOG.debug("device is connected and ready-to-use (pipeline prepared): {}",
                     connectionContext.getConnectionAdapter().getRemoteAddress());
         }
@@ -51,21 +53,15 @@ public class ConnectionReadyListenerImpl implements ConnectionReadyListener {
                     final Future<?> handshakeResult = handshakeContext.getHandshakePool().submit(handshakeStepWrapper);
 
                     try {
-                        // as we run not in netty thread, need to remain in sync lock until initial handshake step processed
+                        // As we run not in netty thread,
+                        // need to remain in sync lock until initial handshake step processed.
                         handshakeResult.get();
                     } catch (Exception e) {
                         LOG.error("failed to process onConnectionReady event on device {}, reason {}",
                                 connectionContext.getConnectionAdapter().getRemoteAddress(),
                                 e);
                         connectionContext.closeConnection(false);
-                        try {
-                            handshakeContext.close();
-                        } catch (Exception e1) {
-                            LOG.error("failed to close handshake context for device {}, reason {}",
-                                    connectionContext.getConnectionAdapter().getRemoteAddress(),
-                                    e1
-                            );
-                        }
+                        handshakeContext.close();
                     }
                 } else {
                     LOG.debug("already touched by hello message from device {} after second check",
index 7582871f8ffb90549727f6b1d7a15b2cbfee4c4a..9ec64066e0c3655593c69a4e31f0c047661b6d05 100644 (file)
@@ -28,9 +28,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class HandshakeListenerImpl implements HandshakeListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(HandshakeListenerImpl.class);
@@ -40,10 +37,13 @@ public class HandshakeListenerImpl implements HandshakeListener {
     private HandshakeContext handshakeContext;
 
     /**
-     * @param connectionContext
-     * @param deviceConnectedHandler
+     * Constructor.
+     *
+     * @param connectionContext - connection context
+     * @param deviceConnectedHandler - device connected handler
      */
-    public HandshakeListenerImpl(final ConnectionContext connectionContext, final DeviceConnectedHandler deviceConnectedHandler) {
+    public HandshakeListenerImpl(final ConnectionContext connectionContext,
+                                 final DeviceConnectedHandler deviceConnectedHandler) {
         this.connectionContext = connectionContext;
         this.deviceConnectedHandler = deviceConnectedHandler;
     }
@@ -67,9 +67,11 @@ public class HandshakeListenerImpl implements HandshakeListener {
     private FutureCallback<RpcResult<BarrierOutput>> addBarrierCallback() {
         return new FutureCallback<RpcResult<BarrierOutput>>() {
             @Override
+            @SuppressWarnings("checkstyle:IllegalCatch")
             public void onSuccess(@Nullable final RpcResult<BarrierOutput> result) {
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}", connectionContext.getDeviceInfo());
+                    LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}",
+                            connectionContext.getDeviceInfo());
                 }
                 try {
                     ConnectionStatus connectionStatusResult = deviceConnectedHandler.deviceConnected(connectionContext);
@@ -87,8 +89,9 @@ public class HandshakeListenerImpl implements HandshakeListener {
             }
 
             @Override
-            public void onFailure(final Throwable t) {
-                LOG.warn("failed to get sweep barrier after post-handshake for device {}", connectionContext.getDeviceInfo(), t);
+            public void onFailure(final Throwable throwable) {
+                LOG.warn("failed to get sweep barrier after post-handshake for device {}",
+                        connectionContext.getDeviceInfo(), throwable);
                 connectionContext.closeConnection(false);
             }
         };
index 05b636b70454fde4bafc181b5f98a027697d7d73..27d5ceeeb2e971f8c05f4823b4efcd63d61cdaa2 100644 (file)
@@ -24,9 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowProtocolListenerInitialImpl.class);
@@ -35,8 +32,10 @@ public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolList
     private final HandshakeContext handshakeContext;
 
     /**
-     * @param connectionContext
-     * @param handshakeContext
+     * Constructor.
+     *
+     * @param connectionContext - connection context
+     * @param handshakeContext - handshake context
      */
     public OpenflowProtocolListenerInitialImpl(final ConnectionContext connectionContext,
                                                final HandshakeContext handshakeContext) {
@@ -119,7 +118,9 @@ public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolList
     }
 
     /**
-     * @param expectedState
+     * Check state of the connection context.
+     *
+     * @param expectedState - the expected state
      */
     protected boolean checkState(final ConnectionContext.CONNECTION_STATE expectedState) {
         boolean verdict = true;
index 5f7a8e9d04d1decb93e6ccbbf9fb7cdf6858ce7c..10e469ad6d3ef3f38213c8f4958a9fa17e9a096e 100644 (file)
@@ -29,9 +29,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class SystemNotificationsListenerImpl implements SystemNotificationsListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class);
@@ -63,6 +60,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
         threadPool.execute(this::executeOnSwitchIdleEvent);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void executeOnSwitchIdleEvent() {
         boolean shouldBeDisconnected = true;
 
@@ -76,12 +74,13 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
             builder.setVersion(features.getVersion());
             builder.setXid(ECHO_XID.getValue());
 
-            Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
+            Future<RpcResult<EchoOutput>> echoReplyFuture =
+                    connectionContext.getConnectionAdapter().echo(builder.build());
 
             try {
                 RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
-                if (echoReplyValue.isSuccessful() &&
-                        Objects.equals(echoReplyValue.getResult().getXid(), ECHO_XID.getValue())) {
+                if (echoReplyValue.isSuccessful()
+                        && Objects.equals(echoReplyValue.getResult().getXid(), ECHO_XID.getValue())) {
                     connectionContext.changeStateToWorking();
                     shouldBeDisconnected = false;
                 } else {
@@ -89,11 +88,13 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
                 }
             } catch (Exception e) {
                 if (LOG.isWarnEnabled()) {
-                    LOG.warn("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
+                    LOG.warn("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}",
+                            remoteAddress, e.getMessage());
                 }
 
                 if (LOG.isTraceEnabled()) {
-                    LOG.trace("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
+                    LOG.trace("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}",
+                            remoteAddress, e);
                 }
 
             }
@@ -101,7 +102,8 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
         if (shouldBeDisconnected) {
             if (LOG.isInfoEnabled()) {
                 LOG.info("ConnectionEvent:Closing connection as device is idle. Echo sent at {}. Device:{}, NodeId:{}",
-                        new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getSafeNodeIdForLOG());
+                        new Date(System.currentTimeMillis() - echoReplyTimeout),
+                        remoteAddress, connectionContext.getSafeNodeIdForLOG());
             }
 
             connectionContext.closeConnection(true);
@@ -112,7 +114,8 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
         for (RpcError replyError : echoReplyValue.getErrors()) {
             Throwable cause = replyError.getCause();
             if (LOG.isWarnEnabled()) {
-                LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause.getMessage());
+                LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}",
+                        remoteAddress, cause.getMessage());
             }
 
             if (LOG.isTraceEnabled()) {
index feb26ec103864529af7c2a648e3db24825d7a29c..882d4e58bc1e68b369d4ac96f43b79ba32fc6503 100644 (file)
@@ -84,16 +84,24 @@ public class OpenFlowPluginProviderImplTest {
         when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
         when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
         when(entityOwnershipService.registerListener(any(), any())).thenReturn(entityOwnershipListenerRegistration);
-        when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any())).thenReturn(controlServiceRegistration);
+        when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any()))
+                .thenReturn(controlServiceRegistration);
         when(switchConnectionProvider.startup()).thenReturn(Futures.immediateFuture(true));
         when(switchConnectionProvider.shutdown()).thenReturn(Futures.immediateFuture(true));
-        when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()), any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
-        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any())).thenReturn(THREAD_POOL_MIN_THREADS);
-        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any())).thenReturn(THREAD_POOL_MAX_THREADS);
-        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any())).thenReturn(THREAD_POOL_TIMEOUT);
-        when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any())).thenReturn(RPC_REQUESTS_QUOTA);
-        when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any())).thenReturn(GLOBAL_NOTIFICATION_QUOTA);
-        when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any())).thenReturn(BASIC_TIMER_DELAY);
+        when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()),
+                any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
+        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any()))
+                .thenReturn(THREAD_POOL_MIN_THREADS);
+        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any()))
+                .thenReturn(THREAD_POOL_MAX_THREADS);
+        when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any()))
+                .thenReturn(THREAD_POOL_TIMEOUT);
+        when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any()))
+                .thenReturn(RPC_REQUESTS_QUOTA);
+        when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any()))
+                .thenReturn(GLOBAL_NOTIFICATION_QUOTA);
+        when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any()))
+                .thenReturn(BASIC_TIMER_DELAY);
     }
 
     @Test
index ab4780e26b47f4b9abfabec373e638477b3e0608..bca7a967fba435e0c4f6159102529cfcbfd3b400 100644 (file)
@@ -45,7 +45,8 @@ public class ConnectionContextImplTest {
 
     @Before
     public void setUp() throws Exception {
-        Mockito.when(connetionAdapter.getRemoteAddress()).thenReturn(InetSocketAddress.createUnresolved("ofp-ut.example.org", 4242));
+        Mockito.when(connetionAdapter.getRemoteAddress())
+                .thenReturn(InetSocketAddress.createUnresolved("ofp-ut.example.org", 4242));
         Mockito.when(connetionAdapter.isAlive()).thenReturn(true);
 
         connectionContext = new ConnectionContextImpl(connetionAdapter);
index c5a1e69350457892be9d0ad3d160d557d498a050..1dfd70ea5dfeda35f03a3ffbadb2a6d28e53d62a 100644 (file)
@@ -43,12 +43,12 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
- * test of {@link ConnectionManagerImpl} - lightweight version, using basic ways (TDD)
+ * Test of {@link ConnectionManagerImpl} - lightweight version, using basic ways (TDD).
  */
 @RunWith(MockitoJUnitRunner.class)
 public class ConnectionManagerImplTest {
 
-    /** timeout of final step [ms] */
+    // timeout of final step [ms]
     private static final int FINAL_STEP_TIMEOUT = 500;
     private ConnectionManagerImpl connectionManagerImpl;
     @Mock
@@ -60,11 +60,8 @@ public class ConnectionManagerImplTest {
     @Captor
     private ArgumentCaptor<OpenflowProtocolListener> ofpListenerAC;
 
-    private final static long ECHO_REPLY_TIMEOUT = 500;
+    private static final long ECHO_REPLY_TIMEOUT = 500;
 
-    /**
-     * before each test method
-     */
     @Before
     public void setUp() {
         final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE,
@@ -83,25 +80,24 @@ public class ConnectionManagerImplTest {
                 .thenReturn(RpcResultBuilder.success(new BarrierOutputBuilder().build()).buildFuture());
     }
 
-    /**
-     * after each test method
-     * @throws InterruptedException
-     */
     @After
     public void tearDown() throws InterruptedException {
         Thread.sleep(200L);
     }
 
     /**
-     * Test method for {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
+     * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
      * invoking onConnectionReady first, scenario:
      * <ol>
-     *  <li>send hello to device (rpc with void output)</li>
-     *  <li>receive hello from device (notification)</li>
-     *  <li>send getFeature to device (rpc with getFeatureOutput)</li>
-     *  <li>wait for rpc to finish with getFeatureOutput</li>
+     * <li>send hello to device (rpc with void output)</li>
+     * <li>receive hello from device (notification)</li>
+     * <li>send getFeature to device (rpc with getFeatureOutput)</li>
+     * <li>wait for rpc to finish with getFeatureOutput</li>
      * </ol>
-     * @throws InterruptedException
+     *
+     * @throws InterruptedException - interrupted exception
      */
     @Test
     public void testOnSwitchConnected1() throws Exception {
@@ -113,7 +109,8 @@ public class ConnectionManagerImplTest {
         final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
         Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
         // prepare getFeature reply (getFeture rpc output)
-        final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
+        final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx =
+                SettableFuture.<RpcResult<GetFeaturesOutput>>create();
         Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
 
 
@@ -132,27 +129,31 @@ public class ConnectionManagerImplTest {
         // deliver getFeature output
         Thread.sleep(100L);
         final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder()
-        .setDatapathId(BigInteger.TEN)
-        .setVersion(OFConstants.OFP_VERSION_1_3)
-        .setXid(2L)
-        .setTables((short) 15)
-        .build();
+                .setDatapathId(BigInteger.TEN)
+                .setVersion(OFConstants.OFP_VERSION_1_3)
+                .setXid(2L)
+                .setTables((short) 15)
+                .build();
         final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
         featureResponseFx.set(rpcFeaturesOutput);
 
-        Mockito.verify(deviceConnectedHandler, Mockito.timeout(500)).deviceConnected(Matchers.any(ConnectionContext.class));
+        Mockito.verify(deviceConnectedHandler,
+                Mockito.timeout(500)).deviceConnected(Matchers.any(ConnectionContext.class));
     }
 
     /**
-     * Test method for {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
+     * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
      * invoking onHelloMessage, scenario:
      * <ol>
-     *  <li>receive hello from device (notification)</li>
-     *  <li>send hello to device (rpc with void output)</li>
-     *  <li>send getFeature to device (rpc with getFeatureOutput)</li>
-     *  <li>wait for rpc to finish with getFeatureOutput</li>
+     * <li>receive hello from device (notification)</li>
+     * <li>send hello to device (rpc with void output)</li>
+     * <li>send getFeature to device (rpc with getFeatureOutput)</li>
+     * <li>wait for rpc to finish with getFeatureOutput</li>
      * </ol>
-     * @throws InterruptedException
+     *
+     * @throws InterruptedException - interrupted exception
      */
     @Test
     public void testOnSwitchConnected2() throws Exception {
@@ -164,7 +165,8 @@ public class ConnectionManagerImplTest {
         final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
         Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
         // prepare getFeature reply (getFeture rpc output)
-        final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
+        final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx =
+                SettableFuture.<RpcResult<GetFeaturesOutput>>create();
         Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
 
 
@@ -183,14 +185,15 @@ public class ConnectionManagerImplTest {
         // deliver getFeature output
         Thread.sleep(100L);
         final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder()
-        .setDatapathId(BigInteger.TEN)
-        .setVersion(OFConstants.OFP_VERSION_1_3)
-        .setXid(2L)
-        .setTables((short) 15)
-        .build();
+                .setDatapathId(BigInteger.TEN)
+                .setVersion(OFConstants.OFP_VERSION_1_3)
+                .setXid(2L)
+                .setTables((short) 15)
+                .build();
         final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
         featureResponseFx.set(rpcFeaturesOutput);
 
-        Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
+        Mockito.verify(deviceConnectedHandler,
+                Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
     }
 }
index b8421c0c48c5e03c56c7d0058c3572119d3fa07e..9b04454fe09024c4f35e83d172926ea4426f106c 100644 (file)
@@ -21,7 +21,8 @@ public class OutboundQueueProviderImplTest extends TestCase {
     private static final Long DUMMY_ENTRY_NUMBER = 44L;
     private static final Long DUMMY_XID = 55L;
 
-    private final OutboundQueueProviderImpl outboundQueueProvider = new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
+    private final OutboundQueueProviderImpl outboundQueueProvider =
+            new OutboundQueueProviderImpl(OFConstants.OFP_VERSION_1_3);
 
     @Test
     public void testReserveEntry() throws Exception {
index 9dede809beaba2e9476dd160d30806abf411b1d5..5e75c48aba730ee4786bd70798b6136671da0779 100644 (file)
@@ -93,7 +93,8 @@ public class HandshakeListenerImplTest {
 
     @Test
     public void testOnHandshakeFailure2() throws Exception {
-        Mockito.when(connectionAdapter.getRemoteAddress()).thenReturn(InetSocketAddress.createUnresolved("ut-ofp.example.org", 4242));
+        Mockito.when(connectionAdapter.getRemoteAddress())
+                .thenReturn(InetSocketAddress.createUnresolved("ut-ofp.example.org", 4242));
         connectionContextSpy.setNodeId(new NodeId("openflow:1"));
         handshakeListener.onHandshakeFailure();
         Mockito.verify(handshakeContext).close();
index 3bd971b21dd31cf6c87c4f4d4b2e6aeab3b94bd1..00ab46a2ca5937c301cdd1d771d834bb758894d4 100644 (file)
@@ -47,7 +47,8 @@ public class OpenflowProtocolListenerInitialImplTest {
     public void setUp() throws Exception {
         Mockito.when(connectionAdapter.isAlive()).thenReturn(true);
         Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
-        Mockito.when(connectionContext.getConnectionState()).thenReturn(null, ConnectionContext.CONNECTION_STATE.HANDSHAKING);
+        Mockito.when(connectionContext.getConnectionState())
+                .thenReturn(null, ConnectionContext.CONNECTION_STATE.HANDSHAKING);
         Mockito.when(handshakeContext.getHandshakeManager()).thenReturn(handshakeManager);
 
         openflowProtocolListenerInitial = new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext);
index 997dd3a2b326f2529c450afc6bc2311b8b3accb6..fad4b579821cb4ee74d57d618ae75b6c06f63055 100644 (file)
@@ -40,13 +40,13 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
- * Testing basic bahavior of {@link SystemNotificationsListenerImpl}
+ * Testing basic bahavior of {@link SystemNotificationsListenerImpl}.
  */
 @RunWith(MockitoJUnitRunner.class)
 public class SystemNotificationsListenerImplTest {
 
     private static final int SAFE_TIMEOUT = 1000;
-    private final static int ECHO_REPLY_TIMEOUT = 2000;
+    private static final int ECHO_REPLY_TIMEOUT = 2000;
 
     @Mock
     private ConnectionAdapter connectionAdapter;
@@ -57,17 +57,17 @@ public class SystemNotificationsListenerImplTest {
     private ConnectionContextImpl connectionContextGolem;
     private SystemNotificationsListenerImpl systemNotificationsListener;
 
-    private static final NodeId nodeId =
+    private static final NodeId NODE_ID =
             new NodeId("OFP:TEST");
 
-    private final ThreadPoolLoggingExecutor threadPool =
-            new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), "opfpool");
+    private final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(
+            0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), "opfpool");
 
     @Before
     public void setUp() {
         connectionContextGolem = new ConnectionContextImpl(connectionAdapter);
         connectionContextGolem.changeStateToWorking();
-        connectionContextGolem.setNodeId(nodeId);
+        connectionContextGolem.setNodeId(NODE_ID);
         connectionContext = Mockito.spy(connectionContextGolem);
 
         Mockito.when(connectionAdapter.getRemoteAddress()).thenReturn(
@@ -89,9 +89,7 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * successful scenario - connection is on and closes without errors
-     *
-     * @throws Exception
+     * Successful scenario - connection is on and closes without errors.
      */
     @Test
     public void testOnDisconnectEvent1() throws Exception {
@@ -108,9 +106,7 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * broken scenario - connection is on but fails to close
-     *
-     * @throws Exception
+     * Broken scenario - connection is on but fails to close.
      */
     @Test
     public void testOnDisconnectEvent2() throws Exception {
@@ -127,16 +123,15 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * successful scenario - connection is already down
-     *
-     * @throws Exception
+     * Successful scenario - connection is already down.
      */
     @Test
     public void testOnDisconnectEvent3() throws Exception {
         connectionContextGolem.changeStateToTimeouting();
 
         Mockito.when(connectionAdapter.isAlive()).thenReturn(true);
-        Mockito.when(connectionAdapter.disconnect()).thenReturn(Futures.<Boolean>immediateFailedFuture(new Exception("unit exception")));
+        Mockito.when(connectionAdapter.disconnect())
+                .thenReturn(Futures.<Boolean>immediateFailedFuture(new Exception("unit exception")));
 
         DisconnectEvent disconnectNotification = new DisconnectEventBuilder().setInfo("testing disconnect").build();
         systemNotificationsListener.onDisconnectEvent(disconnectNotification);
@@ -148,9 +143,7 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * broken scenario - connection is on but throws error on close
-     *
-     * @throws Exception
+     * Broken scenario - connection is on but throws error on close.
      */
     @Test
     public void testOnDisconnectEvent4() throws Exception {
@@ -167,13 +160,12 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * first encounter of idle event, echo received successfully
-     *
-     * @throws Exception
+     * First encounter of idle event, echo received successfully.
      */
     @Test
     public void testOnSwitchIdleEvent1() throws Exception {
-        final Future<RpcResult<EchoOutput>> echoReply = Futures.immediateFuture(RpcResultBuilder.success(new EchoOutputBuilder().setXid(0L).build()).build());
+        final Future<RpcResult<EchoOutput>> echoReply =
+                Futures.immediateFuture(RpcResultBuilder.success(new EchoOutputBuilder().setXid(0L).build()).build());
 
         Mockito.when(connectionAdapter.echo(Matchers.any(EchoInput.class))).thenReturn(echoReply);
 
@@ -191,16 +183,15 @@ public class SystemNotificationsListenerImplTest {
     }
 
     /**
-     * first encounter of idle event, echo not receive
-     *
-     * @throws Exception
+     * First encounter of idle event, echo not receive.
      */
     @Test
     public void testOnSwitchIdleEvent2() throws Exception {
         final SettableFuture<RpcResult<EchoOutput>> echoReply = SettableFuture.create();
         Mockito.when(connectionAdapter.echo(Matchers.any(EchoInput.class))).thenReturn(echoReply);
         Mockito.when(connectionAdapter.isAlive()).thenReturn(true);
-        Mockito.when(connectionAdapter.disconnect()).thenReturn(Futures.<Boolean>immediateFailedFuture(new Exception("unit exception")));
+        Mockito.when(connectionAdapter.disconnect())
+                .thenReturn(Futures.<Boolean>immediateFailedFuture(new Exception("unit exception")));
 
         SwitchIdleEvent notification = new SwitchIdleEventBuilder().setInfo("wake up, device sleeps").build();
         systemNotificationsListener.onSwitchIdleEvent(notification);
index c13fd167630519ef3fab16884785a6fd5052a30a..8cc9dafb5e998537bee562e276e7659d9ebfa753 100644 (file)
@@ -16,26 +16,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder;
 
-/**
- * openflowplugin-impl
- * org.opendaylight.openflowplugin.impl.connection.testutil
- *
- *
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Mar 26, 2015
- */
 public class MsgGeneratorTestUtils {
 
-    private MsgGeneratorTestUtils () {
+    private MsgGeneratorTestUtils() {
         throw new UnsupportedOperationException("Test Utility class");
     }
 
-    public static MultipartReplyMessageBuilder makeMultipartDescReply(final long xid, final String value, final boolean hasNext) {
+    public static MultipartReplyMessageBuilder makeMultipartDescReply(final long xid,
+                                                                      final String value,
+                                                                      final boolean hasNext) {
         final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc(value).build();
-        final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder()
-                                                        .setMultipartReplyDesc(descValue).build();
+        final MultipartReplyDescCase replyBody =
+                new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(descValue).build();
 
         MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder()
                 .setMultipartReplyBody(replyBody)