Fix checkstyle issues to enforce it 43/62743/2
authorDavid Suarez <david.suarez.fuentes@gmail.com>
Wed, 6 Sep 2017 07:04:49 +0000 (09:04 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 6 Sep 2017 08:58:14 +0000 (08:58 +0000)
Fix checkstyle issues to enforce it.

Change-Id: I0657beb7831e81b1d24adcd41dc9bf23d0701d64
Signed-off-by: David Suarez <david.suarez.fuentes@gmail.com>
opendaylight/config/config-it-base/pom.xml
opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java

index 4214a3b..e12b966 100644 (file)
@@ -6,7 +6,8 @@ This program and the accompanying materials are made available under the
 terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
   <parent>
     <groupId>org.opendaylight.controller</groupId>
@@ -47,49 +48,58 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
     <!-- Dependencies for pax exam karaf container -->
     <dependency>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>pax-exam-container-karaf</artifactId>
-        <scope>compile</scope>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-karaf</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>pax-exam-junit4</artifactId>
-        <scope>compile</scope>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit4</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>pax-exam</artifactId>
-        <scope>compile</scope>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>org.ops4j.pax.url</groupId>
-        <artifactId>pax-url-aether</artifactId>
-        <scope>compile</scope>
+      <groupId>org.ops4j.pax.url</groupId>
+      <artifactId>pax-url-aether</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>javax.inject</groupId>
-        <artifactId>javax.inject</artifactId>
-        <version>1</version>
-        <scope>compile</scope>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>org.apache.karaf.features</groupId>
-        <artifactId>org.apache.karaf.features.core</artifactId>
-        <version>${karaf.version}</version>
-        <scope>compile</scope>
+      <groupId>org.apache.karaf.features</groupId>
+      <artifactId>org.apache.karaf.features.core</artifactId>
+      <version>${karaf.version}</version>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>org.osgi</groupId>
-        <artifactId>org.osgi.core</artifactId>
-        <scope>compile</scope>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <scope>compile</scope>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>compile</scope>
     </dependency>
   </dependencies>
+
   <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
+    </plugins>
     <resources>
       <resource>
         <directory>src/main/resources</directory>
index 84dcd65..4d964ee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,6 +15,7 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfi
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+
 import com.google.common.base.Stopwatch;
 import java.io.File;
 import java.io.IOException;
@@ -62,7 +63,8 @@ public abstract class AbstractConfigTestBase {
     private static final String KARAF_DISTRO_GROUPID = "org.opendaylight.odlparent";
 
     /*
-     * Property names to override defaults for karaf distro artifactId, groupId, version, and type
+     * Property names to override defaults for karaf distro artifactId, groupId,
+     * version, and type
      */
     private static final String KARAF_DISTRO_VERSION_PROP = "karaf.distro.version";
     private static final String KARAF_DISTRO_TYPE_PROP = "karaf.distro.type";
@@ -70,7 +72,7 @@ public abstract class AbstractConfigTestBase {
     private static final String KARAF_DISTRO_GROUPID_PROP = "karaf.distro.groupId";
 
     /**
-     * Property file used to store the Karaf distribution version
+     * Property file used to store the Karaf distribution version.
      */
     private static final String PROPERTIES_FILENAME = "abstractconfigtestbase.properties";
 
@@ -82,6 +84,8 @@ public abstract class AbstractConfigTestBase {
     /**
      * This method need only be overridden if using the config system.
      *
+     * @deprecated
+     *
      * @return the config module name
      */
     @Deprecated
@@ -92,6 +96,8 @@ public abstract class AbstractConfigTestBase {
     /**
      * This method need only be overridden if using the config system.
      *
+     * @deprecated
+     *
      * @return the config module instance name
      */
     @Deprecated
@@ -104,14 +110,12 @@ public abstract class AbstractConfigTestBase {
     public abstract String getFeatureName();
 
     public Option getLoggingOption() {
-        Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
-                        logConfiguration(AbstractConfigTestBase.class),
-                        LogLevel.INFO.name());
-        return option;
+        return editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG, logConfiguration(AbstractConfigTestBase.class),
+                LogLevel.INFO.name());
     }
 
     /**
-     * Override this method to provide more options to config
+     * Override this method to provide more options to config.
      *
      * @return An array of additional config options
      */
@@ -124,12 +128,13 @@ public abstract class AbstractConfigTestBase {
     }
 
     public String getKarafDistro() {
-        String groupId = System.getProperty(KARAF_DISTRO_GROUPID_PROP,KARAF_DISTRO_GROUPID);
-        String artifactId = System.getProperty(KARAF_DISTRO_ARTIFACTID_PROP,KARAF_DISTRO_ARTIFACTID);
+        String groupId = System.getProperty(KARAF_DISTRO_GROUPID_PROP, KARAF_DISTRO_GROUPID);
+        String artifactId = System.getProperty(KARAF_DISTRO_ARTIFACTID_PROP, KARAF_DISTRO_ARTIFACTID);
         String version = System.getProperty(KARAF_DISTRO_VERSION_PROP);
-        String type = System.getProperty(KARAF_DISTRO_TYPE_PROP,KARAF_DISTRO_TYPE);
+        String type = System.getProperty(KARAF_DISTRO_TYPE_PROP, KARAF_DISTRO_TYPE);
         if (version == null) {
-            // We use a properties file to retrieve ${karaf.version}, instead of .versionAsInProject()
+            // We use a properties file to retrieve ${karaf.version}, instead of
+            // .versionAsInProject()
             // This avoids forcing all users to depend on Karaf in their POMs
             Properties abstractConfigTestBaseProps = new Properties();
             try (InputStream abstractConfigTestBaseInputStream = Thread.currentThread().getContextClassLoader()
@@ -140,10 +145,7 @@ public abstract class AbstractConfigTestBase {
             }
             version = abstractConfigTestBaseProps.getProperty(KARAF_DISTRO_VERSION_PROP);
         }
-        MavenArtifactUrlReference karafUrl = maven()
-                .groupId(groupId)
-                .artifactId(artifactId)
-                .version(version)
+        MavenArtifactUrlReference karafUrl = maven().groupId(groupId).artifactId(artifactId).version(version)
                 .type(type);
         return karafUrl.getURL();
     }
@@ -161,39 +163,36 @@ public abstract class AbstractConfigTestBase {
                 when(Boolean.getBoolean(KARAF_DEBUG_PROP))
                         .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)),
                 karafDistributionConfiguration().frameworkUrl(getKarafDistro())
-                        .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY))
-                        .useDeployFolder(false),
+                        .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY)).useDeployFolder(false),
                 when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
                 features(getFeatureRepo(), getFeatureName()),
-                mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api", "1.0.0"),
-                getLoggingOption(),
+                mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api", "1.0.0"), getLoggingOption(),
                 mvnLocalRepoOption(),
-                editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j.rootLogger", "INFO, stdout, osgi:*")};
+                editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j.rootLogger", "INFO, stdout, osgi:*") };
         return OptionUtils.combine(options, getAdditionalOptions());
     }
 
     @Before
+    @SuppressWarnings("IllegalCatch")
     public void setup() throws Exception {
         String moduleName = getModuleName();
         String instanceName = getInstanceName();
-        if(moduleName == null || instanceName == null) {
+        if (moduleName == null || instanceName == null) {
             return;
         }
 
-        LOG.info("Module: {} Instance: {} attempting to configure.",
-                moduleName, instanceName);
+        LOG.info("Module: {} Instance: {} attempting to configure.", moduleName, instanceName);
         Stopwatch stopWatch = Stopwatch.createStarted();
         ObjectName objectName = null;
-        for(int i = 0;i<MODULE_TIMEOUT_MILLIS;i++) {
+        for (int i = 0; i < MODULE_TIMEOUT_MILLIS; i++) {
             try {
-                ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory
-                        .getPlatformMBeanServer());
+                ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(
+                        ManagementFactory.getPlatformMBeanServer());
                 objectName = configRegistryClient.lookupConfigBean(moduleName, instanceName);
-                LOG.info("Module: {} Instance: {} ObjectName: {}.",
-                        moduleName,instanceName,objectName);
+                LOG.info("Module: {} Instance: {} ObjectName: {}.", moduleName, instanceName, objectName);
                 break;
             } catch (final Exception e) {
-                if(i<MODULE_TIMEOUT_MILLIS) {
+                if (i < MODULE_TIMEOUT_MILLIS) {
                     Thread.sleep(1);
                     continue;
                 } else {
@@ -201,19 +200,17 @@ public abstract class AbstractConfigTestBase {
                 }
             }
         }
-        if(objectName != null) {
-            LOG.info("Module: {} Instance: {} configured after {} ms",
-                moduleName,instanceName,
-                stopWatch.elapsed(TimeUnit.MILLISECONDS));
+        if (objectName != null) {
+            LOG.info("Module: {} Instance: {} configured after {} ms", moduleName, instanceName,
+                    stopWatch.elapsed(TimeUnit.MILLISECONDS));
         } else {
-            throw new RuntimeException("NOT FOUND Module: " +moduleName + " Instance: " + instanceName +
-                    " configured after " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
+            throw new RuntimeException("NOT FOUND Module: " + moduleName + " Instance: " + instanceName
+                    " configured after " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
         }
     }
 
     @Rule
     public TestRule watcher = new TestWatcher() {
-
         @Override
         protected void starting(final Description description) {
             LOG.info("TestWatcher: Starting test: {}", description.getDisplayName());
@@ -239,5 +236,4 @@ public abstract class AbstractConfigTestBase {
             LOG.info("TestWatcher: Test skipped: {} ", description.getDisplayName(), ex);
         }
     };
-
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.