Bug 8153: Enforce check-style on netconf-impl 90/55790/5
authormatus.kubica <matus.kubica@pantheon.tech>
Fri, 21 Apr 2017 08:30:24 +0000 (10:30 +0200)
committerTomas Cere <tcere@cisco.com>
Thu, 27 Apr 2017 12:57:00 +0000 (12:57 +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 checkstyle for test suites.
Add the fail on violation flag into the pom.xml .

Change-Id: I3173827beb34cbece031e61c1b0ba255357f3445
Signed-off-by: matus.kubica <matus.kubica@pantheon.tech>
28 files changed:
netconf/netconf-impl/pom.xml
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerDispatcherImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSession.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionListener.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiator.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorFactoryBuilder.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultCloseSession.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultNetconfOperation.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStartExi.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStopExi.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/AggregatedNetconfOperationServiceFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringService.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivator.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImpl.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfOperationServiceFactoryTracker.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfSessionMonitoringService.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/AdditionalHeaderParserTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/ConcurrentClientsTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/ExiEncodeDecodeTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfDispatcherImplTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/NetconfServerSessionListenerTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/mapping/operations/DefaultCloseSessionTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/mapping/operations/DefaultStopExiTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringServiceTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivatorTest.java
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfOperationRouterImplTest.java

index 76588defc839e889d0c6a4d9ee6869af941354ca..dde977b82aafb32104c5df3990ab6b867625ccff 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 b7b6f2791fc5ae227b9885144bfafcafafb1daf3..7db8db4f09abcae7d37f6f96d3c887c039d18103 100644 (file)
@@ -22,7 +22,8 @@ import org.opendaylight.netconf.impl.util.DeserializerExceptionHandler;
 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
 import org.opendaylight.protocol.framework.AbstractDispatcher;
 
-public class NetconfServerDispatcherImpl extends AbstractDispatcher<NetconfServerSession, NetconfServerSessionListener> implements NetconfServerDispatcher {
+public class NetconfServerDispatcherImpl extends AbstractDispatcher<NetconfServerSession,
+        NetconfServerSessionListener> implements NetconfServerDispatcher {
 
     private final ServerChannelInitializer initializer;
 
@@ -44,7 +45,8 @@ public class NetconfServerDispatcherImpl extends AbstractDispatcher<NetconfServe
 
     @Override
     public ChannelFuture createLocalServer(LocalAddress address) {
-        return super.createServer(address, LocalServerChannel.class, new ChannelPipelineInitializer<LocalChannel, NetconfServerSession>() {
+        return super.createServer(address, LocalServerChannel.class, new ChannelPipelineInitializer<LocalChannel,
+                NetconfServerSession>() {
             @Override
             public void initializeChannel(final LocalChannel ch, final Promise<NetconfServerSession> promise) {
                 initializer.initialize(ch, promise);
index d023be2f0d41a8a751529a762ff170e29d3c3d8f..dc314c05e0fe49a198ce33cce94925faa305af44 100644 (file)
@@ -47,20 +47,26 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class NetconfServerSession extends AbstractNetconfSession<NetconfServerSession, NetconfServerSessionListener> implements NetconfManagementSession {
+public final class NetconfServerSession extends AbstractNetconfSession<NetconfServerSession,
+        NetconfServerSessionListener> implements NetconfManagementSession {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSession.class);
-    private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+    private static final String DATE_TIME_PATTERN_STRING = DateAndTime.PATTERN_CONSTANTS.get(0);
+    private static final Pattern DATE_TIME_PATTERN = Pattern.compile(DATE_TIME_PATTERN_STRING);
 
     private final NetconfHelloMessageAdditionalHeader header;
     private final NetconfServerSessionListener sessionListener;
 
     private ZonedDateTime loginTime;
-    private long inRpcSuccess, inRpcFail, outRpcError, outNotification;
+    private long inRpcSuccess;
+    private long inRpcFail;
+    private long outRpcError;
+    private long outNotification;
     private volatile boolean delayedClose;
 
-    public NetconfServerSession(final NetconfServerSessionListener sessionListener, final Channel channel, final long sessionId,
-            final NetconfHelloMessageAdditionalHeader header) {
+    public NetconfServerSession(final NetconfServerSessionListener sessionListener, final Channel channel,
+                                final long sessionId, final NetconfHelloMessageAdditionalHeader header) {
         super(sessionListener, channel, sessionId);
         this.header = header;
         this.sessionListener = sessionListener;
@@ -90,7 +96,7 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
             sessionListener.onNotification(this, (NetconfNotification) netconfMessage);
         }
         // delayed close was set, close after the message was sent
-        if(delayedClose) {
+        if (delayedClose) {
             channelFuture.addListener(new ChannelFutureListener() {
                 @Override
                 public void operationComplete(final ChannelFuture future) throws Exception {
@@ -113,9 +119,6 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
         outRpcError++;
     }
 
-    private static final String dateTimePatternString = DateAndTime.PATTERN_CONSTANTS.get(0);
-    private static final Pattern dateTimePattern = Pattern.compile(dateTimePatternString);
-
     @Override
     public Session toManagementSession() {
         SessionBuilder builder = new SessionBuilder();
@@ -131,10 +134,11 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
         builder.setSourceHost(new Host(address));
 
         Preconditions.checkState(DateAndTime.PATTERN_CONSTANTS.size() == 1);
-        String formattedDateTime = dateFormatter.format(loginTime);
+        String formattedDateTime = DATE_FORMATTER.format(loginTime);
 
-        Matcher matcher = dateTimePattern.matcher(formattedDateTime);
-        Preconditions.checkState(matcher.matches(), "Formatted datetime %s does not match pattern %s", formattedDateTime, dateTimePattern);
+        Matcher matcher = DATE_TIME_PATTERN.matcher(formattedDateTime);
+        Preconditions.checkState(matcher.matches(), "Formatted datetime %s does not match pattern %s",
+                formattedDateTime, DATE_TIME_PATTERN);
         builder.setLoginTime(new DateAndTime(formattedDateTime));
 
         builder.setInBadRpcs(new ZeroBasedCounter32(inRpcFail));
@@ -156,13 +160,13 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
     }
 
     private static Class<? extends Transport> getTransportForString(final String transport) {
-        switch(transport) {
-        case "ssh" :
-            return NetconfSsh.class;
-        case "tcp" :
-            return NetconfTcp.class;
-        default:
-            throw new IllegalArgumentException("Unknown transport type " + transport);
+        switch (transport) {
+            case "ssh":
+                return NetconfSsh.class;
+            case "tcp":
+                return NetconfTcp.class;
+            default:
+                throw new IllegalArgumentException("Unknown transport type " + transport);
         }
     }
 
@@ -172,7 +176,8 @@ public final class NetconfServerSession extends AbstractNetconfSession<NetconfSe
     }
 
     @Override
-    protected void addExiHandlers(final ByteToMessageDecoder decoder, final MessageToByteEncoder<NetconfMessage> encoder) {
+    protected void addExiHandlers(final ByteToMessageDecoder decoder,
+                                  final MessageToByteEncoder<NetconfMessage> encoder) {
         replaceMessageDecoder(decoder);
         replaceMessageEncoderAfterNextMessage(encoder);
     }
index b6c8d11a95afaf85da9285b55829ad04adcf8c3a..943edd7365a0b8b0a739d37c74b9d0a64fc8e801 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.impl;
 
-
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
@@ -37,7 +36,8 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
     private final NetconfOperationRouter operationRouter;
     private final AutoCloseable onSessionDownCloseable;
 
-    public NetconfServerSessionListener(final NetconfOperationRouter operationRouter, final NetconfMonitoringService monitoringService,
+    public NetconfServerSessionListener(final NetconfOperationRouter operationRouter,
+                                        final NetconfMonitoringService monitoringService,
                                         final AutoCloseable onSessionDownCloseable) {
         this.operationRouter = operationRouter;
         this.monitoringSessionListener = monitoringService.getSessionListener();
@@ -55,6 +55,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
         onDown(netconfNetconfServerSession);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void onDown(final NetconfServerSession netconfNetconfServerSession) {
         monitoringSessionListener.onSessionDown(netconfNetconfServerSession);
 
@@ -72,12 +73,13 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
 
     @Override
     public void onSessionTerminated(final NetconfServerSession netconfNetconfServerSession,
-            final NetconfTerminationReason netconfTerminationReason) {
+                                    final NetconfTerminationReason netconfTerminationReason) {
         LOG.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
                 netconfTerminationReason.getErrorMessage());
         onDown(netconfNetconfServerSession);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public void onMessage(final NetconfServerSession session, final NetconfMessage netconfMessage) {
         try {
@@ -96,7 +98,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
             monitoringSessionListener.onSessionEvent(SessionEvent.inRpcFail(session));
             throw new IllegalStateException("Unable to process incoming message " + netconfMessage, e);
         } catch (final DocumentedException e) {
-            LOG.trace("Error occurred while processing message",e);
+            LOG.trace("Error occurred while processing message", e);
             session.onOutgoingRpcError();
             session.onIncommingRpcFail();
             monitoringSessionListener.onSessionEvent(SessionEvent.inRpcFail(session));
@@ -137,7 +139,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
             throw new DocumentedException("Unknown tag " + rootNode.getNodeName() + " in message:\n" + netconfMessage,
                     DocumentedException.ErrorType.PROTOCOL, DocumentedException.ErrorTag.UNKNOWN_ELEMENT,
                     DocumentedException.ErrorSeverity.ERROR, ImmutableMap.of("bad-element",
-                            rootNode.getNodeName()));
+                    rootNode.getNodeName()));
         }
     }
 
@@ -145,11 +147,12 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
 
         final NamedNodeMap attributes = rootNode.getAttributes();
 
-        if(attributes.getNamedItemNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.MESSAGE_ID)!=null) {
+        if (attributes.getNamedItemNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
+                XmlNetconfConstants.MESSAGE_ID) != null) {
             return;
         }
 
-        if(attributes.getNamedItem(XmlNetconfConstants.MESSAGE_ID)!=null) {
+        if (attributes.getNamedItem(XmlNetconfConstants.MESSAGE_ID) != null) {
             return;
         }
 
index e3fd704663afa7a3d591dee80a3b6b2a8bc14aaf..b3e263a92beadc5f17597abc0eb46340556f3ff2 100644 (file)
@@ -26,8 +26,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class NetconfServerSessionNegotiator
-        extends
-        AbstractNetconfSessionNegotiator<NetconfServerSessionPreferences, NetconfServerSession, NetconfServerSessionListener> {
+        extends AbstractNetconfSessionNegotiator<NetconfServerSessionPreferences, NetconfServerSession,
+                NetconfServerSessionListener> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiator.class);
 
@@ -78,9 +78,10 @@ public class NetconfServerSessionNegotiator
     }
 
     /**
-     * @param socketAddress
-     *            type of socket address LocalAddress, or
-     *            InetSocketAddress, for others returns unknown
+     * Get a name of the host.
+     *
+     * @param socketAddress type of socket address LocalAddress, or
+     *                      InetSocketAddress, for others returns unknown
      * @return Two values - port and host of socket address
      */
     protected static Map.Entry<String, String> getHostName(
index 44e2d4e8145e6a0124271da2af1635d6f94e20da..3d37f8ec13ddeb0401c0e5c82b17956ba6141b1c 100644 (file)
@@ -35,7 +35,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.mon
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfHelloMessage, NetconfServerSession, NetconfServerSessionListener> {
+public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfHelloMessage,
+        NetconfServerSession, NetconfServerSessionListener> {
 
     public static final Set<String> DEFAULT_BASE_CAPABILITIES = ImmutableSet.of(
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
@@ -52,15 +53,18 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
     private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiatorFactory.class);
     private final Set<String> baseCapabilities;
 
-    public NetconfServerSessionNegotiatorFactory(final Timer timer, final NetconfOperationServiceFactory netconfOperationProvider,
+    public NetconfServerSessionNegotiatorFactory(final Timer timer,
+                                                 final NetconfOperationServiceFactory netconfOperationProvider,
                                                  final SessionIdProvider idProvider, final long connectionTimeoutMillis,
-                                                 final NetconfMonitoringService monitoringService, final Set<String> baseCapabilities) {
+                                                 final NetconfMonitoringService monitoringService,
+                                                 final Set<String> baseCapabilities) {
         this.timer = timer;
         this.aggregatedOpService = netconfOperationProvider;
         this.idProvider = idProvider;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
         this.monitoringService = monitoringService;
-        this.baseCapabilities = validateBaseCapabilities(baseCapabilities == null ? DEFAULT_BASE_CAPABILITIES : baseCapabilities);
+        this.baseCapabilities = validateBaseCapabilities(baseCapabilities == null ? DEFAULT_BASE_CAPABILITIES :
+                baseCapabilities);
     }
 
 
@@ -68,7 +72,8 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
         // Check base capabilities to be supported by the server
         final Sets.SetView<String> unknownBaseCaps = Sets.difference(baseCapabilities, DEFAULT_BASE_CAPABILITIES);
         Preconditions.checkArgument(unknownBaseCaps.isEmpty(),
-                "Base capabilities that will be supported by netconf server have to be subset of %s, unknown base capabilities: %s",
+                "Base capabilities that will be supported by netconf server have to be subset of %s, "
+                        + "unknown base capabilities: %s",
                 DEFAULT_BASE_CAPABILITIES, unknownBaseCaps);
 
         final ImmutableSet.Builder<String> b = ImmutableSet.builder();
@@ -79,16 +84,19 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     /**
+     * Get session negotiator.
+     *
      * @param defunctSessionListenerFactory will not be taken into account as session listener factory can
      *                                      only be created after snapshot is opened, thus this method constructs
      *                                      proper session listener factory.
-     * @param channel Underlying channel
-     * @param promise Promise to be notified
+     * @param channel                       Underlying channel
+     * @param promise                       Promise to be notified
      * @return session negotiator
      */
     @Override
-    public SessionNegotiator<NetconfServerSession> getSessionNegotiator(final SessionListenerFactory<NetconfServerSessionListener> defunctSessionListenerFactory,
-                                                                        final Channel channel, final Promise<NetconfServerSession> promise) {
+    public SessionNegotiator<NetconfServerSession> getSessionNegotiator(
+            final SessionListenerFactory<NetconfServerSessionListener> defunctSessionListenerFactory,
+            final Channel channel, final Promise<NetconfServerSession> promise) {
         final long sessionId = idProvider.getNextSessionId();
 
         NetconfServerSessionPreferences proposal;
@@ -103,15 +111,18 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
                 getListener(Long.toString(sessionId), channel.localAddress()), connectionTimeoutMillis);
     }
 
-    private NetconfServerSessionListener getListener(final String netconfSessionIdForReporting, final SocketAddress socketAddress) {
-        final NetconfOperationService service = getOperationServiceForAddress(netconfSessionIdForReporting, socketAddress);
+    private NetconfServerSessionListener getListener(final String netconfSessionIdForReporting,
+                                                     final SocketAddress socketAddress) {
+        final NetconfOperationService service = getOperationServiceForAddress(netconfSessionIdForReporting,
+                socketAddress);
         final NetconfOperationRouter operationRouter =
                 new NetconfOperationRouterImpl(service, monitoringService, netconfSessionIdForReporting);
         return new NetconfServerSessionListener(operationRouter, monitoringService, service);
 
     }
 
-    protected NetconfOperationService getOperationServiceForAddress(final String netconfSessionIdForReporting, final SocketAddress socketAddress) {
+    protected NetconfOperationService getOperationServiceForAddress(final String netconfSessionIdForReporting,
+                                                                    final SocketAddress socketAddress) {
         return this.aggregatedOpService.createService(netconfSessionIdForReporting);
     }
 
@@ -119,8 +130,10 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
         return aggregatedOpService;
     }
 
-    private NetconfHelloMessage createHelloMessage(final long sessionId, final NetconfMonitoringService capabilityProvider) throws NetconfDocumentedException {
-        return NetconfHelloMessage.createServerHello(Sets.union(transformCapabilities(capabilityProvider.getCapabilities()), baseCapabilities), sessionId);
+    private NetconfHelloMessage createHelloMessage(
+            final long sessionId, final NetconfMonitoringService capabilityProvider) throws NetconfDocumentedException {
+        return NetconfHelloMessage.createServerHello(Sets.union(transformCapabilities(capabilityProvider
+                .getCapabilities()), baseCapabilities), sessionId);
     }
 
     public static Set<String> transformCapabilities(final Capabilities capabilities) {
index 1f83e1559e8b7ae255fb24caa84698855e7fe646..a46ed9a4bf373870118a50228f87630a22ebce46 100644 (file)
@@ -35,7 +35,8 @@ public class NetconfServerSessionNegotiatorFactoryBuilder {
         return this;
     }
 
-    public NetconfServerSessionNegotiatorFactoryBuilder setAggregatedOpService(final NetconfOperationServiceFactory aggregatedOpService) {
+    public NetconfServerSessionNegotiatorFactoryBuilder setAggregatedOpService(
+            final NetconfOperationServiceFactory aggregatedOpService) {
         this.aggregatedOpService = aggregatedOpService;
         return this;
     }
@@ -45,7 +46,8 @@ public class NetconfServerSessionNegotiatorFactoryBuilder {
         return this;
     }
 
-    public NetconfServerSessionNegotiatorFactoryBuilder setMonitoringService(final NetconfMonitoringService monitoringService) {
+    public NetconfServerSessionNegotiatorFactoryBuilder setMonitoringService(
+            final NetconfMonitoringService monitoringService) {
         this.monitoringService = monitoringService;
         return this;
     }
@@ -58,7 +60,8 @@ public class NetconfServerSessionNegotiatorFactoryBuilder {
 
     public NetconfServerSessionNegotiatorFactory build() {
         validate();
-        return new NetconfServerSessionNegotiatorFactory(timer, aggregatedOpService, idProvider, connectionTimeoutMillis, monitoringService, baseCapabilities);
+        return new NetconfServerSessionNegotiatorFactory(timer, aggregatedOpService, idProvider,
+                connectionTimeoutMillis, monitoringService, baseCapabilities);
     }
 
 
@@ -69,6 +72,7 @@ public class NetconfServerSessionNegotiatorFactoryBuilder {
         Preconditions.checkArgument(connectionTimeoutMillis > 0, "connection time out <=0");
         Preconditions.checkNotNull(monitoringService, "NetconfMonitoringService not initialized");
 
-        baseCapabilities = (baseCapabilities == null) ? NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES : baseCapabilities;
+        baseCapabilities = (baseCapabilities == null) ? NetconfServerSessionNegotiatorFactory
+                .DEFAULT_BASE_CAPABILITIES : baseCapabilities;
     }
 }
index 78cc99d94368bdeb045c3a7d30b81b97f8be2765..d98f07b069560c3eb4e1394e0d13613f268c9af8 100644 (file)
@@ -43,8 +43,9 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation imple
     /**
      * Close netconf operation router associated to this session, which in turn
      * closes NetconfOperationServiceSnapshot with all NetconfOperationService
-     * instances
+     * instances.
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
             throws DocumentedException {
@@ -63,7 +64,7 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation imple
     }
 
     @Override
-    public void setNetconfSession(final NetconfServerSession s) {
-        this.session = s;
+    public void setNetconfSession(final NetconfServerSession netconfServerSession) {
+        this.session = netconfServerSession;
     }
 }
index c0988fd05fc8343d2cadd087087f9a0419684d60..56b2c11e59f93be439c120086a513c173f2494a3 100644 (file)
@@ -10,5 +10,5 @@ package org.opendaylight.netconf.impl.mapping.operations;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 
 public interface DefaultNetconfOperation {
-    void setNetconfSession(NetconfServerSession s);
+    void setNetconfSession(NetconfServerSession netconfServerSession);
 }
index c204dad8f24e33b4788d67bf1523effc53efe816..db75e6e0f53e18b21fc19024026d5e78ec337e2f 100644 (file)
@@ -51,8 +51,10 @@ public class DefaultStartExi extends AbstractSingletonNetconfOperation implement
     }
 
     @Override
-    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws DocumentedException {
-        final Element getSchemaResult = document.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+    protected Element handleWithNoSubsequentOperations(final Document document,
+                                                       final XmlElement operationElement) throws DocumentedException {
+        final Element getSchemaResult = document.createElementNS(
+                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
         LOG.trace("{} operation successful", START_EXI);
         return getSchemaResult;
     }
@@ -68,7 +70,7 @@ public class DefaultStartExi extends AbstractSingletonNetconfOperation implement
     }
 
     @Override
-    public void setNetconfSession(final NetconfServerSession s) {
-        netconfSession = s;
+    public void setNetconfSession(final NetconfServerSession netconfServerSession) {
+        netconfSession = netconfServerSession;
     }
 }
index 8f298f836767dfd39d6927ecb10cd4f7659f5706..600f63743d07cd41413d7af727da53bd2ebe9abe 100644 (file)
@@ -31,12 +31,14 @@ public class DefaultStopExi extends AbstractSingletonNetconfOperation implements
     }
 
     @Override
-    protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws DocumentedException {
+    protected Element handleWithNoSubsequentOperations(Document document,
+                                                       XmlElement operationElement) throws DocumentedException {
         LOG.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
 
         netconfSession.stopExiCommunication();
 
-        Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+        Element getSchemaResult = document.createElementNS(
+                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
         LOG.trace("{} operation successful", STOP_EXI);
         return getSchemaResult;
     }
@@ -52,7 +54,7 @@ public class DefaultStopExi extends AbstractSingletonNetconfOperation implements
     }
 
     @Override
-    public void setNetconfSession(NetconfServerSession s) {
-        this.netconfSession = s;
+    public void setNetconfSession(NetconfServerSession netconfServerSession) {
+        this.netconfSession = netconfServerSession;
     }
 }
index 140a5d06362d2e901bfff190e44ac060989fc84c..5c292b1f6e5b9f70a7cca773554166c845db1339 100644 (file)
@@ -33,12 +33,14 @@ import org.slf4j.LoggerFactory;
 /**
  * NetconfOperationService aggregator. Makes a collection of operation services accessible as one.
  */
-public class AggregatedNetconfOperationServiceFactory implements NetconfOperationServiceFactory, NetconfOperationServiceFactoryListener, AutoCloseable {
+public class AggregatedNetconfOperationServiceFactory
+        implements NetconfOperationServiceFactory, NetconfOperationServiceFactoryListener, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(AggregatedNetconfOperationServiceFactory.class);
 
     private final Set<NetconfOperationServiceFactory> factories = new ConcurrentSet<>();
-    private final Multimap<NetconfOperationServiceFactory, AutoCloseable> registrations = Multimaps.synchronizedMultimap(HashMultimap.create());
+    private final Multimap<NetconfOperationServiceFactory, AutoCloseable> registrations =
+            Multimaps.synchronizedMultimap(HashMultimap.create());
     private final Set<CapabilityListener> listeners = new ConcurrentSet<>();
 
     public AggregatedNetconfOperationServiceFactory() {
@@ -58,6 +60,7 @@ public class AggregatedNetconfOperationServiceFactory implements NetconfOperatio
         }
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public synchronized void onRemoveNetconfOperationServiceFactory(NetconfOperationServiceFactory service) {
         factories.remove(service);
@@ -125,7 +128,8 @@ public class AggregatedNetconfOperationServiceFactory implements NetconfOperatio
 
         private final Set<NetconfOperationService> services;
 
-        public AggregatedNetconfOperation(final Set<NetconfOperationServiceFactory> factories, final String netconfSessionIdForReporting) {
+        AggregatedNetconfOperation(final Set<NetconfOperationServiceFactory> factories,
+                                   final String netconfSessionIdForReporting) {
             final Builder<NetconfOperationService> b = ImmutableSet.builder();
             for (final NetconfOperationServiceFactory factory : factories) {
                 b.add(factory.createService(netconfSessionIdForReporting));
@@ -142,6 +146,7 @@ public class AggregatedNetconfOperationServiceFactory implements NetconfOperatio
             return operations;
         }
 
+        @SuppressWarnings("checkstyle:IllegalCatch")
         @Override
         public void close() {
             try {
index c31531d052fee92b71120122046c749e209a20dc..489d984a52ae37f28b292dd7e08bea5f8413f24b 100644 (file)
@@ -47,7 +47,8 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
 
     private static final Schema.Location NETCONF_LOCATION = new Schema.Location(Schema.Location.Enumeration.NETCONF);
     private static final List<Schema.Location> NETCONF_LOCATIONS = ImmutableList.of(NETCONF_LOCATION);
-    private static final BasicCapability CANDIDATE_CAPABILITY = new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0");
+    private static final BasicCapability CANDIDATE_CAPABILITY =
+            new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0");
     private static final Function<Capability, Uri> CAPABILITY_TO_URI = new Function<Capability, Uri>() {
         @Override
         public Uri apply(final Capability input) {
@@ -68,6 +69,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         netconfOperationProvider.registerCapabilityListener(this);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     synchronized Schemas getSchemas() {
         try {
             return transformSchemas(netconfOperationProvider.getCapabilities());
@@ -81,8 +83,9 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
     synchronized String getSchemaForModuleRevision(final String moduleName, final Optional<String> revision) {
 
         Map<String, String> revisionMapRequest = mappedModulesToRevisionToSchema.get(moduleName);
-        Preconditions.checkState(revisionMapRequest != null, "Capability for module %s not present, " + ""
-                + "available modules : %s", moduleName, Collections2.transform(capabilities.values(), CAPABILITY_TO_URI));
+        Preconditions.checkState(revisionMapRequest != null,
+                "Capability for module %s not present, available modules : %s",
+                moduleName, Collections2.transform(capabilities.values(), CAPABILITY_TO_URI));
 
         if (revision.isPresent()) {
             String schema = revisionMapRequest.get(revision.get());
@@ -103,7 +106,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
 
     private void updateCapabilityToSchemaMap(final Set<Capability> added, final Set<Capability> removed) {
         for (final Capability cap : added) {
-            if (!isValidModuleCapability(cap)){
+            if (!isValidModuleCapability(cap)) {
                 continue;
             }
 
@@ -118,7 +121,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
             revisionMap.put(currentRevision, cap.getCapabilitySchema().get());
         }
         for (final Capability cap : removed) {
-            if (!isValidModuleCapability(cap)){
+            if (!isValidModuleCapability(cap)) {
                 continue;
             }
             final Map<String, String> revisionMap = mappedModulesToRevisionToSchema.get(cap.getModuleName().get());
@@ -238,9 +241,13 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
 
     private static NetconfCapabilityChange computeDiff(final Set<Capability> added, final Set<Capability> removed) {
         final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
-        netconfCapabilityChangeBuilder.setChangedBy(new ChangedByBuilder().setServerOrUser(new ServerBuilder().setServer(true).build()).build());
-        netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(Collections2.transform(removed, CAPABILITY_TO_URI)));
-        netconfCapabilityChangeBuilder.setAddedCapability(Lists.newArrayList(Collections2.transform(added, CAPABILITY_TO_URI)));
+        netconfCapabilityChangeBuilder
+                .setChangedBy(new ChangedByBuilder().setServerOrUser(new ServerBuilder().setServer(true).build())
+                        .build());
+        netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(Collections2
+                .transform(removed, CAPABILITY_TO_URI)));
+        netconfCapabilityChangeBuilder.setAddedCapability(Lists.newArrayList(Collections2
+                .transform(added, CAPABILITY_TO_URI)));
         // TODO modified should be computed ... but why ?
         netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
         return netconfCapabilityChangeBuilder.build();
index 0ae2b92e0620faf5f0f05ba26eaa17e3a278b197..df45459e1efc75c0c85d84da711b1c47dd252a2f 100644 (file)
@@ -44,6 +44,7 @@ public class NetconfImplActivator implements BundleActivator {
 
     private BaseNotificationPublisherRegistration listenerReg;
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public void start(final BundleContext context) {
         try {
@@ -57,58 +58,68 @@ public class NetconfImplActivator implements BundleActivator {
 
             final NetconfMonitoringServiceImpl monitoringService = startMonitoringService(context, factoriesListener);
 
-            NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder()
-                    .setAggregatedOpService(factoriesListener)
-                    .setTimer(timer)
-                    .setIdProvider(idProvider)
-                    .setMonitoringService(monitoringService)
-                    .setConnectionTimeoutMillis(connectionTimeoutMillis)
-                    .build();
+            NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
+                    new NetconfServerSessionNegotiatorFactoryBuilder()
+                            .setAggregatedOpService(factoriesListener)
+                            .setTimer(timer)
+                            .setIdProvider(idProvider)
+                            .setMonitoringService(monitoringService)
+                            .setConnectionTimeoutMillis(connectionTimeoutMillis)
+                            .build();
 
             eventLoopGroup = new NioEventLoopGroup();
 
             ServerChannelInitializer serverChannelInitializer = new ServerChannelInitializer(
                     serverNegotiatorFactory);
-            NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer, eventLoopGroup, eventLoopGroup);
+            NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer,
+                    eventLoopGroup, eventLoopGroup);
 
             LocalAddress address = NetconfConfiguration.NETCONF_LOCAL_ADDRESS;
             LOG.trace("Starting local netconf server at {}", address);
             dispatch.createLocalServer(address);
 
-            final ServiceTracker<NetconfNotificationCollector, NetconfNotificationCollector> notificationServiceTracker =
-                    new ServiceTracker<>(context, NetconfNotificationCollector.class, new ServiceTrackerCustomizer<NetconfNotificationCollector, NetconfNotificationCollector>() {
-                        @Override
-                        public NetconfNotificationCollector addingService(ServiceReference<NetconfNotificationCollector> reference) {
-                            Preconditions.checkState(listenerReg == null, "Notification collector service was already added");
-                            listenerReg = context.getService(reference).registerBaseNotificationPublisher();
-                            monitoringService.setNotificationPublisher(listenerReg);
-                            return null;
-                        }
-
-                        @Override
-                        public void modifiedService(ServiceReference<NetconfNotificationCollector> reference, NetconfNotificationCollector service) {
-
-                        }
-
-                        @Override
-                        public void removedService(ServiceReference<NetconfNotificationCollector> reference, NetconfNotificationCollector service) {
-                            listenerReg.close();
-                            listenerReg = null;
-                            monitoringService.setNotificationPublisher(listenerReg);
-                        }
-                    });
+            final ServiceTracker<NetconfNotificationCollector, NetconfNotificationCollector>
+                    notificationServiceTracker = new ServiceTracker<>(context, NetconfNotificationCollector.class,
+                    new ServiceTrackerCustomizer<NetconfNotificationCollector, NetconfNotificationCollector>() {
+                            @Override
+                            public NetconfNotificationCollector addingService(ServiceReference<
+                                    NetconfNotificationCollector> reference) {
+                                Preconditions.checkState(listenerReg == null,
+                                        "Notification collector service was already added");
+                                listenerReg = context.getService(reference).registerBaseNotificationPublisher();
+                                monitoringService.setNotificationPublisher(listenerReg);
+                                return null;
+                            }
+
+                            @Override
+                            public void modifiedService(ServiceReference<NetconfNotificationCollector> reference,
+                                            NetconfNotificationCollector service) {
+
+                                }
+
+                            @Override
+                            public void removedService(ServiceReference<NetconfNotificationCollector> reference,
+                                           NetconfNotificationCollector service) {
+                                listenerReg.close();
+                                listenerReg = null;
+                                monitoringService.setNotificationPublisher(listenerReg);
+                            }
+                        });
             notificationServiceTracker.open();
         } catch (Exception e) {
             LOG.warn("Unable to start NetconfImplActivator", e);
         }
     }
 
-    private void startOperationServiceFactoryTracker(BundleContext context, NetconfOperationServiceFactoryListener factoriesListener) {
+    private void startOperationServiceFactoryTracker(BundleContext context,
+                                                     NetconfOperationServiceFactoryListener factoriesListener) {
         factoriesTracker = new NetconfOperationServiceFactoryTracker(context, factoriesListener);
         factoriesTracker.open();
     }
 
-    private NetconfMonitoringServiceImpl startMonitoringService(BundleContext context, AggregatedNetconfOperationServiceFactory factoriesListener) {
+    private NetconfMonitoringServiceImpl startMonitoringService(
+            BundleContext context,
+            AggregatedNetconfOperationServiceFactory factoriesListener) {
         NetconfMonitoringServiceImpl netconfMonitoringServiceImpl = new NetconfMonitoringServiceImpl(factoriesListener);
         Dictionary<String, ?> dic = new Hashtable<>();
         regMonitoring = context.registerService(NetconfMonitoringService.class, netconfMonitoringServiceImpl, dic);
index 1e118129242522058a5deedef766136ae0d216ae..b7db507ca577133acf9be0b6728ca0e962a9c61e 100644 (file)
@@ -53,8 +53,10 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         allNetconfOperations = ImmutableSet.copyOf(ops);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
-    public Document onNetconfMessage(final Document message, final NetconfServerSession session) throws DocumentedException {
+    public Document onNetconfMessage(final Document message, final NetconfServerSession session) throws
+            DocumentedException {
         Preconditions.checkNotNull(allNetconfOperations, "Operation router was not initialized properly");
 
         final NetconfOperationExecution netconfOperationExecution;
@@ -72,10 +74,10 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
             }
 
             throw new DocumentedException(
-                String.format("Unable to handle rpc %s on session %s", messageAsString, session),
+                    String.format("Unable to handle rpc %s on session %s", messageAsString, session),
                     e, DocumentedException.ErrorType.APPLICATION,
                     tag, DocumentedException.ErrorSeverity.ERROR,
-                Collections.singletonMap(tag.toString(), e.getMessage()));
+                    Collections.singletonMap(tag.toString(), e.getMessage()));
         } catch (final RuntimeException e) {
             throw handleUnexpectedEx("Unexpected exception during netconf operation sort", e);
         }
@@ -92,20 +94,22 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         netconfOperationServiceSnapshot.close();
     }
 
-    private static DocumentedException handleUnexpectedEx(final String s, final Exception e) throws DocumentedException {
-        LOG.error("{}", s, e);
+    private static DocumentedException handleUnexpectedEx(final String message, final Exception exception) throws
+            DocumentedException {
+        LOG.error("{}", message, exception);
         return new DocumentedException("Unexpected error",
                 DocumentedException.ErrorType.APPLICATION,
                 DocumentedException.ErrorTag.OPERATION_FAILED,
                 DocumentedException.ErrorSeverity.ERROR,
-                Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), e.toString()));
+                Collections.singletonMap(DocumentedException.ErrorSeverity.ERROR.toString(), exception.toString()));
     }
 
     private Document executeOperationWithHighestPriority(final Document message,
-            final NetconfOperationExecution netconfOperationExecution)
+                                                         final NetconfOperationExecution netconfOperationExecution)
             throws DocumentedException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Forwarding netconf message {} to {}", XmlUtil.toString(message), netconfOperationExecution.netconfOperation);
+            LOG.debug("Forwarding netconf message {} to {}", XmlUtil.toString(message), netconfOperationExecution
+                    .netconfOperation);
         }
 
         return netconfOperationExecution.execute(message);
@@ -114,19 +118,20 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
     private NetconfOperationExecution getNetconfOperationWithHighestPriority(
             final Document message, final NetconfServerSession session) throws DocumentedException {
 
-        final NavigableMap<HandlingPriority, NetconfOperation> sortedByPriority = getSortedNetconfOperationsWithCanHandle(
+        final NavigableMap<HandlingPriority, NetconfOperation> sortedByPriority =
+                getSortedNetconfOperationsWithCanHandle(
                 message, session);
 
         if (sortedByPriority.isEmpty()) {
             throw new IllegalArgumentException(String.format("No %s available to handle message %s",
-                NetconfOperation.class.getName(), XmlUtil.toString(message)));
+                    NetconfOperation.class.getName(), XmlUtil.toString(message)));
         }
 
         return NetconfOperationExecution.createExecutionChain(sortedByPriority, sortedByPriority.lastKey());
     }
 
-    private TreeMap<HandlingPriority, NetconfOperation> getSortedNetconfOperationsWithCanHandle(final Document message,
-            final NetconfServerSession session) throws DocumentedException {
+    private TreeMap<HandlingPriority, NetconfOperation> getSortedNetconfOperationsWithCanHandle(
+            final Document message, final NetconfServerSession session) throws DocumentedException {
         final TreeMap<HandlingPriority, NetconfOperation> sortedPriority = Maps.newTreeMap();
 
         for (final NetconfOperation netconfOperation : allNetconfOperations) {
@@ -134,14 +139,15 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
             if (netconfOperation instanceof DefaultNetconfOperation) {
                 ((DefaultNetconfOperation) netconfOperation).setNetconfSession(session);
             }
-            if(netconfOperation instanceof SessionAwareNetconfOperation) {
+            if (netconfOperation instanceof SessionAwareNetconfOperation) {
                 ((SessionAwareNetconfOperation) netconfOperation).setSession(session);
             }
             if (!handlingPriority.equals(HandlingPriority.CANNOT_HANDLE)) {
 
                 Preconditions.checkState(!sortedPriority.containsKey(handlingPriority),
                         "Multiple %s available to handle message %s with priority %s, %s and %s",
-                        NetconfOperation.class.getName(), message, handlingPriority, netconfOperation, sortedPriority.get(handlingPriority));
+                        NetconfOperation.class.getName(), message, handlingPriority, netconfOperation, sortedPriority
+                                .get(handlingPriority));
                 sortedPriority.put(handlingPriority, netconfOperation);
             }
         }
@@ -152,7 +158,8 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         private final NetconfOperation netconfOperation;
         private final NetconfOperationChainedExecution subsequentExecution;
 
-        private NetconfOperationExecution(final NetconfOperation netconfOperation, final NetconfOperationChainedExecution subsequentExecution) {
+        private NetconfOperationExecution(final NetconfOperation netconfOperation,
+                                          final NetconfOperationChainedExecution subsequentExecution) {
             this.netconfOperation = netconfOperation;
             this.subsequentExecution = subsequentExecution;
         }
@@ -168,7 +175,8 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         }
 
         public static NetconfOperationExecution createExecutionChain(
-                final NavigableMap<HandlingPriority, NetconfOperation> sortedByPriority, final HandlingPriority handlingPriority) {
+                final NavigableMap<HandlingPriority, NetconfOperation> sortedByPriority,
+                final HandlingPriority handlingPriority) {
             final NetconfOperation netconfOperation = sortedByPriority.get(handlingPriority);
             final HandlingPriority subsequentHandlingPriority = sortedByPriority.lowerKey(handlingPriority);
 
index 33408e2d8ca65a49da60e74c93eae92b65f3ca71..b1a084424c67ba9192a9607255787cd04f0a0343 100644 (file)
@@ -19,7 +19,7 @@ class NetconfOperationServiceFactoryTracker extends
     private final NetconfOperationServiceFactoryListener factoriesListener;
 
     NetconfOperationServiceFactoryTracker(BundleContext context,
-            final NetconfOperationServiceFactoryListener factoriesListener) {
+                                          final NetconfOperationServiceFactoryListener factoriesListener) {
         super(context, NetconfOperationServiceFactory.class, null);
         this.factoriesListener = factoriesListener;
     }
@@ -38,7 +38,7 @@ class NetconfOperationServiceFactoryTracker extends
 
     @Override
     public void removedService(ServiceReference<NetconfOperationServiceFactory> reference,
-            NetconfOperationServiceFactory netconfOperationServiceFactory) {
+                               NetconfOperationServiceFactory netconfOperationServiceFactory) {
         if (netconfOperationServiceFactory != null) {
             factoriesListener.onRemoveNetconfOperationServiceFactory(netconfOperationServiceFactory);
         }
index 68883fde680b80546bd8fa1a3a2fdaa02e995158..72697ffebf1b69fc076b8ac6ca732afe61d5939b 100644 (file)
@@ -30,7 +30,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This class implements {@link SessionListener} to receive updates about Netconf sessions. Instance notifies its listeners
+ * This class implements {@link SessionListener} to receive updates about Netconf sessions. Instance notifies its
+ * listeners
  * about session start and end. It also publishes on regular interval list of sessions,
  * where events like rpc or notification happened.
  */
@@ -46,23 +47,28 @@ class NetconfSessionMonitoringService implements SessionListener, AutoCloseable
     private boolean running;
 
     /**
-     * @param schedulingThreadPool thread pool for scheduling session stats updates. If not present, updates won't be scheduled.
-     * @param updateInterval update interval. If is less than 0, updates won't be scheduled
+     * Constructor for {@code NetconfSessionMonitoringService}.
+     *
+     * @param schedulingThreadPool thread pool for scheduling session stats updates. If not present, updates won't be
+     *                             scheduled.
+     * @param updateInterval       update interval. If is less than 0, updates won't be scheduled
      */
     NetconfSessionMonitoringService(Optional<ScheduledThreadPool> schedulingThreadPool, long updateInterval) {
         this.updateInterval = updateInterval;
         if (schedulingThreadPool.isPresent() && updateInterval > 0) {
-            this.executor =  schedulingThreadPool.get().getExecutor();
+            this.executor = schedulingThreadPool.get().getExecutor();
             LOG.info("/netconf-state/sessions will be updated every {} seconds.", updateInterval);
         } else {
-            LOG.info("Scheduling thread pool is present = {}, update interval {}: /netconf-state/sessions won't be updated.",
+            LOG.info("Scheduling thread pool is present = {}, "
+                    + "update interval {}: /netconf-state/sessions won't be updated.",
                     schedulingThreadPool.isPresent(), updateInterval);
             this.executor = null;
         }
     }
 
     synchronized Sessions getSessions() {
-        final Collection<Session> managementSessions = Collections2.transform(sessions, NetconfManagementSession::toManagementSession);
+        final Collection<Session> managementSessions = Collections2.transform(sessions,
+                NetconfManagementSession::toManagementSession);
         return new SessionsBuilder().setSession(ImmutableList.copyOf(managementSessions)).build();
     }
 
index 91d16d06a4eb46ecf6764de34adbc059754679c2..3edd91d3ae57ad909eb55cf1b3c121ce2e8149ce 100644 (file)
@@ -16,8 +16,8 @@ public class AdditionalHeaderParserTest {
 
     @Test
     public void testParsing() throws Exception {
-        String s = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
-        NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
+        String message = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
+        NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(message);
         assertEquals("netconf", header.getUserName());
         assertEquals("10.12.0.102", header.getAddress());
         assertEquals("ssh", header.getTransport());
@@ -25,8 +25,8 @@ public class AdditionalHeaderParserTest {
 
     @Test
     public void testParsing2() throws Exception {
-        String s = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
-        NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
+        String message = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
+        NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(message);
         assertEquals("tomas", header.getUserName());
         assertEquals("10.0.0.0", header.getAddress());
         assertEquals("tcp", header.getTransport());
@@ -34,7 +34,7 @@ public class AdditionalHeaderParserTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testParsingNoUsername() throws Exception {
-        String s = "[10.12.0.102:48528;ssh;;;;;;]";
-        NetconfHelloMessageAdditionalHeader.fromString(s);
+        String message = "[10.12.0.102:48528;ssh;;;;;;]";
+        NetconfHelloMessageAdditionalHeader.fromString(message);
     }
 }
index 8f35f199cbd9ef624aeb3527d575ef2a333acc1e..c49b3ad9783a92af545b16843500360b12c290a5 100644 (file)
@@ -86,7 +86,7 @@ public class ConcurrentClientsTest {
     private static ExecutorService clientExecutor;
 
     private static final int CONCURRENCY = 32;
-    private static final InetSocketAddress netconfAddress = new InetSocketAddress("127.0.0.1", 8303);
+    private static final InetSocketAddress NETCONF_ADDRESS = new InetSocketAddress("127.0.0.1", 8303);
 
     private int nettyThreads;
     private Class<? extends Runnable> clientRunnable;
@@ -100,14 +100,15 @@ public class ConcurrentClientsTest {
 
     @Parameterized.Parameters()
     public static Collection<Object[]> data() {
-        return Arrays.asList(new Object[][]{{4, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
-                                            {1, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
-                                            // empty set of capabilities = only base 1.0 netconf capability
-                                            {4, TestingNetconfClientRunnable.class, Collections.emptySet()},
-                                            {4, TestingNetconfClientRunnable.class, getOnlyExiServerCaps()},
-                                            {4, TestingNetconfClientRunnable.class, getOnlyChunkServerCaps()},
-                                            {4, BlockingClientRunnable.class, getOnlyExiServerCaps()},
-                                            {1, BlockingClientRunnable.class, getOnlyExiServerCaps()},
+        return Arrays.asList(new Object[][]{{4, TestingNetconfClientRunnable.class,
+                NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
+            {1, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
+            // empty set of capabilities = only base 1.0 netconf capability
+            {4, TestingNetconfClientRunnable.class, Collections.emptySet()},
+            {4, TestingNetconfClientRunnable.class, getOnlyExiServerCaps()},
+            {4, TestingNetconfClientRunnable.class, getOnlyChunkServerCaps()},
+            {4, BlockingClientRunnable.class, getOnlyExiServerCaps()},
+            {1, BlockingClientRunnable.class, getOnlyExiServerCaps()},
         });
     }
 
@@ -130,19 +131,20 @@ public class ConcurrentClientsTest {
             }
         }).when(monitoring).registerCapabilitiesListener(any(NetconfMonitoringService.CapabilitiesListener.class));
         doReturn(sessionListener).when(monitoring).getSessionListener();
-        doReturn(new CapabilitiesBuilder().setCapability(Collections.<Uri>emptyList()).build()).when(monitoring).getCapabilities();
+        doReturn(new CapabilitiesBuilder().setCapability(Collections.<Uri>emptyList()).build()).when(monitoring)
+                .getCapabilities();
         return monitoring;
     }
 
     @BeforeClass
     public static void setUpClientExecutor() {
         clientExecutor = Executors.newFixedThreadPool(CONCURRENCY, new ThreadFactory() {
-            int i = 1;
+            int index = 1;
 
             @Override
-            public Thread newThread(final Runnable r) {
-                Thread thread = new Thread(r);
-                thread.setName("client-" + i++);
+            public Thread newThread(final Runnable runnable) {
+                Thread thread = new Thread(runnable);
+                thread.setName("client-" + index++);
                 thread.setDaemon(true);
                 return thread;
             }
@@ -158,11 +160,13 @@ public class ConcurrentClientsTest {
         AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
 
         testingNetconfOperation = new TestingNetconfOperation();
-        factoriesListener.onAddNetconfOperationServiceFactory(new TestingOperationServiceFactory(testingNetconfOperation));
+        factoriesListener.onAddNetconfOperationServiceFactory(
+                new TestingOperationServiceFactory(testingNetconfOperation));
 
         SessionIdProvider idProvider = new SessionIdProvider();
 
-        NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder()
+        NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new
+                NetconfServerSessionNegotiatorFactoryBuilder()
                 .setTimer(hashedWheelTimer)
                 .setAggregatedOpService(factoriesListener)
                 .setIdProvider(idProvider)
@@ -171,15 +175,17 @@ public class ConcurrentClientsTest {
                 .setBaseCapabilities(serverCaps)
                 .build();
 
-        NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
-        final NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer, nettyGroup, nettyGroup);
+        NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer =
+                new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
+        final NetconfServerDispatcherImpl dispatch =
+                new NetconfServerDispatcherImpl(serverChannelInitializer, nettyGroup, nettyGroup);
 
-        ChannelFuture s = dispatch.createServer(netconfAddress);
-        s.await();
+        ChannelFuture server = dispatch.createServer(NETCONF_ADDRESS);
+        server.await();
     }
 
     @After
-    public void tearDown(){
+    public void tearDown() {
         hashedWheelTimer.stop();
         try {
             nettyGroup.shutdownGracefully().get();
@@ -235,7 +241,7 @@ public class ConcurrentClientsTest {
     }
 
     /**
-     * Responds to all operations except start-exi and counts all requests
+     * Responds to all operations except start-exi and counts all requests.
      */
     private static class TestingNetconfOperation implements NetconfOperation {
 
@@ -243,13 +249,15 @@ public class ConcurrentClientsTest {
 
         @Override
         public HandlingPriority canHandle(Document message) {
-            return XmlUtil.toString(message).contains(NetconfStartExiMessage.START_EXI) ?
-                    HandlingPriority.CANNOT_HANDLE :
+            return XmlUtil.toString(message).contains(NetconfStartExiMessage.START_EXI)
+                    HandlingPriority.CANNOT_HANDLE :
                     HandlingPriority.HANDLE_WITH_MAX_PRIORITY;
         }
 
+        @SuppressWarnings("checkstyle:IllegalCatch")
         @Override
-        public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
+        public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation)
+                throws DocumentedException {
             try {
                 LOG.info("Handling netconf message from test {}", XmlUtil.toString(requestMessage));
                 counter.getAndIncrement();
@@ -265,12 +273,12 @@ public class ConcurrentClientsTest {
     }
 
     /**
-     * Hardcoded operation service factory
+     * Hardcoded operation service factory.
      */
     private static class TestingOperationServiceFactory implements NetconfOperationServiceFactory {
         private final NetconfOperation[] operations;
 
-        public TestingOperationServiceFactory(final NetconfOperation... operations) {
+        TestingOperationServiceFactory(final NetconfOperation... operations) {
             this.operations = operations;
         }
 
@@ -281,9 +289,10 @@ public class ConcurrentClientsTest {
 
         @Override
         public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-            return new AutoCloseable(){
+            return new AutoCloseable() {
                 @Override
-                public void close() throws Exception {}
+                public void close() throws Exception {
+                }
             };
         }
 
@@ -297,14 +306,16 @@ public class ConcurrentClientsTest {
                 }
 
                 @Override
-                public void close() {}
+                public void close() {
+                }
             };
         }
     }
 
     /**
-     * Pure socket based blocking client
+     * Pure socket based blocking client.
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public final class BlockingClientRunnable implements Runnable {
 
         @Override
@@ -319,9 +330,10 @@ public class ConcurrentClientsTest {
         private void run2() throws Exception {
             InputStream clientHello = checkNotNull(XmlFileLoader
                     .getResourceAsStream("netconfMessages/client_hello.xml"));
-            InputStream getConfig = checkNotNull(XmlFileLoader.getResourceAsStream("netconfMessages/getConfig.xml"));
+            final InputStream getConfig =
+                    checkNotNull(XmlFileLoader.getResourceAsStream("netconfMessages/getConfig.xml"));
 
-            Socket clientSocket = new Socket(netconfAddress.getHostString(), netconfAddress.getPort());
+            Socket clientSocket = new Socket(NETCONF_ADDRESS.getHostString(), NETCONF_ADDRESS.getPort());
             DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
             InputStreamReader inFromServer = new InputStreamReader(clientSocket.getInputStream());
 
@@ -349,15 +361,17 @@ public class ConcurrentClientsTest {
     }
 
     /**
-     * TestingNetconfClient based runnable
+     * TestingNetconfClient based runnable.
      */
     public final class TestingNetconfClientRunnable implements Runnable {
 
+        @SuppressWarnings("checkstyle:IllegalCatch")
         @Override
         public void run() {
             try {
                 final TestingNetconfClient netconfClient =
-                        new TestingNetconfClient(Thread.currentThread().getName(), netconfClientDispatcher, getClientConfig());
+                        new TestingNetconfClient(Thread.currentThread().getName(), netconfClientDispatcher,
+                                getClientConfig());
                 long sessionId = netconfClient.getSessionId();
                 LOG.info("Client with session id {}: hello exchanged", sessionId);
 
@@ -379,7 +393,7 @@ public class ConcurrentClientsTest {
 
         private NetconfClientConfiguration getClientConfig() {
             final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
-            b.withAddress(netconfAddress);
+            b.withAddress(NETCONF_ADDRESS);
             b.withAdditionalHeader(new NetconfHelloMessageAdditionalHeader("uname", "10.10.10.1", "830", "tcp",
                     "client"));
             b.withSessionListener(new SimpleNetconfClientSessionListener());
index 31806f73e52cb215897ea59f0f2075fb46381fc6..2fe0d5173cacce09349663f0505bd28b4edb38cd 100644 (file)
@@ -13,9 +13,9 @@ import org.junit.Test;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
 
-public class ExiEncodeDecodeTest  {
+public class ExiEncodeDecodeTest {
     @Test
-    public void encodeExi() throws Exception{
+    public void encodeExi() throws Exception {
 
         String startExiString = XmlFileLoader.xmlFileToString("netconfMessages/startExi.xml");
         assertNotNull(startExiString);
@@ -25,7 +25,8 @@ public class ExiEncodeDecodeTest  {
 
         /*
         ExiParameters exiParams = new ExiParameters();
-        exiParams.setParametersFromXmlElement(XmlElement.fromDomElement(startExiMessage.getDocument().getDocumentElement()));
+        exiParams.setParametersFromXmlElement(XmlElement.fromDomElement(startExiMessage.getDocument()
+        .getDocumentElement()));
         assertNotNull(exiParams);
 
         ByteBuf encodedBuf = Unpooled.buffer();
index 46a5695670da3676ac8434ea53bb428f6361f71d..10ef3cd59752704e51aeda6f331acdf4e1637ebf 100644 (file)
@@ -71,8 +71,8 @@ public class MessageParserTest {
             if (i == chunkCount) {
                 exptHeaderLength = msgLength - (ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE * (i - 1));
                 byte[] eom = new byte[NetconfMessageConstants.END_OF_CHUNK.length];
-                recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_CHUNK.length,
-                        eom);
+                recievedOutbound
+                        .getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_CHUNK.length, eom);
                 assertArrayEquals(NetconfMessageConstants.END_OF_CHUNK, eom);
             }
 
@@ -100,7 +100,8 @@ public class MessageParserTest {
         ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound();
 
         byte[] eom = new byte[NetconfMessageConstants.END_OF_MESSAGE.length];
-        recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_MESSAGE.length, eom);
+        recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_MESSAGE.length,
+                eom);
         assertArrayEquals(NetconfMessageConstants.END_OF_MESSAGE, eom);
 
         testChunkChannel.writeInbound(recievedOutbound);
@@ -110,8 +111,8 @@ public class MessageParserTest {
     }
 
     private static long getHeaderLength(byte[] bytes) {
-        byte[] HEADER_START = new byte[] { (byte) 0x0a, (byte) 0x23 };
+        byte[] headerStart = new byte[]{(byte) 0x0a, (byte) 0x23};
         return Long.parseLong(StandardCharsets.US_ASCII.decode(
-                ByteBuffer.wrap(bytes, HEADER_START.length, bytes.length - HEADER_START.length - 1)).toString());
+                ByteBuffer.wrap(bytes, headerStart.length, bytes.length - headerStart.length - 1)).toString());
     }
 }
index ba38938917fcdf2f8ff00c39810ff5305c917202..c24aaf8cd51a2b501650c456bcb3ba6162396094 100644 (file)
@@ -34,15 +34,17 @@ public class NetconfDispatcherImplTest {
         SessionIdProvider idProvider = new SessionIdProvider();
         hashedWheelTimer = new HashedWheelTimer();
 
-        NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder()
-                .setAggregatedOpService(factoriesListener)
-                .setTimer(hashedWheelTimer)
-                .setIdProvider(idProvider)
-                .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
-                .setConnectionTimeoutMillis(5000)
-                .build();
+        NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
+                new NetconfServerSessionNegotiatorFactoryBuilder()
+                        .setAggregatedOpService(factoriesListener)
+                        .setTimer(hashedWheelTimer)
+                        .setIdProvider(idProvider)
+                        .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
+                        .setConnectionTimeoutMillis(5000)
+                        .build();
 
-        NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
+        NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer =
+                new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
 
         dispatch = new NetconfServerDispatcherImpl(
                 serverChannelInitializer, nettyGroup, nettyGroup);
@@ -57,7 +59,7 @@ public class NetconfDispatcherImplTest {
     @Test
     public void test() throws Exception {
         InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
-        ChannelFuture s = dispatch.createServer(addr);
-        s.get();
+        ChannelFuture server = dispatch.createServer(addr);
+        server.get();
     }
 }
index 4b435e8f7685bcb3db39d8b8b0715262cd62f5f4..37e17659fc39b3115f6213866184dedaeb4952a6 100644 (file)
@@ -91,11 +91,11 @@ public class NetconfServerSessionListenerTest {
 
     @Test
     public void testOnMessage() throws Exception {
-        final Document reply = XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" " +
-                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc-reply>");
+        final Document reply = XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" "
+                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc-reply>");
         doReturn(reply).when(router).onNetconfMessage(any(), any());
-        final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"101\" " +
-                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc>"));
+        final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"101\" "
+                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc>"));
         listener.onMessage(session, msg);
         verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_SUCCESS)));
         channel.runPendingTasks();
@@ -108,8 +108,8 @@ public class NetconfServerSessionListenerTest {
     public void testOnMessageRuntimeFail() throws Exception {
         doThrow(new RuntimeException("runtime fail")).when(router).onNetconfMessage(any(), any());
         final Document reply =
-                XmlUtil.readXmlToDocument("<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
-                        "<example/></rpc>");
+                XmlUtil.readXmlToDocument("<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
+                        "<example/></rpc>");
         final NetconfMessage msg = new NetconfMessage(reply);
         try {
             listener.onMessage(session, msg);
@@ -119,22 +119,23 @@ public class NetconfServerSessionListenerTest {
         }
     }
 
+    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
     @Test
     public void testOnMessageDocumentedFail() throws Exception {
         final Document reply =
-                XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
-                        "<rpc-error>\n" +
-                        "<error-type>protocol</error-type>\n" +
-                        "<error-tag>unknown-element</error-tag>\n" +
-                        "<error-severity>error</error-severity>\n" +
-                        "<error-message>Unknown tag bad-rpc in message:\n" +
-                        "&lt;bad-rpc/&gt;\n" +
-                        "</error-message>\n" +
-                        "<error-info>\n" +
-                        "<bad-element>bad-rpc</bad-element>\n" +
-                        "</error-info>\n" +
-                        "</rpc-error>\n" +
-                        "</rpc-reply>");
+                XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+                        + "<rpc-error>\n"
+                        + "<error-type>protocol</error-type>\n"
+                        + "<error-tag>unknown-element</error-tag>\n"
+                        + "<error-severity>error</error-severity>\n"
+                        + "<error-message>Unknown tag bad-rpc in message:\n"
+                        + "&lt;bad-rpc/&gt;\n"
+                        + "</error-message>\n"
+                        + "<error-info>\n"
+                        + "<bad-element>bad-rpc</bad-element>\n"
+                        + "</error-info>\n"
+                        + "</rpc-error>\n"
+                        "</rpc-reply>");
         final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<bad-rpc/>"));
         listener.onMessage(session, msg);
         verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_FAIL)));
index d9853b3b9a95d61ace81edeb20cdebd6cca7102c..068ebf6eb4a3a28edb2f9f35254cdd633ec3eb0d 100644 (file)
@@ -57,8 +57,8 @@ public class DefaultCloseSessionTest {
         AutoCloseable res = mock(AutoCloseable.class);
         doNothing().when(res).close();
         DefaultCloseSession close = new DefaultCloseSession("", res);
-        Document doc = XmlUtil.newDocument();
-        XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
+        final Document doc = XmlUtil.newDocument();
+        final XmlElement elem = XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"));
         final Channel channel = mock(Channel.class);
         doReturn("channel").when(channel).toString();
         mockEventLoop(channel);
@@ -77,17 +77,18 @@ public class DefaultCloseSessionTest {
         doReturn(sendFuture).when(channel).writeAndFlush(anyObject());
         doReturn(true).when(sendFuture).isSuccess();
         final NetconfServerSessionListener listener = mock(NetconfServerSessionListener.class);
-        doNothing().when(listener).onSessionTerminated(any(NetconfServerSession.class), any(NetconfTerminationReason.class));
+        doNothing().when(listener).onSessionTerminated(any(NetconfServerSession.class),
+                any(NetconfTerminationReason.class));
         final NetconfServerSession session =
                 new NetconfServerSession(listener, channel, 1L,
                         NetconfHelloMessageAdditionalHeader.fromString("[netconf;10.12.0.102:48528;ssh;;;;;;]"));
         close.setNetconfSession(session);
         close.handleWithNoSubsequentOperations(doc, elem);
         // Fake close response to trigger delayed close
-        session.sendMessage(new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n" +
-                "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
-                "<ok/>\n" +
-                "</rpc-reply>")));
+        session.sendMessage(new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n"
+                + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+                + "<ok/>\n"
+                "</rpc-reply>")));
         verify(channel).close();
         verify(listener).onSessionTerminated(any(NetconfServerSession.class), any(NetconfTerminationReason.class));
     }
index a2662e4b5f806e32dac7ddd54cb4cf33cf6ab4aa..e181cc6227f5334ff264543be6d094fdf67b6e3e 100644 (file)
@@ -28,8 +28,8 @@ import org.w3c.dom.Document;
 public class DefaultStopExiTest {
     @Test
     public void testHandleWithNoSubsequentOperations() throws Exception {
-        DefaultStopExi exi = new DefaultStopExi("");
-        Document doc = XmlUtil.newDocument();
+        final DefaultStopExi exi = new DefaultStopExi("");
+        final Document doc = XmlUtil.newDocument();
         Channel channel = mock(Channel.class);
         doReturn("mockChannel").when(channel).toString();
         ChannelPipeline pipeline = mock(ChannelPipeline.class);
@@ -40,7 +40,8 @@ public class DefaultStopExiTest {
         NetconfServerSession serverSession = new NetconfServerSession(null, channel, 2L, null);
         exi.setNetconfSession(serverSession);
 
-        assertNotNull(exi.handleWithNoSubsequentOperations(doc, XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"))));
+        assertNotNull(exi.handleWithNoSubsequentOperations(doc,
+                XmlElement.fromDomElement(XmlUtil.readXmlToElement("<elem/>"))));
         verify(pipeline, times(1)).replace(anyString(), anyString(), any(ChannelHandler.class));
     }
 }
index f71cac6233cccd62ffbfd7e5d0a7636cdef5138b..7acef9165feb986171294676aadf05884490f1da 100644 (file)
@@ -53,7 +53,7 @@ public class NetconfCapabilityMonitoringServiceTest {
     private static final String TEST_MODULE_CONTENT2 = "content2";
     private static final String TEST_MODULE_REV = "1970-01-01";
     private static final String TEST_MODULE_REV2 = "1970-01-02";
-    private static final  Uri TEST_MODULE_NAMESPACE = new Uri("testModuleNamespace");
+    private static final Uri TEST_MODULE_NAMESPACE = new Uri("testModuleNamespace");
     private static final String TEST_MODULE_NAME = "testModule";
     private static Date TEST_MODULE_DATE;
     private static Date TEST_MODULE_DATE2;
@@ -67,7 +67,7 @@ public class NetconfCapabilityMonitoringServiceTest {
             .build();
     private int capabilitiesSize;
 
-    private final Set<Capability> CAPABILITIES = new HashSet<>();
+    private final Set<Capability> capabilities = new HashSet<>();
 
     @Mock
     private Module moduleMock;
@@ -87,7 +87,7 @@ public class NetconfCapabilityMonitoringServiceTest {
     @BeforeClass
     public static void suiteSetUp() throws Exception {
         TEST_MODULE_DATE = SimpleDateFormatUtil.getRevisionFormat().parse(TEST_MODULE_REV);
-        TEST_MODULE_DATE2= SimpleDateFormatUtil.getRevisionFormat().parse(TEST_MODULE_REV2);
+        TEST_MODULE_DATE2 = SimpleDateFormatUtil.getRevisionFormat().parse(TEST_MODULE_REV2);
     }
 
     @Before
@@ -99,19 +99,21 @@ public class NetconfCapabilityMonitoringServiceTest {
         doReturn(TEST_MODULE_DATE).when(moduleMock).getRevision();
         moduleCapability1 = new YangModuleCapability(moduleMock, TEST_MODULE_CONTENT);
 
-        CAPABILITIES.add(moduleCapability1);
+        capabilities.add(moduleCapability1);
 
         doReturn(new URI(TEST_MODULE_NAMESPACE.getValue())).when(moduleMock2).getNamespace();
         doReturn(TEST_MODULE_NAME).when(moduleMock2).getName();
         doReturn(TEST_MODULE_DATE2).when(moduleMock2).getRevision();
         moduleCapability2 = new YangModuleCapability(moduleMock2, TEST_MODULE_CONTENT2);
 
-        CAPABILITIES.add(new BasicCapability("urn:ietf:params:netconf:base:1.0"));
-        CAPABILITIES.add(new BasicCapability("urn:ietf:params:netconf:base:1.1"));
-        CAPABILITIES.add(new BasicCapability("urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24"));
+        capabilities.add(new BasicCapability("urn:ietf:params:netconf:base:1.0"));
+        capabilities.add(new BasicCapability("urn:ietf:params:netconf:base:1.1"));
+        capabilities.add(new BasicCapability("urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;"
+                + "revision=2010-09-24"));
 
-        doReturn(CAPABILITIES).when(operationServiceFactoryMock).getCapabilities();
-        doReturn(null).when(operationServiceFactoryMock).registerCapabilityListener(any(NetconfCapabilityMonitoringService.class));
+        doReturn(capabilities).when(operationServiceFactoryMock).getCapabilities();
+        doReturn(null).when(operationServiceFactoryMock)
+                .registerCapabilityListener(any(NetconfCapabilityMonitoringService.class));
 
         doReturn(SESSION).when(sessionMock).toManagementSession();
         doNothing().when(listener).onCapabilitiesChanged(any());
@@ -122,7 +124,7 @@ public class NetconfCapabilityMonitoringServiceTest {
         doNothing().when(notificationPublisher).onSessionEnded(any());
 
         monitoringService = new NetconfCapabilityMonitoringService(operationServiceFactoryMock);
-        monitoringService.onCapabilitiesChanged(CAPABILITIES, Collections.emptySet());
+        monitoringService.onCapabilitiesChanged(capabilities, Collections.emptySet());
         monitoringService.setNotificationPublisher(notificationPublisher);
         monitoringService.registerListener(listener);
         capabilitiesSize = monitoringService.getCapabilities().getCapability().size();
@@ -151,9 +153,11 @@ public class NetconfCapabilityMonitoringServiceTest {
     public void testGetSchemaForCapability() throws Exception {
         //test multiple revisions of the same capability
         monitoringService.onCapabilitiesChanged(Collections.singleton(moduleCapability2), Collections.emptySet());
-        final String schema = monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV));
+        final String schema =
+                monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV));
         Assert.assertEquals(TEST_MODULE_CONTENT, schema);
-        final String schema2 = monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV2));
+        final String schema2 =
+                monitoringService.getSchemaForModuleRevision(TEST_MODULE_NAME, Optional.of(TEST_MODULE_REV2));
         Assert.assertEquals(TEST_MODULE_CONTENT2, schema2);
         //remove one revision
         monitoringService.onCapabilitiesChanged(Collections.emptySet(), Collections.singleton(moduleCapability1));
@@ -166,7 +170,7 @@ public class NetconfCapabilityMonitoringServiceTest {
     public void testGetCapabilities() throws Exception {
         Capabilities actual = monitoringService.getCapabilities();
         List<Uri> exp = new ArrayList<>();
-        for (Capability capability : CAPABILITIES) {
+        for (Capability capability : capabilities) {
             exp.add(new Uri(capability.getCapabilityUri()));
         }
         //candidate is added by monitoring service automatically
@@ -188,7 +192,8 @@ public class NetconfCapabilityMonitoringServiceTest {
         final Uri uri = new Uri(capUri);
         final HashSet<Capability> testCaps = new HashSet<>();
         testCaps.add(new BasicCapability(capUri));
-        final ArgumentCaptor<NetconfCapabilityChange> capabilityChangeCaptor = ArgumentCaptor.forClass(NetconfCapabilityChange.class);
+        final ArgumentCaptor<NetconfCapabilityChange> capabilityChangeCaptor =
+                ArgumentCaptor.forClass(NetconfCapabilityChange.class);
         final ArgumentCaptor<Capabilities> monitoringListenerCaptor = ArgumentCaptor.forClass(Capabilities.class);
         //add capability
         monitoringService.onCapabilitiesChanged(testCaps, Collections.emptySet());
index 156c4d7ba9507e44d16c42dc03dfaf80f4b95ca9..5f8c6d2aa46f858c39d21e330b298b2d9adc8ea2 100644 (file)
@@ -47,7 +47,8 @@ public class NetconfImplActivatorTest {
         doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString());
         doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString());
         doReturn("").when(bundle).getProperty(anyString());
-        doReturn(registration).when(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
+        doReturn(registration).when(bundle).registerService(any(Class.class),
+                any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
         doNothing().when(registration).unregister();
         doNothing().when(bundle).removeServiceListener(any(ServiceListener.class));
     }
@@ -56,7 +57,8 @@ public class NetconfImplActivatorTest {
     public void testStart() throws Exception {
         NetconfImplActivator activator = new NetconfImplActivator();
         activator.start(bundle);
-        verify(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
+        verify(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class),
+                any(Dictionary.class));
         activator.stop(bundle);
     }
 }
index 03a74dccdb32b591c43b2c2a5a6b4d15e901d8e7..1736c72f9371e16a6db516afc7b8ceb9dd69c13a 100644 (file)
@@ -34,7 +34,8 @@ import org.xml.sax.SAXException;
 
 public class NetconfOperationRouterImplTest {
 
-    private static final String TEST_RPC = "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><test/></rpc>\n";
+    private static final String TEST_RPC = "<rpc message-id=\"101\" "
+            + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><test/></rpc>\n";
     private static final String MAX_PRIORITY_REPLY = "<high/>";
     private static final String DEFAULT_PRIORITY_REPLY = "<default/>";
 
@@ -62,10 +63,12 @@ public class NetconfOperationRouterImplTest {
         MockitoAnnotations.initMocks(this);
 
         doReturn(HandlingPriority.HANDLE_WITH_MAX_PRIORITY).when(maxPrioMock).canHandle(any(Document.class));
-        doReturn(XmlUtil.readXmlToDocument(MAX_PRIORITY_REPLY)).when(maxPrioMock).handle(any(Document.class), any(NetconfOperationChainedExecution.class));
+        doReturn(XmlUtil.readXmlToDocument(MAX_PRIORITY_REPLY)).when(maxPrioMock).handle(any(Document.class),
+                any(NetconfOperationChainedExecution.class));
 
         doReturn(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY).when(defaultPrioMock).canHandle(any(Document.class));
-        doReturn(XmlUtil.readXmlToDocument(DEFAULT_PRIORITY_REPLY)).when(defaultPrioMock).handle(any(Document.class), any(NetconfOperationChainedExecution.class));
+        doReturn(XmlUtil.readXmlToDocument(DEFAULT_PRIORITY_REPLY)).when(defaultPrioMock).handle(any(Document.class),
+                any(NetconfOperationChainedExecution.class));
 
         final Set<NetconfOperation> operations = new HashSet<>();
         operations.add(maxPrioMock);
@@ -80,8 +83,10 @@ public class NetconfOperationRouterImplTest {
 
     @Test
     public void testOnNetconfMessage() throws Exception {
-        final ArgumentCaptor<NetconfOperationChainedExecution> highPriorityChainEx = ArgumentCaptor.forClass(NetconfOperationChainedExecution.class);
-        final ArgumentCaptor<NetconfOperationChainedExecution> defaultPriorityChainEx = ArgumentCaptor.forClass(NetconfOperationChainedExecution.class);
+        final ArgumentCaptor<NetconfOperationChainedExecution> highPriorityChainEx =
+                ArgumentCaptor.forClass(NetconfOperationChainedExecution.class);
+        final ArgumentCaptor<NetconfOperationChainedExecution> defaultPriorityChainEx =
+                ArgumentCaptor.forClass(NetconfOperationChainedExecution.class);
 
         final Document document = operationRouter.onNetconfMessage(TEST_RPC_DOC, null);
 
@@ -103,7 +108,7 @@ public class NetconfOperationRouterImplTest {
 
     @Test
     public void testOnNetconfMessageFail() throws Exception {
-        try{
+        try {
             emptyOperationRouter.onNetconfMessage(TEST_RPC_DOC, null);
             Assert.fail("Exception expected");
         } catch (final DocumentedException e) {