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;
}
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
unregisterMXBean(MESSAGE_INTELLIGENCE_AGENCY_MX_BEAN_NAME);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private static void gracefulShutdown(final AutoCloseable closeable) {
if (Objects.isNull(closeable)) {
return;
try {
timer.stop();
- } catch (Exception e) {
+ } catch (IllegalStateException e) {
LOG.warn("Failed to shutdown {} gracefully.", timer);
}
}
try {
threadPoolExecutor.shutdownNow();
- } catch (Exception e) {
+ } catch (SecurityException e) {
LOG.warn("Failed to shutdown {} gracefully.", threadPoolExecutor);
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class ConnectionContextImpl implements ConnectionContext {
private final ConnectionAdapter connectionAdapter;
private List<PortStatusMessage> portStatusMessages = new ArrayList<>();
/**
- * @param connectionAdapter
+ * Constructor.
+ *
+ * @param connectionAdapter - connection adapter
*/
public ConnectionContextImpl(final ConnectionAdapter connectionAdapter) {
this.connectionAdapter = connectionAdapter;
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;
}
}
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
}
/**
- * This method returns safe nodeId for logging
+ * Get safe nodeId for logging.
+ *
* @return string value od nodeId or string "null"
*/
@Override
}
@Override
- public void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration) {
+ public void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider>
+ outboundQueueHandlerRegistration) {
this.outboundQueueHandlerRegistration = outboundQueueHandlerRegistration;
}
}
@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;
}
@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));
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class ConnectionManagerImpl implements ConnectionManager {
private static final Logger LOG = LoggerFactory.getLogger(ConnectionManagerImpl.class);
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;
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 {
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());
}
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",
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class HandshakeListenerImpl implements HandshakeListener {
private static final Logger LOG = LoggerFactory.getLogger(HandshakeListenerImpl.class);
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;
}
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);
}
@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);
}
};
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class OpenflowProtocolListenerInitialImpl implements OpenflowProtocolListener {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowProtocolListenerInitialImpl.class);
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) {
}
/**
- * @param expectedState
+ * Check state of the connection context.
+ *
+ * @param expectedState - the expected state
*/
protected boolean checkState(final ConnectionContext.CONNECTION_STATE expectedState) {
boolean verdict = true;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class SystemNotificationsListenerImpl implements SystemNotificationsListener {
private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class);
threadPool.execute(this::executeOnSwitchIdleEvent);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void executeOnSwitchIdleEvent() {
boolean shouldBeDisconnected = true;
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 {
}
} 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);
}
}
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);
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()) {
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
@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);
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
@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,
.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 {
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);
// 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 {
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);
// 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));
}
}
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 {
@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();
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);
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;
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(
}
/**
- * 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 {
}
/**
- * 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 {
}
/**
- * 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);
}
/**
- * 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 {
}
/**
- * 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);
}
/**
- * 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);
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)