From: Marian Dubai Date: Fri, 14 Nov 2014 14:25:45 +0000 (+0100) Subject: Fix checkstyle warnings in netconf-client X-Git-Tag: release/lithium~853 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=42f9ed728bc7a13e2599fbc8493b5c7ae161e68a Fix checkstyle warnings in netconf-client Change-Id: I94d8c31a16f0755451a3bebad5a8792a97d426d2 Signed-off-by: Marian Dubai --- diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImpl.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImpl.java index bdebfa28cc..5d584f3b98 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImpl.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImpl.java @@ -8,24 +8,22 @@ package org.opendaylight.controller.netconf.client; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.util.Timer; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.Promise; import java.io.Closeable; - import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.protocol.framework.AbstractDispatcher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.util.Timer; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.Promise; - public class NetconfClientDispatcherImpl extends AbstractDispatcher implements NetconfClientDispatcher, Closeable { - private static final Logger logger = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class); private final Timer timer; @@ -48,14 +46,17 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher createReconnectingClient(final NetconfReconnectingClientConfiguration clientConfiguration) { switch (clientConfiguration.getProtocol()) { - case TCP: return createReconnectingTcpClient(clientConfiguration); - case SSH: return createReconnectingSshClient(clientConfiguration); - default: throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol()); + case TCP: + return createReconnectingTcpClient(clientConfiguration); + case SSH: + return createReconnectingSshClient(clientConfiguration); + default: + throw new IllegalArgumentException("Unknown client protocol " + clientConfiguration.getProtocol()); } } private Future createTcpClient(final NetconfClientConfiguration currentConfiguration) { - logger.debug("Creating TCP client with configuration: {}", currentConfiguration); + LOG.debug("Creating TCP client with configuration: {}", currentConfiguration); return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(), new PipelineInitializer() { @@ -72,7 +73,7 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher createReconnectingTcpClient(final NetconfReconnectingClientConfiguration currentConfiguration) { - logger.debug("Creating reconnecting TCP client with configuration: {}", currentConfiguration); + LOG.debug("Creating reconnecting TCP client with configuration: {}", currentConfiguration); final TcpClientChannelInitializer init = new TcpClientChannelInitializer(getNegotiatorFactory(currentConfiguration), currentConfiguration.getSessionListener()); @@ -86,7 +87,7 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher createSshClient(final NetconfClientConfiguration currentConfiguration) { - logger.debug("Creating SSH client with configuration: {}", currentConfiguration); + LOG.debug("Creating SSH client with configuration: {}", currentConfiguration); return super.createClient(currentConfiguration.getAddress(), currentConfiguration.getReconnectStrategy(), new PipelineInitializer() { @@ -102,7 +103,7 @@ public class NetconfClientDispatcherImpl extends AbstractDispatcher createReconnectingSshClient(final NetconfReconnectingClientConfiguration currentConfiguration) { - logger.debug("Creating reconnecting SSH client with configuration: {}", currentConfiguration); + LOG.debug("Creating reconnecting SSH client with configuration: {}", currentConfiguration); final SshClientChannelInitializer init = new SshClientChannelInitializer(currentConfiguration.getAuthHandler(), getNegotiatorFactory(currentConfiguration), currentConfiguration.getSessionListener()); diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java index bd91af5bcc..732b8fa1ca 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java @@ -9,9 +9,7 @@ package org.opendaylight.controller.netconf.client; import io.netty.channel.Channel; - import java.util.Collection; - import org.opendaylight.controller.netconf.nettyutil.AbstractNetconfSession; import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXICodec; import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXIToMessageDecoder; @@ -23,7 +21,7 @@ import org.slf4j.LoggerFactory; public class NetconfClientSession extends AbstractNetconfSession { - private static final Logger logger = LoggerFactory.getLogger(NetconfClientSession.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSession.class); private final Collection capabilities; /** @@ -38,7 +36,7 @@ public class NetconfClientSession extends AbstractNetconfSession capabilities) { super(sessionListener, channel, sessionId); this.capabilities = capabilities; - logger.debug("Client Session {} created", toString()); + LOG.debug("Client Session {} created", toString()); } public Collection getServerCapabilities() { diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiator.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiator.java index cbbee1f655..a8c9a6526d 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiator.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiator.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.netconf.client; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; - import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; @@ -18,12 +17,9 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.Timer; import io.netty.util.concurrent.Promise; - import java.util.Collection; - import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; - import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; @@ -44,7 +40,7 @@ import org.w3c.dom.NodeList; public class NetconfClientSessionNegotiator extends AbstractNetconfSessionNegotiator { - private static final Logger logger = LoggerFactory.getLogger(NetconfClientSessionNegotiator.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiator.class); private static final XPathExpression sessionIdXPath = XMLNetconfUtil .compileXPath("/netconf:hello/netconf:session-id"); @@ -68,12 +64,12 @@ public class NetconfClientSessionNegotiator extends // If exi should be used, try to initiate exi communication // Call negotiationSuccessFul after exi negotiation is finished successfully or not if (shouldUseExi(netconfMessage)) { - logger.debug("Netconf session {} should use exi.", session); + LOG.debug("Netconf session {} should use exi.", session); NetconfStartExiMessage startExiMessage = (NetconfStartExiMessage) sessionPreferences.getStartExiMessage(); tryToInitiateExi(session, startExiMessage); } else { // Exi is not supported, release session immediately - logger.debug("Netconf session {} isn't capable of using exi.", session); + LOG.debug("Netconf session {} isn't capable of using exi.", session); negotiationSuccessful(session); } } @@ -92,10 +88,10 @@ public class NetconfClientSessionNegotiator extends @Override public void operationComplete(final ChannelFuture f) { if (!f.isSuccess()) { - logger.warn("Failed to send start-exi message {} on session {}", startExiMessage, this, f.cause()); + LOG.warn("Failed to send start-exi message {} on session {}", startExiMessage, this, f.cause()); channel.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER); } else { - logger.trace("Start-exi message {} sent to socket on session {}", startExiMessage, this); + LOG.trace("Start-exi message {} sent to socket on session {}", startExiMessage, this); } } }); @@ -161,26 +157,26 @@ public class NetconfClientSessionNegotiator extends // Ok response to start-exi, try to add exi handlers if (NetconfMessageUtil.isOKMessage(netconfMessage)) { - logger.trace("Positive response on start-exi call received on session {}", session); + LOG.trace("Positive response on start-exi call received on session {}", session); try { session.startExiCommunication(startExiMessage); } catch (RuntimeException e) { // Unable to add exi, continue without exi - logger.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)) { - logger.warn( + LOG.warn( "Error response to start-exi message {}, Communication will continue without exi on session {}", XmlUtil.toString(netconfMessage.getDocument()), session); // Unexpected response to start-exi, throwing message away, continue without exi } else { - logger.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 {}", - XmlUtil.toString(netconfMessage.getDocument()), session); + LOG.warn( + "Unexpected response to start-exi message, should be ok, was {}, ",XmlUtil.toString(netconfMessage.getDocument()), + "Communication will continue without exi and response message will be thrown away on session {}", + session); } negotiationSuccessful(session); diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java index 3b1de348ff..7efb28b467 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java @@ -11,11 +11,9 @@ package org.opendaylight.controller.netconf.client; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; - import io.netty.channel.Channel; import io.netty.util.Timer; import io.netty.util.concurrent.Promise; - import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; @@ -45,7 +43,7 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF private final long connectionTimeoutMillis; private final Timer timer; private final EXIOptions options; - private static final Logger logger = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class); public NetconfClientSessionNegotiatorFactory(Timer timer, Optional additionalHeader, @@ -72,7 +70,7 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF try { helloMessage = NetconfHelloMessage.createClientHello(CLIENT_CAPABILITIES, additionalHeader); } catch (NetconfDocumentedException e) { - logger.error("Unable to create client hello message with capabilities {} and additional handler {}",CLIENT_CAPABILITIES,additionalHeader); + LOG.error("Unable to create client hello message with capabilities {} and additional handler {}",CLIENT_CAPABILITIES,additionalHeader); throw new IllegalStateException(e); } diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java index 524f0b52b7..77f8741a4f 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java @@ -8,22 +8,18 @@ package org.opendaylight.controller.netconf.client; +import com.google.common.base.Preconditions; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GlobalEventExecutor; import io.netty.util.concurrent.Promise; - import java.util.ArrayDeque; import java.util.Queue; - import javax.annotation.concurrent.GuardedBy; - import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.api.NetconfTerminationReason; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; - public class SimpleNetconfClientSessionListener implements NetconfClientSessionListener { private static final class RequestEntry { private final Promise promise; @@ -35,7 +31,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL } } - private static final Logger logger = LoggerFactory.getLogger(SimpleNetconfClientSessionListener.class); + private static final Logger LOG = LoggerFactory.getLogger(SimpleNetconfClientSessionListener.class); @GuardedBy("this") private final Queue requests = new ArrayDeque<>(); @@ -48,12 +44,12 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL while (!requests.isEmpty()) { final RequestEntry e = requests.peek(); if (e.promise.setUncancellable()) { - logger.debug("Sending message {}", e.request); + LOG.debug("Sending message {}", e.request); clientSession.sendMessage(e.request); break; } - logger.debug("Message {} has been cancelled, skipping it", e.request); + LOG.debug("Message {} has been cancelled, skipping it", e.request); requests.poll(); } } @@ -61,7 +57,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL @Override public final synchronized void onSessionUp(NetconfClientSession clientSession) { this.clientSession = Preconditions.checkNotNull(clientSession); - logger.debug("Client session {} went up", clientSession); + LOG.debug("Client session {} went up", clientSession); dispatchRequest(); } @@ -76,28 +72,28 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL @Override public final void onSessionDown(NetconfClientSession clientSession, Exception e) { - logger.debug("Client Session {} went down unexpectedly", clientSession, e); + LOG.debug("Client Session {} went down unexpectedly", clientSession, e); tearDown(e); } @Override public final void onSessionTerminated(NetconfClientSession clientSession, NetconfTerminationReason netconfTerminationReason) { - logger.debug("Client Session {} terminated, reason: {}", clientSession, + LOG.debug("Client Session {} terminated, reason: {}", clientSession, netconfTerminationReason.getErrorMessage()); tearDown(new RuntimeException(netconfTerminationReason.getErrorMessage())); } @Override public synchronized void onMessage(NetconfClientSession session, NetconfMessage message) { - logger.debug("New message arrived: {}", message); + LOG.debug("New message arrived: {}", message); final RequestEntry e = requests.poll(); if (e != null) { e.promise.setSuccess(message); dispatchRequest(); } else { - logger.info("Ignoring unsolicited message {}", message); + LOG.info("Ignoring unsolicited message {}", message); } } diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java index 592cdad4c1..5fa217839d 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java @@ -9,19 +9,16 @@ package org.opendaylight.controller.netconf.client; import com.google.common.base.Optional; +import java.net.InetSocketAddress; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; -import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; import org.opendaylight.protocol.framework.ReconnectStrategy; -import java.net.InetSocketAddress; - public class NetconfClientConfigurationTest { @Test public void testNetconfClientConfiguration() throws Exception { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImplTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImplTest.java index dfbb972e8c..ab25f96088 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImplTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcherImplTest.java @@ -8,6 +8,10 @@ package org.opendaylight.controller.netconf.client; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; + import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPromise; @@ -15,11 +19,10 @@ import io.netty.channel.EventLoopGroup; import io.netty.util.HashedWheelTimer; import io.netty.util.Timer; import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; +import java.util.concurrent.Future; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; -import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; -import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder; @@ -28,13 +31,6 @@ import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAddi import org.opendaylight.protocol.framework.ReconnectStrategy; import org.opendaylight.protocol.framework.ReconnectStrategyFactory; -import java.net.InetSocketAddress; -import java.util.concurrent.Future; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; - public class NetconfClientDispatcherImplTest { @Test public void testNetconfClientDispatcherImpl() throws Exception { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java index 62d6275b9e..ecb14cc84d 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactoryTest.java @@ -8,6 +8,10 @@ package org.opendaylight.controller.netconf.client; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + import com.google.common.base.Optional; import io.netty.channel.Channel; import io.netty.util.HashedWheelTimer; @@ -17,9 +21,6 @@ import org.junit.Test; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; import org.opendaylight.protocol.framework.SessionListenerFactory; import org.opendaylight.protocol.framework.SessionNegotiator; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; public class NetconfClientSessionNegotiatorFactoryTest { @Test diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java index 187f13b258..ce18ac0579 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorTest.java @@ -16,6 +16,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; + import com.google.common.base.Optional; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -61,7 +62,6 @@ public class NetconfClientSessionNegotiatorTest { pipeline = mockChannelPipeline(); future = mockChannelFuture(); channel = mockChannel(); - System.out.println("setup done"); } private ChannelHandler mockChannelHandler() { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionTest.java index 731a3fe960..850ad55fc6 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientSessionTest.java @@ -8,27 +8,24 @@ package org.opendaylight.controller.netconf.client; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; + import com.google.common.collect.Lists; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelPipeline; +import java.util.Collection; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.netconf.client.NetconfClientSession; -import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; import org.opendaylight.controller.netconf.nettyutil.handler.NetconfEXICodec; import org.openexi.proc.common.EXIOptions; -import java.util.Collection; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; - public class NetconfClientSessionTest { @Mock diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfReconnectingClientConfigurationTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfReconnectingClientConfigurationTest.java index a9754654d5..c74aa2bf15 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfReconnectingClientConfigurationTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfReconnectingClientConfigurationTest.java @@ -9,11 +9,10 @@ package org.opendaylight.controller.netconf.client; import com.google.common.base.Optional; +import java.net.InetSocketAddress; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; -import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; -import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder; @@ -22,8 +21,6 @@ import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAddi import org.opendaylight.protocol.framework.ReconnectStrategy; import org.opendaylight.protocol.framework.ReconnectStrategyFactory; -import java.net.InetSocketAddress; - public class NetconfReconnectingClientConfigurationTest { @Test public void testNetconfReconnectingClientConfiguration() throws Exception { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListenerTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListenerTest.java index 9065ca45a2..8ce1ef0db5 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListenerTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListenerTest.java @@ -7,20 +7,25 @@ */ package org.opendaylight.controller.netconf.client; -import io.netty.channel.*; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; import io.netty.util.concurrent.Future; +import java.util.Set; import org.junit.Before; import org.junit.Test; import org.mockito.internal.util.collections.Sets; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; -import java.util.Set; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.*; - public class SimpleNetconfClientSessionListenerTest { private Channel channel; diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializerTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializerTest.java index 8c55d8cc10..dc8fde6e2c 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializerTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SshClientChannelInitializerTest.java @@ -8,6 +8,13 @@ package org.opendaylight.controller.netconf.client; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelPipeline; @@ -17,10 +24,6 @@ import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication. import org.opendaylight.protocol.framework.SessionListenerFactory; import org.opendaylight.protocol.framework.SessionNegotiator; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.*; - public class SshClientChannelInitializerTest { @Test public void test() throws Exception { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java index 9c57565981..210f898659 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java @@ -8,6 +8,13 @@ package org.opendaylight.controller.netconf.client; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelPipeline; @@ -16,8 +23,6 @@ import org.junit.Test; import org.opendaylight.protocol.framework.SessionListenerFactory; import org.opendaylight.protocol.framework.SessionNegotiator; -import static org.mockito.Mockito.*; - public class TcpClientChannelInitializerTest { @Test public void testInitializeSessionNegotiator() throws Exception { diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TestingNetconfClient.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TestingNetconfClient.java index d7209d9295..256dc30a14 100644 --- a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TestingNetconfClient.java +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TestingNetconfClient.java @@ -108,7 +108,7 @@ public class TestingNetconfClient implements Closeable { 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))); - System.out.println(client.getCapabilities()); + System.console().writer().println(client.getCapabilities()); } private static NetconfClientConfiguration getClientConfig(String host ,int port, boolean ssh, Optional maybeAuthHandler) throws UnknownHostException {