From 0ca9c6672b635cb827530bd2ba3d0fbad339c4a7 Mon Sep 17 00:00:00 2001 From: Mathieu Lemay Date: Mon, 28 Jul 2014 15:13:34 -0400 Subject: [PATCH] Created Sample Feature Test Class for Base Feature Repository Change-Id: I9553bc264080abd013c9c9ef8c6a29356e2ac7fd Signed-off-by: Mathieu Lemay --- itests/base-features-it/pom.xml | 90 +++++++++++++++++++ .../controller/base/BaseFeatureTest.java | 74 +++++++++++++++ itests/pom.xml | 18 ++++ opendaylight/commons/opendaylight/pom.xml | 1 + 4 files changed, 183 insertions(+) create mode 100644 itests/base-features-it/pom.xml create mode 100644 itests/base-features-it/src/test/java/org/opendaylight/controller/base/BaseFeatureTest.java create mode 100644 itests/pom.xml diff --git a/itests/base-features-it/pom.xml b/itests/base-features-it/pom.xml new file mode 100644 index 0000000000..8f73779009 --- /dev/null +++ b/itests/base-features-it/pom.xml @@ -0,0 +1,90 @@ + + 4.0.0 + + org.opendaylight.controller + itests-controller + 1.4.2-SNAPSHOT + ../pom.xml + + base-features-it + base-features-it + jar + + + org.opendaylight.controller + base-features + ${project.version} + features + xml + + + org.slf4j + slf4j-api + + + + org.ops4j.pax.exam + pax-exam-container-karaf + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + test + + + org.ops4j.pax.exam + pax-exam + ${pax.exam.version} + test + + + org.ops4j.pax.url + pax-url-aether + test + + + javax.inject + javax.inject + 1 + test + + + org.apache.karaf.features + org.apache.karaf.features.core + ${karaf.version} + test + + + org.osgi + org.osgi.core + test + + + junit + junit + test + + + + + + + + + + + diff --git a/itests/base-features-it/src/test/java/org/opendaylight/controller/base/BaseFeatureTest.java b/itests/base-features-it/src/test/java/org/opendaylight/controller/base/BaseFeatureTest.java new file mode 100644 index 0000000000..0d38940346 --- /dev/null +++ b/itests/base-features-it/src/test/java/org/opendaylight/controller/base/BaseFeatureTest.java @@ -0,0 +1,74 @@ +package org.opendaylight.controller.base; + +import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; + +import java.io.File; +import java.net.URI; +import java.util.EnumSet; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.apache.karaf.features.Feature; +import org.apache.karaf.features.FeaturesService; +import org.apache.karaf.features.Repository; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; + + +@RunWith(PaxExam.class) +public class BaseFeatureTest { + @Inject + private FeaturesService featuresService; + @Configuration + public Option[] config() { + return new Option[] { + // Provision and launch a container based on a distribution of Karaf (Apache ServiceMix). + karafDistributionConfiguration() + .frameworkUrl( + maven() + .groupId("org.opendaylight.controller") + .artifactId("distribution.opendaylight-karaf") + .type("tar.gz") + .version("1.4.2-SNAPSHOT")) + .name("OpenDaylight") + .unpackDirectory(new File("target/pax")) + .useDeployFolder(false), + // It is really nice if the container sticks around after the test so you can check the contents + // of the data directory when things go wrong. + keepRuntimeFolder(), + // Don't bother with local console output as it just ends up cluttering the logs + configureConsole().ignoreLocalConsole(), + // Force the log level to INFO so we have more details during the test. It defaults to WARN. + logLevel(LogLevel.WARN), + // Remember that the test executes in another process. If you want to debug it, you need + // to tell Pax Exam to launch that process with debugging enabled. Launching the test class itself with + // debugging enabled (for example in Eclipse) will not get you the desired results. + //debugConfiguration("5000", true), + }; + } + + @Test + public void testAllFeatures() throws Exception { + featuresService.addRepository(new URI("mvn:org.opendaylight.controller/base-features/1.4.2-SNAPSHOT/xml/features")); + Repository repoUnderTest = featuresService.getRepository("base-1.4.2-SNAPSHOT"); + Assert.assertNotNull(repoUnderTest); + Feature[] featuresUnderTest = repoUnderTest.getFeatures(); + for(int i=0; i< featuresUnderTest.length; i++) + { + Feature feature = featuresUnderTest[i]; + featuresService.installFeature(feature,EnumSet.of(FeaturesService.Option.Verbose)); + System.out.println("Testing Feature:"+feature.getName()); + Assert.assertTrue(featuresService.isInstalled(feature)); + } + } +} \ No newline at end of file diff --git a/itests/pom.xml b/itests/pom.xml new file mode 100644 index 0000000000..19836a2ad6 --- /dev/null +++ b/itests/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.2-SNAPSHOT + ../opendaylight/commons/opendaylight + + itests-controller + pom + + 3.0 + + + base-features-it + + diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index d6c65a4272..ce014fc02d 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -133,6 +133,7 @@ 1.4.2-SNAPSHOT 2013.08.27.4-SNAPSHOT 0.0.2-SNAPSHOT + 4.0.0 1.1.6 1.1.6 1.0-alpha-2 -- 2.36.6