From: Madhu Venugopal Date: Sat, 2 Aug 2014 08:34:32 +0000 (+0000) Subject: Merge "Created Sample Feature Test Class for Base Feature Repository" X-Git-Tag: release/helium~362 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=5a9287bb6ddaaa8805939b3b3301f648c03785f4;hp=475d28f717bae92b2cc10b0589131771fcc62242 Merge "Created Sample Feature Test Class for Base Feature Repository" --- 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 b44a7212ca..c4ab2edcb3 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -134,6 +134,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