Move JMX generator out of src/main
[controller.git] / itests / base-features-it / src / test / java / org / opendaylight / controller / base / BaseFeatureTest.java
1 package org.opendaylight.controller.base;
2
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;
8
9 import java.io.File;
10 import java.net.URI;
11 import java.util.EnumSet;
12
13 import javax.inject.Inject;
14
15 import org.junit.Assert;
16
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;
26
27
28 @RunWith(PaxExam.class)
29 public class BaseFeatureTest {
30    @Inject
31    private FeaturesService featuresService;
32     @Configuration
33     public Option[] config() {
34        return new Option[] {
35              // Provision and launch a container based on a distribution of Karaf (Apache ServiceMix).
36              karafDistributionConfiguration()
37                  .frameworkUrl(
38                           maven()
39                                   .groupId("org.opendaylight.controller")
40                                   .artifactId("distribution.opendaylight-karaf")
41                                   .type("tar.gz")
42                                   .version("1.4.2-SNAPSHOT"))
43                  .name("OpenDaylight")
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.
48              keepRuntimeFolder(),
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),
57        };
58     }
59
60     @Test
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++)
67        {
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));
72        }
73     }
74 }