1 package org.opendaylight.controller.base;
3 import static org.ops4j.pax.exam.CoreOptions.maven;
4 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
5 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
6 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
7 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
11 import java.util.EnumSet;
13 import javax.inject.Inject;
15 import junit.framework.Assert;
17 import org.apache.karaf.features.Feature;
18 import org.apache.karaf.features.FeaturesService;
19 import org.apache.karaf.features.Repository;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.ops4j.pax.exam.Configuration;
23 import org.ops4j.pax.exam.Option;
24 import org.ops4j.pax.exam.junit.PaxExam;
25 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
28 @RunWith(PaxExam.class)
29 public class BaseFeatureTest {
31 private FeaturesService featuresService;
33 public Option[] config() {
35 // Provision and launch a container based on a distribution of Karaf (Apache ServiceMix).
36 karafDistributionConfiguration()
39 .groupId("org.opendaylight.controller")
40 .artifactId("distribution.opendaylight-karaf")
42 .version("1.4.2-SNAPSHOT"))
44 .unpackDirectory(new File("target/pax"))
45 .useDeployFolder(false),
46 // It is really nice if the container sticks around after the test so you can check the contents
47 // of the data directory when things go wrong.
49 // Don't bother with local console output as it just ends up cluttering the logs
50 configureConsole().ignoreLocalConsole(),
51 // Force the log level to INFO so we have more details during the test. It defaults to WARN.
52 logLevel(LogLevel.WARN),
53 // Remember that the test executes in another process. If you want to debug it, you need
54 // to tell Pax Exam to launch that process with debugging enabled. Launching the test class itself with
55 // debugging enabled (for example in Eclipse) will not get you the desired results.
56 //debugConfiguration("5000", true),
61 public void testAllFeatures() throws Exception {
62 featuresService.addRepository(new URI("mvn:org.opendaylight.controller/base-features/1.4.2-SNAPSHOT/xml/features"));
63 Repository repoUnderTest = featuresService.getRepository("base-1.4.2-SNAPSHOT");
64 Assert.assertNotNull(repoUnderTest);
65 Feature[] featuresUnderTest = repoUnderTest.getFeatures();
66 for(int i=0; i< featuresUnderTest.length; i++)
68 Feature feature = featuresUnderTest[i];
69 featuresService.installFeature(feature,EnumSet.of(FeaturesService.Option.Verbose));
70 System.out.println("Testing Feature:"+feature.getName());
71 Assert.assertTrue(featuresService.isInstalled(feature));