Update integration test base classes to use Log4J2 92/68992/2
authorLorand Jakab <lojakab@cisco.com>
Tue, 6 Mar 2018 14:27:36 +0000 (16:27 +0200)
committerLorand Jakab <lojakab@cisco.com>
Tue, 6 Mar 2018 14:27:36 +0000 (16:27 +0200)
The config-it-base and mdsal-it-base components contain abstract classes
to be used for integration tests. This commit migrates those classes to
Log4J2.

See also: https://lists.opendaylight.org/pipermail/odlparent-dev/2018-March/001769.html

Change-Id: Ia19cb2f1d91cc2df7e9fc632a5b82731260652f1
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java
opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java

index 4d964ee..549aef7 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.config.it.base;
 
 
 package org.opendaylight.controller.config.it.base;
 
+import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.when;
@@ -110,8 +111,13 @@ public abstract class AbstractConfigTestBase {
     public abstract String getFeatureName();
 
     public Option getLoggingOption() {
     public abstract String getFeatureName();
 
     public Option getLoggingOption() {
-        return editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG, logConfiguration(AbstractConfigTestBase.class),
-                LogLevel.INFO.name());
+        Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                "log4j2.logger.config-it-base.name",
+                AbstractConfigTestBase.class.getPackage().getName());
+        option = composite(option, editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                "log4j2.logger.config-it-base.level",
+                LogLevel.INFO.name()));
+        return option;
     }
 
     /**
     }
 
     /**
@@ -123,10 +129,6 @@ public abstract class AbstractConfigTestBase {
         return null;
     }
 
         return null;
     }
 
-    public String logConfiguration(final Class<?> klazz) {
-        return "log4j.logger." + klazz.getPackage().getName();
-    }
-
     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);
     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);
@@ -168,7 +170,7 @@ public abstract class AbstractConfigTestBase {
                 features(getFeatureRepo(), getFeatureName()),
                 mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api", "1.0.0"), getLoggingOption(),
                 mvnLocalRepoOption(),
                 features(getFeatureRepo(), getFeatureName()),
                 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, "log4j2.rootLogger.level", "INFO") };
         return OptionUtils.combine(options, getAdditionalOptions());
     }
 
         return OptionUtils.combine(options, getAdditionalOptions());
     }
 
index ef4ab1a..500ce89 100644 (file)
@@ -68,8 +68,11 @@ public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase imple
     @Override
     public Option getLoggingOption() {
         Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
     @Override
     public Option getLoggingOption() {
         Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
-                        logConfiguration(AbstractMdsalTestBase.class),
-                        LogLevel.INFO.name());
+                "log4j2.logger.mdsal-it-base.name",
+                AbstractMdsalTestBase.class.getPackage().getName());
+        option = composite(option, editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                "log4j2.logger.mdsal-it-base.level",
+                LogLevel.INFO.name()));
         option = composite(option, super.getLoggingOption());
         return option;
     }
         option = composite(option, super.getLoggingOption());
         return option;
     }

©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.