Bug 8153: Enforce check-style rules for netconf - client. 87/55787/5
authormatus.kubica <matus.kubica@pantheon.tech>
Fri, 21 Apr 2017 06:34:11 +0000 (08:34 +0200)
committerMatúš Kubica <Matus.Kubica@pantheon.tech>
Thu, 27 Apr 2017 09:48:15 +0000 (09:48 +0000)
    Organize Imports for Checkstyle compliance.
    Checkstyle compliance: line length.
    Checkstyle compliance: various types of small changes.
    Checkstyle compliant Exception handling.
    Checkstyle final clean up & enforcement.
    Add the fail on violation flag into the pom.xml .

Change-Id: I889c86f680d93ffe946c5223b86da1c2967af114
Signed-off-by: matus.kubica <matus.kubica@pantheon.tech>
22 files changed:
netconf/netconf-client/pom.xml
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientDispatcher.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientDispatcherImpl.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSession.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiator.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/SimpleNetconfClientSessionListener.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/SshClientChannelInitializer.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/TcpClientChannelInitializer.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfiguration.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfClientConfigurationBuilder.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfReconnectingClientConfiguration.java
netconf/netconf-client/src/main/java/org/opendaylight/netconf/client/conf/NetconfReconnectingClientConfigurationBuilder.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientConfigurationTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfReconnectingClientConfigurationTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/SimpleNetconfClientSessionListenerTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/SshClientChannelInitializerTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/TcpClientChannelInitializerTest.java
netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/TestingNetconfClient.java

index 6c4f3edae121c3de76b3eadd7f8d7bca7587f3ab..072eeac5b638c931e279caa9a31ad3ba467fd137 100644 (file)
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 
index 38f7155d292656bc1d30908fddbd6c1f962bd2f5..66fdff674dff563dbac1dad9464e5f81ad45fa1c 100644 (file)
@@ -14,10 +14,10 @@ import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurati
 public interface NetconfClientDispatcher {
 
     /**
+     * Create netconf client. Network communication has to be set up based on network protocol specified in
+     * clientConfiguration
      *
-     * Create netconf client. Network communication has to be set up based on network protocol specified in clientConfiguration
-     *
-     * @param clientConfiguration
+     * @param clientConfiguration Configuration of client
      * @return netconf client based on provided configuration
      */
     Future<NetconfClientSession> createClient(NetconfClientConfiguration clientConfiguration);
index 38635b1ec350bd071a83b92e759e488105c09179..6abce42b43239d0c0d645964d11450c8abcb2c7a 100644 (file)
@@ -25,7 +25,8 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClien
 
     private final Timer timer;
 
-    public NetconfClientDispatcherImpl(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup, final Timer timer) {
+    public NetconfClientDispatcherImpl(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup,
+                                       final Timer timer) {
         super(bossGroup, workerGroup);
         this.timer = timer;
     }
@@ -37,55 +38,63 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClien
     @Override
     public Future<NetconfClientSession> createClient(final NetconfClientConfiguration clientConfiguration) {
         switch (clientConfiguration.getProtocol()) {
-        case TCP:
-            return createTcpClient(clientConfiguration);
-        case SSH:
-            return createSshClient(clientConfiguration);
+            case TCP:
+                return createTcpClient(clientConfiguration);
+            case SSH:
+                return createSshClient(clientConfiguration);
+            default:
+                throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
         }
-        throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
     }
 
     @Override
     public Future<Void> createReconnectingClient(final NetconfReconnectingClientConfiguration clientConfiguration) {
         switch (clientConfiguration.getProtocol()) {
-        case TCP:
-            return createReconnectingTcpClient(clientConfiguration);
-        case SSH:
-            return createReconnectingSshClient(clientConfiguration);
+            case TCP:
+                return createReconnectingTcpClient(clientConfiguration);
+            case SSH:
+                return createReconnectingSshClient(clientConfiguration);
+            default:
+                throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
         }
-        throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol());
     }
 
     private Future<NetconfClientSession> createTcpClient(final NetconfClientConfiguration currentConfiguration) {
         LOG.debug("Creating TCP client with configuration: {}", currentConfiguration);
         return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(),
-                (ch, promise) -> new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration), currentConfiguration
-                                .getSessionListener()).initialize(ch, promise));
+            (ch, promise) -> new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration),
+                        currentConfiguration
+                        .getSessionListener()).initialize(ch, promise));
     }
 
-    private Future<Void> createReconnectingTcpClient(final NetconfReconnectingClientConfiguration currentConfiguration) {
+    private Future<Void> createReconnectingTcpClient(
+            final NetconfReconnectingClientConfiguration currentConfiguration) {
         LOG.debug("Creating reconnecting TCP client with configuration: {}", currentConfiguration);
-        final TcpClientChannelInitializer init = new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration),
+        final TcpClientChannelInitializer init =
+                new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration),
                 currentConfiguration.getSessionListener());
 
-        return super.createReconnectingClient(currentConfiguration.getAddress(), currentConfiguration.getConnectStrategyFactory(),
+        return super.createReconnectingClient(currentConfiguration.getAddress(), currentConfiguration
+                .getConnectStrategyFactory(),
                 currentConfiguration.getReconnectStrategy(), init::initialize);
     }
 
     private Future<NetconfClientSession> createSshClient(final NetconfClientConfiguration currentConfiguration) {
         LOG.debug("Creating SSH client with configuration: {}", currentConfiguration);
         return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(),
-                (ch, sessionPromise) -> new SshClientChannelInitializer(currentConfiguration.getAuthHandler(),
+            (ch, sessionPromise) -> new SshClientChannelInitializer(currentConfiguration.getAuthHandler(),
                         getNegotiatorFactory(currentConfiguration), currentConfiguration.getSessionListener())
                         .initialize(ch, sessionPromise));
     }
 
-    private Future<Void> createReconnectingSshClient(final NetconfReconnectingClientConfiguration currentConfiguration) {
+    private Future<Void> createReconnectingSshClient(
+            final NetconfReconnectingClientConfiguration currentConfiguration) {
         LOG.debug("Creating reconnecting SSH client with configuration: {}", currentConfiguration);
         final SshClientChannelInitializer init = new SshClientChannelInitializer(currentConfiguration.getAuthHandler(),
                 getNegotiatorFactory(currentConfiguration), currentConfiguration.getSessionListener());
 
-        return super.createReconnectingClient(currentConfiguration.getAddress(), currentConfiguration.getConnectStrategyFactory(), currentConfiguration.getReconnectStrategy(),
+        return super.createReconnectingClient(currentConfiguration.getAddress(), currentConfiguration
+                .getConnectStrategyFactory(), currentConfiguration.getReconnectStrategy(),
                 init::initialize);
     }
 
index e27f72b5c927ccb8d70d80e1de9ba7de1204780a..86415ecfdfa9fa450db3051ec5214acb5164a2e6 100644 (file)
@@ -27,13 +27,13 @@ public class NetconfClientSession extends AbstractNetconfSession<NetconfClientSe
     /**
      * Construct a new session.
      *
-     * @param sessionListener
-     * @param channel
-     * @param sessionId
-     * @param capabilities set of advertised capabilities. Expected to be immutable.
+     * @param sessionListener    Netconf client session listener.
+     * @param channel    Channel.
+     * @param sessionId    Session Id.
+     * @param capabilities    Set of advertised capabilities. Expected to be immutable.
      */
-    public NetconfClientSession(final NetconfClientSessionListener sessionListener, final Channel channel, final long sessionId,
-            final Collection<String> capabilities) {
+    public NetconfClientSession(final NetconfClientSessionListener sessionListener, final Channel channel,
+                                final long sessionId, final Collection<String> capabilities) {
         super(sessionListener, channel, sessionId);
         this.capabilities = capabilities;
         LOG.debug("Client Session {} created", this);
@@ -49,7 +49,8 @@ public class NetconfClientSession extends AbstractNetconfSession<NetconfClientSe
     }
 
     @Override
-    protected void addExiHandlers(final ByteToMessageDecoder decoder, final MessageToByteEncoder<NetconfMessage> encoder) {
+    protected void addExiHandlers(final ByteToMessageDecoder decoder,
+                                  final MessageToByteEncoder<NetconfMessage> encoder) {
         // TODO used only in negotiator, client supports only auto start-exi
         replaceMessageDecoder(decoder);
         replaceMessageEncoder(encoder);
index 55d92d6df6e33bc25ea471067bce24976d6db529..608450225f52d84d71cff3d1443b739905edaa5d 100644 (file)
@@ -40,14 +40,14 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 public class NetconfClientSessionNegotiator extends
-        AbstractNetconfSessionNegotiator<NetconfClientSessionPreferences, NetconfClientSession, NetconfClientSessionListener>
-{
+        AbstractNetconfSessionNegotiator<NetconfClientSessionPreferences, NetconfClientSession,
+                NetconfClientSessionListener> {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiator.class);
 
-    private static final XPathExpression sessionIdXPath = XMLNetconfUtil
+    private static final XPathExpression SESSION_ID_X_PATH = XMLNetconfUtil
             .compileXPath("/netconf:hello/netconf:session-id");
 
-    private static final XPathExpression sessionIdXPathNoNamespace = XMLNetconfUtil
+    private static final XPathExpression SESSION_ID_X_PATH_NO_NAMESPACE = XMLNetconfUtil
             .compileXPath("/hello/session-id");
 
     private static final String EXI_1_0_CAPABILITY_MARKER = "exi:1.0";
@@ -84,7 +84,7 @@ public class NetconfClientSessionNegotiator extends
     /**
      * Initiates exi communication by sending start-exi message and waiting for positive/negative response.
      *
-     * @param startExiMessage
+     * @param startExiMessage Exi message for initilization of exi communication.
      */
     void tryToInitiateExi(final NetconfClientSession session, final NetconfStartExiMessage startExiMessage) {
         channel.pipeline().addAfter(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER,
@@ -93,9 +93,10 @@ public class NetconfClientSessionNegotiator extends
 
         session.sendMessage(startExiMessage).addListener(new ChannelFutureListener() {
             @Override
-            public void operationComplete(final ChannelFuture f) {
-                if (!f.isSuccess()) {
-                    LOG.warn("Failed to send start-exi message {} on session {}", startExiMessage, this, f.cause());
+            public void operationComplete(final ChannelFuture channelFuture) {
+                if (!channelFuture.isSuccess()) {
+                    LOG.warn("Failed to send start-exi message {} on session {}", startExiMessage, this,
+                            channelFuture.cause());
                     channel.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER);
                 } else {
                     LOG.trace("Start-exi message {} sent to socket on session {}", startExiMessage, this);
@@ -120,11 +121,12 @@ public class NetconfClientSessionNegotiator extends
     }
 
     private static long extractSessionId(final Document doc) {
-        String textContent = getSessionIdWithXPath(doc, sessionIdXPath);
+        String textContent = getSessionIdWithXPath(doc, SESSION_ID_X_PATH);
         if (Strings.isNullOrEmpty(textContent)) {
-            textContent = getSessionIdWithXPath(doc, sessionIdXPathNoNamespace);
+            textContent = getSessionIdWithXPath(doc, SESSION_ID_X_PATH_NO_NAMESPACE);
             if (Strings.isNullOrEmpty(textContent)) {
-                throw new IllegalStateException("Session id not received from server, hello message: " + XmlUtil.toString(doc));
+                throw new IllegalStateException("Session id not received from server, hello message: " + XmlUtil
+                        .toString(doc));
             }
         }
 
@@ -142,7 +144,8 @@ public class NetconfClientSessionNegotiator extends
         final long sessionId = extractSessionId(message.getDocument());
 
         // Copy here is important: it disconnects the strings from the document
-        Set<String> capabilities = ImmutableSet.copyOf(NetconfMessageUtil.extractCapabilitiesFromHello(message.getDocument()));
+        Set<String> capabilities = ImmutableSet.copyOf(NetconfMessageUtil.extractCapabilitiesFromHello(message
+                .getDocument()));
 
         capabilities = INTERNER.intern(capabilities);
 
@@ -150,7 +153,7 @@ public class NetconfClientSessionNegotiator extends
     }
 
     /**
-     * Handler to process response for start-exi message
+     * Handler to process response for start-exi message.
      */
     private final class ExiConfirmationInboundHandler extends ChannelInboundHandlerAdapter {
         private static final String EXI_CONFIRMED_HANDLER = "exiConfirmedHandler";
@@ -158,11 +161,13 @@ public class NetconfClientSessionNegotiator extends
         private final NetconfClientSession session;
         private final NetconfStartExiMessage startExiMessage;
 
-        ExiConfirmationInboundHandler(final NetconfClientSession session, final NetconfStartExiMessage startExiMessage) {
+        ExiConfirmationInboundHandler(final NetconfClientSession session,
+                                      final NetconfStartExiMessage startExiMessage) {
             this.session = session;
             this.startExiMessage = startExiMessage;
         }
 
+        @SuppressWarnings("checkstyle:IllegalCatch")
         @Override
         public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
             ctx.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER);
@@ -176,20 +181,22 @@ public class NetconfClientSessionNegotiator extends
                     session.startExiCommunication(startExiMessage);
                 } catch (RuntimeException e) {
                     // Unable to add exi, continue without exi
-                    LOG.warn("Unable to start exi communication, Communication will continue without exi on session {}", session, e);
+                    LOG.warn("Unable to start exi communication, Communication will continue without exi on session "
+                            + "{}", session, e);
                 }
 
                 // Error response
-            } else if(NetconfMessageUtil.isErrorMessage(netconfMessage)) {
+            } else if (NetconfMessageUtil.isErrorMessage(netconfMessage)) {
                 LOG.warn(
                         "Error response to start-exi message {}, Communication will continue without exi on session {}",
                         netconfMessage, session);
 
                 // Unexpected response to start-exi, throwing message away, continue without exi
             } else {
-                LOG.warn("Unexpected response to start-exi message, should be ok, was {}, " +
-                         "Communication will continue without exi and response message will be thrown away on session {}",
-                         netconfMessage, session);
+                LOG.warn("Unexpected response to start-exi message, should be ok, was {}, "
+                        + "Communication will continue without exi "
+                        + "and response message will be thrown away on session {}",
+                        netconfMessage, session);
             }
 
             negotiationSuccessful(session);
index a49ac1a26d794651d754f1551350e74fcad43750..b1767f9fddd383335d400869e35c54820a2c1e07 100644 (file)
@@ -31,7 +31,8 @@ import org.openexi.proc.common.EXIOptionsException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfMessage, NetconfClientSession, NetconfClientSessionListener> {
+public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfMessage,
+        NetconfClientSession, NetconfClientSessionListener> {
 
     public static final Set<String> EXI_CLIENT_CAPABILITIES = ImmutableSet.of(
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
@@ -95,7 +96,8 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
 
     public NetconfClientSessionNegotiatorFactory(final Timer timer,
                                                  final Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
-                                                 final long connectionTimeoutMillis, final EXIOptions exiOptions, final Set<String> capabilities) {
+                                                 final long connectionTimeoutMillis, final EXIOptions exiOptions,
+                                                 final Set<String> capabilities) {
         this.timer = Preconditions.checkNotNull(timer);
         this.additionalHeader = additionalHeader;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
@@ -104,21 +106,22 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     @Override
-    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(final SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
-                                                                        final Channel channel,
-            final Promise<NetconfClientSession> promise) {
+    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(
+            final SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
+            final Channel channel, final Promise<NetconfClientSession> promise) {
 
         NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
         NetconfHelloMessage helloMessage = null;
         try {
             helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
         } catch (NetconfDocumentedException e) {
-            LOG.error("Unable to create client hello message with capabilities {} and additional handler {}", clientCapabilities,additionalHeader);
+            LOG.error("Unable to create client hello message with capabilities {} and additional handler {}",
+                    clientCapabilities, additionalHeader);
             throw new IllegalStateException(e);
         }
 
         NetconfClientSessionPreferences proposal = new NetconfClientSessionPreferences(helloMessage, startExiMessage);
         return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
-                sessionListenerFactory.getSessionListener(),connectionTimeoutMillis);
+                sessionListenerFactory.getSessionListener(), connectionTimeoutMillis);
     }
 }
index 040d60c14acff0ff80b80a0f69d06b0bf7f1716c..654210a4a0e1685b032cdf3cb60fb10c9bd3a1d8 100644 (file)
@@ -25,7 +25,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
         private final Promise<NetconfMessage> promise;
         private final NetconfMessage request;
 
-        public RequestEntry(Promise<NetconfMessage> future, NetconfMessage request) {
+        RequestEntry(Promise<NetconfMessage> future, NetconfMessage request) {
             this.promise = Preconditions.checkNotNull(future);
             this.request = Preconditions.checkNotNull(request);
         }
@@ -71,14 +71,14 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
     }
 
     @Override
-    public final void onSessionDown(NetconfClientSession clientSession, Exception e) {
-        LOG.debug("Client Session {} went down unexpectedly", clientSession, e);
-        tearDown(e);
+    public final void onSessionDown(NetconfClientSession clientSession, Exception exception) {
+        LOG.debug("Client Session {} went down unexpectedly", clientSession, exception);
+        tearDown(exception);
     }
 
     @Override
     public final void onSessionTerminated(NetconfClientSession clientSession,
-            NetconfTerminationReason netconfTerminationReason) {
+                                          NetconfTerminationReason netconfTerminationReason) {
         LOG.debug("Client Session {} terminated, reason: {}", clientSession,
                 netconfTerminationReason.getErrorMessage());
         tearDown(new RuntimeException(netconfTerminationReason.getErrorMessage()));
index 65a433fe16d03dce4a4b024cbf0a98526e5631eb..9adf79cef1d404860ce8bc5cbfd2f5c00b67f3aa 100644 (file)
@@ -20,9 +20,9 @@ final class SshClientChannelInitializer extends AbstractChannelInitializer<Netco
     private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
     private final NetconfClientSessionListener sessionListener;
 
-    public SshClientChannelInitializer(final AuthenticationHandler authHandler,
-                                       final NetconfClientSessionNegotiatorFactory negotiatorFactory,
-                                       final NetconfClientSessionListener sessionListener) {
+    SshClientChannelInitializer(final AuthenticationHandler authHandler,
+                                final NetconfClientSessionNegotiatorFactory negotiatorFactory,
+                                final NetconfClientSessionListener sessionListener) {
         this.authenticationHandler = authHandler;
         this.negotiatorFactory = negotiatorFactory;
         this.sessionListener = sessionListener;
@@ -33,7 +33,7 @@ final class SshClientChannelInitializer extends AbstractChannelInitializer<Netco
         try {
             // ssh handler has to be the first handler in pipeline
             ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler, promise));
-            super.initialize(ch,promise);
+            super.initialize(ch, promise);
         } catch (final IOException e) {
             throw new RuntimeException(e);
         }
@@ -42,7 +42,7 @@ final class SshClientChannelInitializer extends AbstractChannelInitializer<Netco
     @Override
     protected void initializeSessionNegotiator(final Channel ch,
                                                final Promise<NetconfClientSession> promise) {
-        ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER,  AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
+        ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
                 negotiatorFactory.getSessionNegotiator(() -> sessionListener, ch, promise));
     }
 }
index 84f4bf9f3238c54a91f75cb500ce0c1f79756222..2cf0e1a5cd32e04aaabf297a695e786946f8723b 100644 (file)
@@ -41,7 +41,8 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
             GenericFutureListener<Future<NetconfClientSession>> negotiationFutureListener;
 
             @Override
-            public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress,
+            public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
+                                final SocketAddress localAddress,
                                 final ChannelPromise channelPromise) throws Exception {
                 connectPromise = channelPromise;
                 ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch);
@@ -53,7 +54,7 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
                 };
 
                 tcpConnectFuture.addListener(future -> {
-                    if(future.isSuccess()) {
+                    if (future.isSuccess()) {
                         //complete connection promise with netconf negotiation future
                         negotiationFuture.addListener(negotiationFutureListener);
                     } else {
@@ -65,14 +66,15 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
 
             @Override
             public void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
-                // If we have already succeeded and the session was dropped after, we need to fire inactive to notify reconnect logic
-                if(connectPromise.isSuccess()) {
+                // If we have already succeeded and the session was dropped after, we need to fire inactive to notify
+                // reconnect logic
+                if (connectPromise.isSuccess()) {
                     ctx.fireChannelInactive();
                 }
 
                 //If connection promise is not already set, it means negotiation failed
                 //we must set connection promise to failure
-                if(!connectPromise.isDone()) {
+                if (!connectPromise.isDone()) {
                     connectPromise.setFailure(new IllegalStateException("Negotiation failed"));
                 }
 
index 59a8d1f446169b123b2065bd32504233666eca62..d1d6e40176abc79407c0f4466dde96b18e7380d0 100644 (file)
@@ -16,9 +16,13 @@ import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NetconfClientConfiguration {
 
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfClientConfiguration.class);
+
     private final NetconfClientProtocol clientProtocol;
     private final InetSocketAddress address;
     private final Long connectionTimeoutMillis;
@@ -30,7 +34,11 @@ public class NetconfClientConfiguration {
 
     private final AuthenticationHandler authHandler;
 
-    NetconfClientConfiguration(final NetconfClientProtocol protocol, final InetSocketAddress address, final Long connectionTimeoutMillis, final NetconfHelloMessageAdditionalHeader additionalHeader, final NetconfClientSessionListener sessionListener, final ReconnectStrategy reconnectStrategy, final AuthenticationHandler authHandler) {
+    NetconfClientConfiguration(final NetconfClientProtocol protocol, final InetSocketAddress address,
+                               final Long connectionTimeoutMillis,
+                               final NetconfHelloMessageAdditionalHeader additionalHeader,
+                               final NetconfClientSessionListener sessionListener,
+                               final ReconnectStrategy reconnectStrategy, final AuthenticationHandler authHandler) {
         this.address = address;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
         this.additionalHeader = additionalHeader;
@@ -69,14 +77,17 @@ public class NetconfClientConfiguration {
         return clientProtocol;
     }
 
+    @SuppressWarnings("checkstyle:FallThrough")
     private void validateConfiguration() {
         Preconditions.checkNotNull(clientProtocol, " ");
         switch (clientProtocol) {
-        case SSH:
-            validateSshConfiguration();
-            // Fall through intentional (ssh validation is a superset of tcp validation)
-        case TCP:
-            validateTcpConfiguration();
+            case SSH:
+                validateSshConfiguration();
+                // Fall through intentional (ssh validation is a superset of tcp validation)
+            case TCP:
+                validateTcpConfiguration();
+            default:
+                LOG.warn("Unexpected protocol: {} in netconf client configuration.", clientProtocol);
         }
     }
 
@@ -108,7 +119,7 @@ public class NetconfClientConfiguration {
                 .add("authHandler", authHandler);
     }
 
-    public static enum NetconfClientProtocol {
+    public enum NetconfClientProtocol {
         TCP, SSH
     }
 }
\ No newline at end of file
index d1f2b42d4ec51e5247ebfe25affe5fbe6085898a..8047d60f1cca6cdc9101b9a782d117349992e137 100644 (file)
@@ -16,7 +16,8 @@ import org.opendaylight.protocol.framework.ReconnectStrategy;
 public class NetconfClientConfigurationBuilder {
 
     public static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000;
-    public static final NetconfClientConfiguration.NetconfClientProtocol DEFAULT_CLIENT_PROTOCOL = NetconfClientConfiguration.NetconfClientProtocol.TCP;
+    public static final NetconfClientConfiguration.NetconfClientProtocol DEFAULT_CLIENT_PROTOCOL =
+            NetconfClientConfiguration.NetconfClientProtocol.TCP;
 
     private InetSocketAddress address;
     private long connectionTimeoutMillis = DEFAULT_CONNECTION_TIMEOUT_MILLIS;
@@ -43,12 +44,14 @@ public class NetconfClientConfigurationBuilder {
         return this;
     }
 
-    public NetconfClientConfigurationBuilder withProtocol(final NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
+    public NetconfClientConfigurationBuilder withProtocol(
+            final NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
         this.clientProtocol = clientProtocol;
         return this;
     }
 
-    public NetconfClientConfigurationBuilder withAdditionalHeader(final NetconfHelloMessageAdditionalHeader additionalHeader) {
+    public NetconfClientConfigurationBuilder withAdditionalHeader(
+            final NetconfHelloMessageAdditionalHeader additionalHeader) {
         this.additionalHeader = additionalHeader;
         return this;
     }
@@ -97,6 +100,7 @@ public class NetconfClientConfigurationBuilder {
     }
 
     public NetconfClientConfiguration build() {
-        return new NetconfClientConfiguration(clientProtocol, address, connectionTimeoutMillis, additionalHeader, sessionListener, reconnectStrategy, authHandler);
+        return new NetconfClientConfiguration(clientProtocol, address, connectionTimeoutMillis, additionalHeader,
+                sessionListener, reconnectStrategy, authHandler);
     }
 }
index dcb9ec310dd623813779820c306801e38a22d044..a2512687e4ad569a35adc5bfd5f91472edc62797 100644 (file)
@@ -21,9 +21,12 @@ public final class NetconfReconnectingClientConfiguration extends NetconfClientC
     private final ReconnectStrategyFactory connectStrategyFactory;
 
     NetconfReconnectingClientConfiguration(final NetconfClientProtocol clientProtocol, final InetSocketAddress address,
-            final Long connectionTimeoutMillis, final NetconfHelloMessageAdditionalHeader additionalHeader,
-            final NetconfClientSessionListener sessionListener, final ReconnectStrategy reconnectStrategy,
-            final ReconnectStrategyFactory connectStrategyFactory, final AuthenticationHandler authHandler) {
+                                           final Long connectionTimeoutMillis,
+                                           final NetconfHelloMessageAdditionalHeader additionalHeader,
+                                           final NetconfClientSessionListener sessionListener,
+                                           final ReconnectStrategy reconnectStrategy,
+                                           final ReconnectStrategyFactory connectStrategyFactory,
+                                           final AuthenticationHandler authHandler) {
         super(clientProtocol, address, connectionTimeoutMillis, additionalHeader, sessionListener, reconnectStrategy,
                 authHandler);
         this.connectStrategyFactory = connectStrategyFactory;
index dfa334c5b36b069fe81bc861caed083987532703..4597dca75eb2cc4ba0e5c07a919af1e6e485392f 100644 (file)
@@ -26,14 +26,17 @@ public class NetconfReconnectingClientConfigurationBuilder extends NetconfClient
     }
 
 
-    public NetconfReconnectingClientConfigurationBuilder withConnectStrategyFactory(final ReconnectStrategyFactory connectStrategyFactory) {
+    public NetconfReconnectingClientConfigurationBuilder withConnectStrategyFactory(
+            final ReconnectStrategyFactory connectStrategyFactory) {
         this.connectStrategyFactory = connectStrategyFactory;
         return this;
     }
 
     @Override
     public NetconfReconnectingClientConfiguration build() {
-        return new NetconfReconnectingClientConfiguration(getProtocol(), getAddress(), getConnectionTimeoutMillis(), getAdditionalHeader(), getSessionListener(), getReconnectStrategy(), connectStrategyFactory, getAuthHandler());
+        return new NetconfReconnectingClientConfiguration(getProtocol(), getAddress(), getConnectionTimeoutMillis(),
+                getAdditionalHeader(), getSessionListener(), getReconnectStrategy(), connectStrategyFactory,
+                getAuthHandler());
     }
 
     // Override setter methods to return subtype
@@ -44,22 +47,27 @@ public class NetconfReconnectingClientConfigurationBuilder extends NetconfClient
     }
 
     @Override
-    public NetconfReconnectingClientConfigurationBuilder withConnectionTimeoutMillis(final long connectionTimeoutMillis) {
-        return (NetconfReconnectingClientConfigurationBuilder) super.withConnectionTimeoutMillis(connectionTimeoutMillis);
+    public NetconfReconnectingClientConfigurationBuilder withConnectionTimeoutMillis(
+            final long connectionTimeoutMillis) {
+        return (NetconfReconnectingClientConfigurationBuilder)
+                super.withConnectionTimeoutMillis(connectionTimeoutMillis);
     }
 
     @Override
-    public NetconfReconnectingClientConfigurationBuilder withAdditionalHeader(final NetconfHelloMessageAdditionalHeader additionalHeader) {
+    public NetconfReconnectingClientConfigurationBuilder withAdditionalHeader(
+            final NetconfHelloMessageAdditionalHeader additionalHeader) {
         return (NetconfReconnectingClientConfigurationBuilder) super.withAdditionalHeader(additionalHeader);
     }
 
     @Override
-    public NetconfReconnectingClientConfigurationBuilder withSessionListener(final NetconfClientSessionListener sessionListener) {
+    public NetconfReconnectingClientConfigurationBuilder withSessionListener(
+            final NetconfClientSessionListener sessionListener) {
         return (NetconfReconnectingClientConfigurationBuilder) super.withSessionListener(sessionListener);
     }
 
     @Override
-    public NetconfReconnectingClientConfigurationBuilder withReconnectStrategy(final ReconnectStrategy reconnectStrategy) {
+    public NetconfReconnectingClientConfigurationBuilder withReconnectStrategy(
+            final ReconnectStrategy reconnectStrategy) {
         return (NetconfReconnectingClientConfigurationBuilder) super.withReconnectStrategy(reconnectStrategy);
     }
 
@@ -69,7 +77,8 @@ public class NetconfReconnectingClientConfigurationBuilder extends NetconfClient
     }
 
     @Override
-    public NetconfReconnectingClientConfigurationBuilder withProtocol(NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
+    public NetconfReconnectingClientConfigurationBuilder withProtocol(
+            NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
         return (NetconfReconnectingClientConfigurationBuilder) super.withProtocol(clientProtocol);
     }
 }
index 0d4f0addf90408a3cb7f09d3300af953d75833c7..e5aec5d402da77928491b2bb0a6b9b9ac8052070 100644 (file)
@@ -23,19 +23,20 @@ public class NetconfClientConfigurationTest {
     @Test
     public void testNetconfClientConfiguration() throws Exception {
         Long timeout = 200L;
-        NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
+        NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
         NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
         InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
         ReconnectStrategy strategy = Mockito.mock(ReconnectStrategy.class);
         AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class);
-        NetconfClientConfiguration cfg = NetconfClientConfigurationBuilder.create().
-                withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
-                withAddress(address).
-                withConnectionTimeoutMillis(timeout).
-                withReconnectStrategy(strategy).
-                withAdditionalHeader(header).
-                withSessionListener(listener).
-                withAuthHandler(handler).build();
+        NetconfClientConfiguration cfg = NetconfClientConfigurationBuilder.create()
+                .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH)
+                .withAddress(address)
+                .withConnectionTimeoutMillis(timeout)
+                .withReconnectStrategy(strategy)
+                .withAdditionalHeader(header)
+                .withSessionListener(listener)
+                .withAuthHandler(handler).build();
 
         Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis());
         Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader());
index c2c1289555e0d136e96581b4413b166fcf2dd4cb..82bbe001381154707cb111422ff8190791508092 100644 (file)
@@ -49,7 +49,8 @@ public class NetconfClientDispatcherImplTest {
         doReturn(thr).when(chf).cause();
 
         Long timeout = 200L;
-        NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
+        NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
         NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
         InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
         ReconnectStrategyFactory reconnectStrategyFactory = Mockito.mock(ReconnectStrategyFactory.class);
@@ -62,32 +63,32 @@ public class NetconfClientDispatcherImplTest {
         doReturn("").when(reconnectStrategyFactory).toString();
         doReturn(reconnect).when(reconnectStrategyFactory).createReconnectStrategy();
 
-        NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create().
-                withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
-                withAddress(address).
-                withConnectionTimeoutMillis(timeout).
-                withReconnectStrategy(reconnect).
-                withAdditionalHeader(header).
-                withSessionListener(listener).
-                withConnectStrategyFactory(reconnectStrategyFactory).
-                withAuthHandler(handler).build();
+        NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create()
+                .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH)
+                .withAddress(address)
+                .withConnectionTimeoutMillis(timeout)
+                .withReconnectStrategy(reconnect)
+                .withAdditionalHeader(header)
+                .withSessionListener(listener)
+                .withConnectStrategyFactory(reconnectStrategyFactory)
+                .withAuthHandler(handler).build();
 
-        NetconfReconnectingClientConfiguration cfg2 = NetconfReconnectingClientConfigurationBuilder.create().
-                withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP).
-                withAddress(address).
-                withConnectionTimeoutMillis(timeout).
-                withReconnectStrategy(reconnect).
-                withAdditionalHeader(header).
-                withSessionListener(listener).
-                withConnectStrategyFactory(reconnectStrategyFactory).
-                withAuthHandler(handler).build();
+        NetconfReconnectingClientConfiguration cfg2 = NetconfReconnectingClientConfigurationBuilder.create()
+                .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP)
+                .withAddress(address)
+                .withConnectionTimeoutMillis(timeout)
+                .withReconnectStrategy(reconnect)
+                .withAdditionalHeader(header)
+                .withSessionListener(listener)
+                .withConnectStrategyFactory(reconnectStrategyFactory)
+                .withAuthHandler(handler).build();
 
         NetconfClientDispatcherImpl dispatcher = new NetconfClientDispatcherImpl(bossGroup, workerGroup, timer);
         Future<NetconfClientSession> sshSession = dispatcher.createClient(cfg);
         Future<NetconfClientSession> tcpSession = dispatcher.createClient(cfg2);
 
         Future<Void> sshReconn = dispatcher.createReconnectingClient(cfg);
-        Future<Void> tcpReconn = dispatcher.createReconnectingClient(cfg2);
+        final Future<Void> tcpReconn = dispatcher.createReconnectingClient(cfg2);
 
         assertNotNull(sshSession);
         assertNotNull(tcpSession);
index 3c24b7b5f8da7cd75b9a6433fce5ec227d2060cf..718c67b7989106cd2fe2220a5c836812d243ac08 100644 (file)
@@ -35,7 +35,8 @@ public class NetconfClientSessionNegotiatorFactoryTest {
         NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
                 Optional.<NetconfHelloMessageAdditionalHeader>absent(), 200L);
 
-        SessionNegotiator<?> sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise);
+        SessionNegotiator<?> sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel,
+                promise);
         assertNotNull(sessionNegotiator);
     }
 }
index 9632d176af12e0345cdda287a79293503928436a..8ca1d8c8115098cf447a467eaba49f867acca0a6 100644 (file)
@@ -66,7 +66,8 @@ public class NetconfClientSessionNegotiatorTest {
 
     @Before
     public void setUp() throws Exception {
-        helloMessage = NetconfHelloMessage.createClientHello(Sets.newSet("exi:1.0"), Optional.<NetconfHelloMessageAdditionalHeader>absent());
+        helloMessage = NetconfHelloMessage.createClientHello(Sets.newSet("exi:1.0"), Optional
+                .<NetconfHelloMessageAdditionalHeader>absent());
         pipeline = mockChannelPipeline();
         future = mockChannelFuture();
         channel = mockChannel();
@@ -107,8 +108,10 @@ public class NetconfClientSessionNegotiatorTest {
         doReturn(handler).when(pipeline).replace(anyString(), anyString(), any(ChunkedFramingMechanismEncoder.class));
 
         NetconfXMLToHelloMessageDecoder messageDecoder = new NetconfXMLToHelloMessageDecoder();
-        doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(NetconfXMLToMessageDecoder.class));
-        doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(), any(NetconfClientSession.class));
+        doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(NetconfXMLToMessageDecoder
+                .class));
+        doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(), any(NetconfClientSession
+                .class));
         return pipeline;
     }
 
@@ -126,8 +129,9 @@ public class NetconfClientSessionNegotiatorTest {
         }).when(eventLoop).execute(any(Runnable.class));
     }
 
-    private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(final Promise<NetconfClientSession> promise,
-                                                                                final NetconfMessage startExi) {
+    private NetconfClientSessionNegotiator createNetconfClientSessionNegotiator(
+            final Promise<NetconfClientSession> promise,
+            final NetconfMessage startExi) {
         ChannelProgressivePromise progressivePromise = mock(ChannelProgressivePromise.class);
         NetconfClientSessionPreferences preferences = new NetconfClientSessionPreferences(helloMessage, startExi);
         doReturn(progressivePromise).when(promise).setFailure(any(Throwable.class));
@@ -203,13 +207,16 @@ public class NetconfClientSessionNegotiatorTest {
         NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
         NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
 
-        Set<String> set =  createCapabilities("/helloMessage3.xml");
+        Set<String> set = createCapabilities("/helloMessage3.xml");
 
-        final Set<String> cachedS1 = (Set<String>) negotiator.getSession(sessionListener,channel,createHelloMsg("/helloMessage1.xml")).getServerCapabilities();
+        final Set<String> cachedS1 = (Set<String>) negotiator.getSession(sessionListener, channel,
+                createHelloMsg("/helloMessage1.xml")).getServerCapabilities();
 
         //helloMessage2 and helloMessage3 are the same with different order
-        final Set<String> cachedS2 = (Set<String>) negotiator.getSession(sessionListener,channel,createHelloMsg("/helloMessage2.xml")).getServerCapabilities();
-        final Set<String> cachedS3 = (Set<String>) negotiator.getSession(sessionListener,channel,createHelloMsg("/helloMessage3.xml")).getServerCapabilities();
+        final Set<String> cachedS2 = (Set<String>) negotiator.getSession(sessionListener, channel,
+                createHelloMsg("/helloMessage2.xml")).getServerCapabilities();
+        final Set<String> cachedS3 = (Set<String>) negotiator.getSession(sessionListener, channel,
+                createHelloMsg("/helloMessage3.xml")).getServerCapabilities();
 
         assertEquals(cachedS3, set);
         assertNotEquals(cachedS1, set);
index 6ec737d01699f3b7749c2cdd79529470f1504cd9..d6e480014c5b74a4f5576bc9ce36e9c01772ed29 100644 (file)
@@ -25,22 +25,23 @@ public class NetconfReconnectingClientConfigurationTest {
     @Test
     public void testNetconfReconnectingClientConfiguration() throws Exception {
         Long timeout = 200L;
-        NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
+        NetconfHelloMessageAdditionalHeader header =
+                new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
         NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
         InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
         ReconnectStrategyFactory strategy = Mockito.mock(ReconnectStrategyFactory.class);
         AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class);
         ReconnectStrategy reconnect = Mockito.mock(ReconnectStrategy.class);
 
-        NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create().
-                withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
-                withAddress(address).
-                withConnectionTimeoutMillis(timeout).
-                withReconnectStrategy(reconnect).
-                withAdditionalHeader(header).
-                withSessionListener(listener).
-                withConnectStrategyFactory(strategy).
-                withAuthHandler(handler).build();
+        NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create()
+                .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH)
+                .withAddress(address)
+                .withConnectionTimeoutMillis(timeout)
+                .withReconnectStrategy(reconnect)
+                .withAdditionalHeader(header)
+                .withSessionListener(listener)
+                .withConnectStrategyFactory(strategy)
+                .withAuthHandler(handler).build();
 
         Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis());
         Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader());
index 6d0fb5b44e66798b812c64e6db32b1fbef05050e..1dde3d4dfa64f6f7b4151d807ec722557dd52c28 100644 (file)
@@ -73,7 +73,7 @@ public class SimpleNetconfClientSessionListenerTest {
     @Test
     public void testSessionDown() throws Exception {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
-        Future<NetconfMessage> promise = simpleListener.sendRequest(message);
+        final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
         verify(channel, times(1)).writeAndFlush(anyObject());
 
@@ -84,7 +84,7 @@ public class SimpleNetconfClientSessionListenerTest {
     @Test
     public void testSendRequest() throws Exception {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
-        Future<NetconfMessage> promise = simpleListener.sendRequest(message);
+        final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
         verify(channel, times(1)).writeAndFlush(anyObject());
 
@@ -95,7 +95,7 @@ public class SimpleNetconfClientSessionListenerTest {
     @Test
     public void testOnMessage() throws Exception {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
-        Future<NetconfMessage> promise = simpleListener.sendRequest(message);
+        final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
         verify(channel, times(1)).writeAndFlush(anyObject());
 
index 288e0662eae15a5b3d21dffdd5dfcf5d98d670ac..2bfe717403472ff663743d8daefe805ff7652ece 100644 (file)
@@ -34,7 +34,8 @@ public class SshClientChannelInitializerTest {
 
         SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
         doReturn("").when(sessionNegotiator).toString();
-        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class));
+        doReturn(sessionNegotiator).when(negotiatorFactory).getSessionNegotiator(any(SessionListenerFactory.class),
+                any(Channel.class), any(Promise.class));
         ChannelPipeline pipeline = mock(ChannelPipeline.class);
         doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
         Channel channel = mock(Channel.class);
@@ -46,8 +47,8 @@ public class SshClientChannelInitializerTest {
         Promise<NetconfClientSession> promise = mock(Promise.class);
         doReturn("").when(promise).toString();
 
-        SshClientChannelInitializer initializer = new SshClientChannelInitializer(authenticationHandler, negotiatorFactory,
-                sessionListener);
+        SshClientChannelInitializer initializer = new SshClientChannelInitializer(authenticationHandler,
+                negotiatorFactory, sessionListener);
         initializer.initialize(channel, promise);
         verify(pipeline, times(1)).addFirst(any(ChannelHandler.class));
     }
index 04b284bc54c8991d20387b175cb772bf62fbbdc5..7ff2f174739261f415749dd9105e30e5d9e5cb4c 100644 (file)
@@ -29,9 +29,10 @@ public class TcpClientChannelInitializerTest {
         NetconfClientSessionNegotiatorFactory factory = mock(NetconfClientSessionNegotiatorFactory.class);
         SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
         doReturn("").when(sessionNegotiator).toString();
-        doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class));
+        doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class),
+                any(Channel.class), any(Promise.class));
         NetconfClientSessionListener listener = mock(NetconfClientSessionListener.class);
-        TcpClientChannelInitializer initializer = new TcpClientChannelInitializer(factory, listener);
+        final TcpClientChannelInitializer initializer = new TcpClientChannelInitializer(factory, listener);
         ChannelPipeline pipeline = mock(ChannelPipeline.class);
         doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
         Channel channel = mock(Channel.class);
index dabe11a3ed9606b42daf45cbde69075cd0787437..10f7ae893d8aa6e4d9e1dc8d69703b20863700a7 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 
 
 /**
- * Synchronous netconf client suitable for testing
+ * Synchronous netconf client suitable for testing.
  */
 public class TestingNetconfClient implements Closeable {
 
@@ -47,7 +47,8 @@ public class TestingNetconfClient implements Closeable {
     private final long sessionId;
 
     public TestingNetconfClient(String clientLabel,
-                                NetconfClientDispatcher netconfClientDispatcher, final NetconfClientConfiguration config) throws InterruptedException {
+                                NetconfClientDispatcher netconfClientDispatcher,
+                                final NetconfClientConfiguration config) throws InterruptedException {
         this.label = clientLabel;
         sessionListener = config.getSessionListener();
         Future<NetconfClientSession> clientFuture = netconfClientDispatcher.createClient(config);
@@ -66,7 +67,7 @@ public class TestingNetconfClient implements Closeable {
     }
 
     public Future<NetconfMessage> sendRequest(NetconfMessage message) {
-        return ((SimpleNetconfClientSessionListener)sessionListener).sendRequest(message);
+        return ((SimpleNetconfClientSessionListener) sessionListener).sendRequest(message);
     }
 
     public NetconfMessage sendMessage(NetconfMessage message, int attemptMsDelay) throws ExecutionException,
@@ -105,13 +106,16 @@ public class TestingNetconfClient implements Closeable {
     public static void main(String[] args) throws Exception {
         HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
         NioEventLoopGroup nettyGroup = new NioEventLoopGroup();
-        NetconfClientDispatcherImpl netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer);
+        NetconfClientDispatcherImpl netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup,
+                hashedWheelTimer);
         LoginPassword authHandler = new LoginPassword("admin", "admin");
-        TestingNetconfClient client = new TestingNetconfClient("client", netconfClientDispatcher, getClientConfig("127.0.0.1", 1830, true, Optional.of(authHandler)));
+        TestingNetconfClient client = new TestingNetconfClient("client", netconfClientDispatcher,
+                getClientConfig("127.0.0.1", 1830, true, Optional.of(authHandler)));
         System.console().writer().println(client.getCapabilities());
     }
 
-    private static NetconfClientConfiguration getClientConfig(String host ,int port, boolean ssh, Optional<? extends AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
+    private static NetconfClientConfiguration getClientConfig(String host, int port, boolean ssh, Optional<? extends
+            AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
         InetSocketAddress netconfAddress = new InetSocketAddress(InetAddress.getByName(host), port);
         final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
         b.withAddress(netconfAddress);