From: Marian Dubai Date: Fri, 14 Nov 2014 13:16:07 +0000 (+0100) Subject: Fix checkstyle warnings for config-persister-impl X-Git-Tag: release/lithium~872^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8d9cdd0223be6d550d6f44dcb42fe7366bce3cf9 Fix checkstyle warnings for config-persister-impl Change-Id: Ife66b5fea7bb6d1fe293d6181d6da7221e296731 Signed-off-by: Marian Dubai --- diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolder.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolder.java index ab353e349b..eac58cbd7f 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolder.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolder.java @@ -9,6 +9,12 @@ package org.opendaylight.controller.netconf.persist.impl; import com.google.common.annotations.VisibleForTesting; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -17,19 +23,12 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Attr; import org.w3c.dom.Element; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - /** * Inspects snapshot xml to be stored, remove all capabilities that are not referenced by it. * Useful when persisting current configuration. */ public class CapabilityStrippingConfigSnapshotHolder implements ConfigSnapshotHolder { - private static final Logger logger = LoggerFactory.getLogger(CapabilityStrippingConfigSnapshotHolder.class); + private static final Logger LOG = LoggerFactory.getLogger(CapabilityStrippingConfigSnapshotHolder.class); private final String configSnapshot; private final StripCapabilitiesResult stripCapabilitiesResult; @@ -54,7 +53,7 @@ public class CapabilityStrippingConfigSnapshotHolder implements ConfigSnapshotHo static StripCapabilitiesResult stripCapabilities(XmlElement configElement, Set allCapabilitiesFromHello) { // collect all namespaces Set foundNamespacesInXML = getNamespaces(configElement); - logger.trace("All capabilities {}\nFound namespaces in XML {}", allCapabilitiesFromHello, foundNamespacesInXML); + LOG.trace("All capabilities {}\nFound namespaces in XML {}", allCapabilitiesFromHello, foundNamespacesInXML); // required are referenced both in xml and hello SortedSet requiredCapabilities = new TreeSet<>(); // can be removed @@ -68,7 +67,7 @@ public class CapabilityStrippingConfigSnapshotHolder implements ConfigSnapshotHo } } - logger.trace("Required capabilities {}, \nObsolete capabilities {}", + LOG.trace("Required capabilities {}, \nObsolete capabilities {}", requiredCapabilities, obsoleteCapabilities); return new StripCapabilitiesResult(requiredCapabilities, obsoleteCapabilities); diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java index d72c26cb77..7618807a0e 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java @@ -8,21 +8,20 @@ package org.opendaylight.controller.netconf.persist.impl; -import org.opendaylight.controller.config.persist.api.Persister; -import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification; -import org.opendaylight.controller.netconf.api.jmx.DefaultCommitOperationMXBean; -import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.io.Closeable; +import java.io.IOException; import javax.annotation.concurrent.ThreadSafe; import javax.management.InstanceNotFoundException; import javax.management.MBeanServerConnection; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; -import java.io.Closeable; -import java.io.IOException; +import org.opendaylight.controller.config.persist.api.Persister; +import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification; +import org.opendaylight.controller.netconf.api.jmx.DefaultCommitOperationMXBean; +import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Responsible for listening for notifications from netconf (via JMX) containing latest @@ -32,7 +31,7 @@ import java.io.IOException; @ThreadSafe public class ConfigPersisterNotificationHandler implements Closeable { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterNotificationHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPersisterNotificationHandler.class); private final MBeanServerConnection mBeanServerConnection; private final NotificationListener listener; @@ -48,7 +47,7 @@ public class ConfigPersisterNotificationHandler implements Closeable { } private static void registerAsJMXListener(final MBeanServerConnection mBeanServerConnection, final NotificationListener listener) { - logger.trace("Called registerAsJMXListener"); + LOG.trace("Called registerAsJMXListener"); try { mBeanServerConnection.addNotificationListener(DefaultCommitOperationMXBean.OBJECT_NAME, listener, null, null); } catch (InstanceNotFoundException | IOException e) { @@ -65,13 +64,13 @@ public class ConfigPersisterNotificationHandler implements Closeable { mBeanServerConnection.removeNotificationListener(on, listener); } } catch (final Exception e) { - logger.warn("Unable to unregister {} as listener for {}", listener, on, e); + LOG.warn("Unable to unregister {} as listener for {}", listener, on, e); } } } class ConfigPersisterNotificationListener implements NotificationListener { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterNotificationListener.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPersisterNotificationListener.class); private final Persister persisterAggregator; @@ -87,14 +86,14 @@ class ConfigPersisterNotificationListener implements NotificationListener { // Socket should not be closed at this point // Activator unregisters this as JMX listener before close is called - logger.trace("Received notification {}", notification); + LOG.trace("Received notification {}", notification); if (notification instanceof CommitJMXNotification) { try { handleAfterCommitNotification((CommitJMXNotification) notification); } catch (final Exception e) { // log exceptions from notification Handler here since // notificationBroadcastSupport logs only DEBUG level - logger.warn("Failed to handle notification {}", notification, e); + LOG.warn("Failed to handle notification {}", notification, e); throw e; } } else { @@ -106,7 +105,7 @@ class ConfigPersisterNotificationListener implements NotificationListener { try { persisterAggregator.persistConfig(new CapabilityStrippingConfigSnapshotHolder(notification.getConfigSnapshot(), notification.getCapabilities())); - logger.trace("Configuration persisted successfully"); + LOG.trace("Configuration persisted successfully"); } catch (final IOException e) { throw new RuntimeException("Unable to persist configuration snapshot", e); } diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java index b346522f44..b06219c978 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java @@ -53,7 +53,7 @@ import org.xml.sax.SAXException; @Immutable public class ConfigPusherImpl implements ConfigPusher { - private static final Logger logger = LoggerFactory.getLogger(ConfigPusherImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPusherImpl.class); private final long maxWaitForCapabilitiesMillis; private final long conflictingVersionTimeoutMillis; @@ -83,35 +83,35 @@ public class ConfigPusherImpl implements ConfigPusher { * it is good idea to perform garbage collection to prune * any garbage we have accumulated during startup. */ - logger.debug("Running post-initialization garbage collection..."); + LOG.debug("Running post-initialization garbage collection..."); System.gc(); - logger.debug("Post-initialization garbage collection completed."); - logger.debug("ConfigPusher has pushed configs {}, gc completed", configs); + LOG.debug("Post-initialization garbage collection completed."); + LOG.debug("ConfigPusher has pushed configs {}, gc completed", configs); } catch (NetconfDocumentedException e) { - logger.error("Error pushing configs {}",configs); + LOG.error("Error pushing configs {}",configs); throw new IllegalStateException(e); } } } public void pushConfigs(List configs) throws InterruptedException { - logger.debug("Requested to push configs {}", configs); + LOG.debug("Requested to push configs {}", configs); this.queue.put(configs); } private LinkedHashMap internalPushConfigs(List configs) throws NetconfDocumentedException { - logger.debug("Last config snapshots to be pushed to netconf: {}", configs); + LOG.debug("Last config snapshots to be pushed to netconf: {}", configs); LinkedHashMap result = new LinkedHashMap<>(); // start pushing snapshots: for (ConfigSnapshotHolder configSnapshotHolder : configs) { if(configSnapshotHolder != null) { EditAndCommitResponse editAndCommitResponseWithRetries = pushConfigWithConflictingVersionRetries(configSnapshotHolder); - logger.debug("Config snapshot pushed successfully: {}, result: {}", configSnapshotHolder, result); + LOG.debug("Config snapshot pushed successfully: {}, result: {}", configSnapshotHolder, result); result.put(configSnapshotHolder, editAndCommitResponseWithRetries); } } - logger.debug("All configuration snapshots have been pushed successfully."); + LOG.debug("All configuration snapshots have been pushed successfully."); return result; } @@ -133,7 +133,7 @@ public class ConfigPusherImpl implements ConfigPusher { return pushConfig(configSnapshotHolder, operationService); } catch (ConflictingVersionException e) { lastException = e; - logger.debug("Conflicting version detected, will retry after timeout"); + LOG.debug("Conflicting version detected, will retry after timeout"); sleep(); } } while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < conflictingVersionTimeoutMillis); @@ -148,7 +148,7 @@ public class ConfigPusherImpl implements ConfigPusher { try { return getOperationService(expectedCapabilities, idForReporting); } catch (NotEnoughCapabilitiesException e) { - logger.debug("Not enough capabilities: " + e.toString()); + LOG.debug("Not enough capabilities: {}", e.toString()); lastException = e; sleep(); } @@ -187,9 +187,9 @@ public class ConfigPusherImpl implements ConfigPusher { return serviceCandidate; } else { serviceCandidate.close(); - logger.trace("Netconf server did not provide required capabilities for {} " + + LOG.trace("Netconf server did not provide required capabilities for {} ", idForReporting, "Expected but not found: {}, all expected {}, current {}", - idForReporting, notFoundDiff, expectedCapabilities, serviceCandidate.getCapabilities() + notFoundDiff, expectedCapabilities, serviceCandidate.getCapabilities() ); throw new NotEnoughCapabilitiesException("Not enough capabilities for " + idForReporting + ". Expected but not found: " + notFoundDiff); } @@ -234,7 +234,7 @@ public class ConfigPusherImpl implements ConfigPusher { } catch (SAXException | IOException e) { throw new IllegalStateException("Cannot parse " + configSnapshotHolder); } - logger.trace("Pushing last configuration to netconf: {}", configSnapshotHolder); + LOG.trace("Pushing last configuration to netconf: {}", configSnapshotHolder); Stopwatch stopwatch = new Stopwatch().start(); NetconfMessage editConfigMessage = createEditConfigMessage(xmlToBePersisted); @@ -244,16 +244,16 @@ public class ConfigPusherImpl implements ConfigPusher { Document commitResponseMessage = sendRequestGetResponseCheckIsOK(getCommitMessage(), operationService, "commit", configSnapshotHolder.toString()); - if (logger.isTraceEnabled()) { + if (LOG.isTraceEnabled()) { StringBuilder response = new StringBuilder("editConfig response = {"); response.append(XmlUtil.toString(editResponseMessage)); response.append("}"); response.append("commit response = {"); response.append(XmlUtil.toString(commitResponseMessage)); response.append("}"); - logger.trace("Last configuration loaded successfully"); - logger.trace("Detailed message {}", response); - logger.trace("Total time spent {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); + LOG.trace("Last configuration loaded successfully"); + LOG.trace("Detailed message {}", response); + LOG.trace("Total time spent {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); } return new EditAndCommitResponse(editResponseMessage, commitResponseMessage); } diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/NoOpStorageAdapter.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/NoOpStorageAdapter.java index 27f930990d..26e497387a 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/NoOpStorageAdapter.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/NoOpStorageAdapter.java @@ -8,6 +8,9 @@ package org.opendaylight.controller.netconf.persist.impl; +import java.io.IOException; +import java.util.Collections; +import java.util.List; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; import org.opendaylight.controller.config.persist.api.PropertiesProvider; @@ -15,32 +18,28 @@ import org.opendaylight.controller.config.persist.api.StorageAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.Collections; -import java.util.List; - public class NoOpStorageAdapter implements StorageAdapter, Persister { - private static final Logger logger = LoggerFactory.getLogger(NoOpStorageAdapter.class); + private static final Logger LOG = LoggerFactory.getLogger(NoOpStorageAdapter.class); @Override public Persister instantiate(PropertiesProvider propertiesProvider) { - logger.debug("instantiate called with {}", propertiesProvider); + LOG.debug("instantiate called with {}", propertiesProvider); return this; } @Override public void persistConfig(ConfigSnapshotHolder holder) throws IOException { - logger.debug("persistConfig called with {}", holder); + LOG.debug("persistConfig called with {}", holder); } @Override public List loadLastConfigs() throws IOException { - logger.debug("loadLastConfig called"); + LOG.debug("loadLastConfig called"); return Collections.emptyList(); } @Override public void close() { - logger.debug("close called"); + LOG.debug("close called"); } } diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java index 7e68ac1875..0c51166fe4 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java @@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory; * */ public final class PersisterAggregator implements Persister { - private static final Logger logger = LoggerFactory.getLogger(PersisterAggregator.class); + private static final Logger LOG = LoggerFactory.getLogger(PersisterAggregator.class); public static class PersisterWithConfiguration { @@ -139,7 +139,7 @@ public final class PersisterAggregator implements Persister { persisterWithConfigurations.add(PersisterAggregator.loadConfiguration(index, propertiesProvider)); } } - logger.debug("Initialized persister with following adapters {}", persisterWithConfigurations); + LOG.debug("Initialized persister with following adapters {}", persisterWithConfigurations); return new PersisterAggregator(persisterWithConfigurations); } @@ -147,7 +147,7 @@ public final class PersisterAggregator implements Persister { public void persistConfig(ConfigSnapshotHolder holder) throws IOException { for (PersisterWithConfiguration persisterWithConfiguration: persisterWithConfigurations){ if (!persisterWithConfiguration.readOnly){ - logger.debug("Calling {}.persistConfig", persisterWithConfiguration.getStorage()); + LOG.debug("Calling {}.persistConfig", persisterWithConfiguration.getStorage()); persisterWithConfiguration.getStorage().persistConfig(holder); } } @@ -169,12 +169,12 @@ public final class PersisterAggregator implements Persister { throw new RuntimeException("Error while calling loadLastConfig on " + persisterWithConfiguration, e); } if (!configs.isEmpty()) { - logger.debug("Found non empty configs using {}:{}", persisterWithConfiguration, configs); + LOG.debug("Found non empty configs using {}:{}", persisterWithConfiguration, configs); return configs; } } // no storage had an answer - logger.debug("No non-empty list of configuration snapshots found"); + LOG.debug("No non-empty list of configuration snapshots found"); return Collections.emptyList(); } @@ -190,7 +190,7 @@ public final class PersisterAggregator implements Persister { try{ persisterWithConfiguration.storage.close(); }catch(RuntimeException e) { - logger.error("Error while closing {}", persisterWithConfiguration.storage, e); + LOG.error("Error while closing {}", persisterWithConfiguration.storage, e); if (lastException == null){ lastException = e; } else { diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java index 8e9f9978c4..135d5ff9be 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java @@ -8,13 +8,12 @@ package org.opendaylight.controller.netconf.persist.impl.osgi; +import com.google.common.annotations.VisibleForTesting; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; - import javax.management.MBeanServer; - import org.opendaylight.controller.config.persist.api.ConfigPusher; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; @@ -34,11 +33,9 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.annotations.VisibleForTesting; - public class ConfigPersisterActivator implements BundleActivator { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterActivator.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPersisterActivator.class); private static final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); public static final String MAX_WAIT_FOR_CAPABILITIES_MILLIS_PROPERTY = "maxWaitForCapabilitiesMillis"; @@ -57,7 +54,7 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public void start(final BundleContext context) throws Exception { - logger.debug("ConfigPersister starting"); + LOG.debug("ConfigPersister starting"); this.context = context; autoCloseables = new ArrayList<>(); @@ -68,7 +65,7 @@ public class ConfigPersisterActivator implements BundleActivator { long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider); List configs = persisterAggregator.loadLastConfigs(); long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider); - logger.debug("Following configs will be pushed: {}", configs); + LOG.debug("Following configs will be pushed: {}", configs); InnerCustomizer innerCustomizer = new InnerCustomizer(configs, maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis, persisterAggregator); @@ -117,7 +114,7 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public NetconfOperationProvider addingService(ServiceReference reference) { - logger.trace("Got OuterCustomizer.addingService {}", reference); + LOG.trace("Got OuterCustomizer.addingService {}", reference); // JMX was registered, track config-netconf-connector Filter filter; try { @@ -156,15 +153,15 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public NetconfOperationServiceFactory addingService(ServiceReference reference) { - logger.trace("Got InnerCustomizer.addingService {}", reference); + LOG.trace("Got InnerCustomizer.addingService {}", reference); NetconfOperationServiceFactory service = reference.getBundle().getBundleContext().getService(reference); - logger.debug("Creating new job queue"); + LOG.debug("Creating new job queue"); final ConfigPusherImpl configPusher = new ConfigPusherImpl(service, maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis); - logger.debug("Configuration Persister got {}", service); - logger.debug("Context was {}", context); - logger.debug("Registration was {}", registration); + LOG.debug("Configuration Persister got {}", service); + LOG.debug("Context was {}", context); + LOG.debug("Registration was {}", registration); final Thread pushingThread = new Thread(new Runnable() { @Override @@ -177,12 +174,12 @@ public class ConfigPersisterActivator implements BundleActivator { registration = context.registerService(ConfigPusher.class.getName(), configPusher, null); configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator); } else { - logger.warn("Unable to process configs as BundleContext is null"); + LOG.warn("Unable to process configs as BundleContext is null"); } } catch (InterruptedException e) { - logger.info("ConfigPusher thread stopped",e); + LOG.info("ConfigPusher thread stopped",e); } - logger.info("Configuration Persister initialization completed."); + LOG.info("Configuration Persister initialization completed."); } }, "config-pusher"); synchronized (autoCloseables) { diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/PropertiesProviderBaseImpl.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/PropertiesProviderBaseImpl.java index 2a95cca937..d73f3b801e 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/PropertiesProviderBaseImpl.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/PropertiesProviderBaseImpl.java @@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory; public class PropertiesProviderBaseImpl implements PropertiesProvider { - private static final Logger logger = LoggerFactory.getLogger(PropertiesProviderBaseImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(PropertiesProviderBaseImpl.class); private final BundleContext bundleContext; public PropertiesProviderBaseImpl(BundleContext bundleContext) { @@ -28,7 +28,7 @@ public class PropertiesProviderBaseImpl implements PropertiesProvider { } public String getPropertyWithoutPrefix(String fullKey){ - logger.trace("Full key {}", fullKey); + LOG.trace("Full key {}", fullKey); return bundleContext.getProperty(fullKey); } diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolderTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolderTest.java index 7e9d80abc0..b22924a722 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolderTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/CapabilityStrippingConfigSnapshotHolderTest.java @@ -7,18 +7,17 @@ */ package org.opendaylight.controller.netconf.persist.impl; +import static org.junit.Assert.assertEquals; + import com.google.common.collect.Sets; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.w3c.dom.Element; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import static org.junit.Assert.assertEquals; - public class CapabilityStrippingConfigSnapshotHolderTest { @Test diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandlerTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandlerTest.java index f16083e3f3..e96b547169 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandlerTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandlerTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import javax.management.MBeanServerConnection; - import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationListenerTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationListenerTest.java index bf031f192a..f0cd267dd6 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationListenerTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationListenerTest.java @@ -8,10 +8,9 @@ package org.opendaylight.controller.netconf.persist.impl; +import com.google.common.collect.Lists; import java.util.Collections; - import javax.management.Notification; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -25,8 +24,6 @@ import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification; import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification; import org.opendaylight.controller.netconf.util.xml.XmlUtil; -import com.google.common.collect.Lists; - public class ConfigPersisterNotificationListenerTest { @Mock diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/DummyAdapter.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/DummyAdapter.java index e824b58832..792f8cd1c0 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/DummyAdapter.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/DummyAdapter.java @@ -7,15 +7,14 @@ */ package org.opendaylight.controller.netconf.persist.impl; +import java.io.IOException; +import java.util.Collections; +import java.util.List; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; import org.opendaylight.controller.config.persist.api.PropertiesProvider; import org.opendaylight.controller.config.persist.api.StorageAdapter; -import java.io.IOException; -import java.util.Collections; -import java.util.List; - public class DummyAdapter implements StorageAdapter, Persister { static int persist = 0; diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregatorTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregatorTest.java index bef1237f98..e6464f8403 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregatorTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregatorTest.java @@ -8,21 +8,6 @@ package org.opendaylight.controller.netconf.persist.impl; -import com.google.common.collect.Lists; - -import org.junit.Test; -import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; -import org.opendaylight.controller.config.persist.api.Persister; -import org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter; -import org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator; -import org.opendaylight.controller.netconf.persist.impl.osgi.PropertiesProviderBaseImpl; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -31,7 +16,19 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.opendaylight.controller.netconf.persist.impl.PersisterAggregator.PersisterWithConfiguration; -import static org.opendaylight.controller.netconf.persist.impl.PersisterAggregatorTest.TestingPropertiesProvider.loadFile; + +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import org.junit.Test; +import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; +import org.opendaylight.controller.config.persist.api.Persister; +import org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter; +import org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator; +import org.opendaylight.controller.netconf.persist.impl.osgi.PropertiesProviderBaseImpl; public class PersisterAggregatorTest { @@ -72,7 +69,7 @@ public class PersisterAggregatorTest { @Test public void testDummyAdapter() throws Exception { - PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(loadFile("test1.properties")); + PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(TestingPropertiesProvider.loadFile("test1.properties")); List persisters = persisterAggregator.getPersisterWithConfigurations(); assertEquals(1, persisters.size()); PersisterWithConfiguration persister = persisters.get(0); @@ -107,7 +104,7 @@ public class PersisterAggregatorTest { @Test public void testLoadFromPropertyFile() throws Exception { - PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(loadFile("test2.properties")); + PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(TestingPropertiesProvider.loadFile("test2.properties")); List persisters = persisterAggregator.getPersisterWithConfigurations(); assertEquals(1, persisters.size()); PersisterWithConfiguration persister = persisters.get(0); @@ -118,7 +115,7 @@ public class PersisterAggregatorTest { @Test public void testFileStorageNumberOfBackups() throws Exception { try { - PersisterAggregator.createFromProperties(loadFile("test3.properties")); + PersisterAggregator.createFromProperties(TestingPropertiesProvider.loadFile("test3.properties")); fail(); } catch (RuntimeException e) { assertThat( diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java index e02e27a745..142d8f5226 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java @@ -7,7 +7,15 @@ */ package org.opendaylight.controller.netconf.persist.impl.osgi; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; + import com.google.common.collect.Sets; +import java.io.IOException; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,17 +33,8 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.xml.sax.SAXException; -import java.io.IOException; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; - public class ConfigPersisterTest { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterTest.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPersisterTest.class); private MockedBundleContext ctx; private ConfigPersisterActivator configPersisterActivator; @@ -136,7 +135,7 @@ public class ConfigPersisterTest { doReturn(getConflictingService()).when(ctx.serviceFactory).createService(anyString()); Thread.sleep(500); // working service: - logger.info("Switching to working service **"); + LOG.info("Switching to working service **"); doReturn(getWorkingService(getOKDocument())).when(ctx.serviceFactory).createService(anyString()); Thread.sleep(1000); assertCannotRegisterAsJMXListener_pushWasSuccessful(); diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/MockedBundleContext.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/MockedBundleContext.java index 3e5249468d..0d866ecda7 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/MockedBundleContext.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/MockedBundleContext.java @@ -13,6 +13,8 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import java.io.Closeable; import java.io.IOException; import java.util.Collections; @@ -20,7 +22,6 @@ import java.util.Dictionary; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; - import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.config.persist.api.ConfigPusher; @@ -38,9 +39,6 @@ import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - final class MockedBundleContext { @Mock private BundleContext context; diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/TestingExceptionHandler.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/TestingExceptionHandler.java index c8140973eb..fcd39d6ae6 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/TestingExceptionHandler.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/TestingExceptionHandler.java @@ -19,13 +19,13 @@ import org.slf4j.LoggerFactory; final class TestingExceptionHandler implements Thread.UncaughtExceptionHandler { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterTest.class); + private static final Logger LOG = LoggerFactory.getLogger(TestingExceptionHandler.class); private Throwable t; @Override public void uncaughtException(Thread t, Throwable e) { - logger.debug("Uncaught exception in thread {}", t, e); + LOG.debug("Uncaught exception in thread {}", t, e); this.t = e; }