X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-it-base%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fit%2Fbase%2FAbstractConfigTestBase.java;h=4d964eec607135d39ce62e5ed82df1e1a8f090cb;hp=ce38de2d3a33fdb83f383a4400526560f5e6921a;hb=643e257089689f50cdd9523cdf7793078abaddd4;hpb=2bf7349f94202f24f132b14c9cd66340c65a67ee diff --git a/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java b/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java index ce38de2d3a..4d964eec60 100644 --- a/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java +++ b/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java @@ -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, @@ -9,11 +9,13 @@ package org.opendaylight.controller.config.it.base; 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.karaf.options.KarafDistributionOption.editConfigurationFilePut; 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; @@ -32,6 +34,7 @@ import org.opendaylight.controller.config.api.ConfigRegistry; import org.opendaylight.controller.config.util.ConfigRegistryJMXClient; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.OptionUtils; import org.ops4j.pax.exam.karaf.options.KarafDistributionOption; import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; import org.ops4j.pax.exam.options.MavenArtifactUrlReference; @@ -56,11 +59,12 @@ public abstract class AbstractConfigTestBase { * Default values for karaf distro type, groupId, and artifactId */ private static final String KARAF_DISTRO_TYPE = "zip"; - private static final String KARAF_DISTRO_ARTIFACTID = "apache-karaf"; - private static final String KARAF_DISTRO_GROUPID = "org.apache.karaf"; + private static final String KARAF_DISTRO_ARTIFACTID = "opendaylight-karaf-empty"; + 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"; @@ -68,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"; @@ -77,46 +81,71 @@ public abstract class AbstractConfigTestBase { */ private static final int MODULE_TIMEOUT_MILLIS = 60000; - public abstract String getModuleName(); + /** + * This method need only be overridden if using the config system. + * + * @deprecated + * + * @return the config module name + */ + @Deprecated + public String getModuleName() { + return null; + } - public abstract String getInstanceName(); + /** + * This method need only be overridden if using the config system. + * + * @deprecated + * + * @return the config module instance name + */ + @Deprecated + public String getInstanceName() { + return null; + } public abstract MavenUrlReference getFeatureRepo(); 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()); } - public String logConfiguration(Class klazz) { + /** + * Override this method to provide more options to config. + * + * @return An array of additional config options + */ + protected Option[] getAdditionalOptions() { + 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); + 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() .getResourceAsStream(PROPERTIES_FILENAME)) { abstractConfigTestBaseProps.load(abstractConfigTestBaseInputStream); - } catch (IOException e) { + } catch (final IOException e) { LOG.error("Unable to load {} to determine the Karaf version", PROPERTIES_FILENAME, e); } 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(); } @@ -134,32 +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()), - 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:*")}; - return options; + 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 { - LOG.info("Module: {} Instance: {} attempting to configure.", - getModuleName(),getInstanceName()); + String moduleName = getModuleName(); + String instanceName = getInstanceName(); + if (moduleName == null || instanceName == null) { + return; + } + + LOG.info("Module: {} Instance: {} attempting to configure.", moduleName, instanceName); Stopwatch stopWatch = Stopwatch.createStarted(); ObjectName objectName = null; - for(int i = 0;i