Created Sample Feature Test Class for Base Feature Repository 97/9397/2
authorMathieu Lemay <mlemay@inocybe.com>
Mon, 28 Jul 2014 19:13:34 +0000 (15:13 -0400)
committerEd Warnicke <eaw@cisco.com>
Wed, 30 Jul 2014 13:27:15 +0000 (13:27 +0000)
Change-Id: I9553bc264080abd013c9c9ef8c6a29356e2ac7fd
Signed-off-by: Mathieu Lemay <mlemay@inocybe.com>
itests/base-features-it/pom.xml [new file with mode: 0644]
itests/base-features-it/src/test/java/org/opendaylight/controller/base/BaseFeatureTest.java [new file with mode: 0644]
itests/pom.xml [new file with mode: 0644]
opendaylight/commons/opendaylight/pom.xml

diff --git a/itests/base-features-it/pom.xml b/itests/base-features-it/pom.xml
new file mode 100644 (file)
index 0000000..8f73779
--- /dev/null
@@ -0,0 +1,90 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>itests-controller</artifactId>
+        <version>1.4.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>base-features-it</artifactId>
+    <name>base-features-it</name>
+    <packaging>jar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>base-features</artifactId>
+            <version>${project.version}</version>
+            <classifier>features</classifier>
+            <type>xml</type>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <!-- Dependencies for pax exam karaf container -->
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-karaf</artifactId>
+            <version>${pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${pax.exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+            <version>1</version>
+            <scope>test</scope>
+        </dependency>
+         <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>org.apache.karaf.features.core</artifactId>
+            <version>${karaf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+           <groupId>org.osgi</groupId>
+           <artifactId>org.osgi.core</artifactId>
+           <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- Needed if you use versionAsInProject() -->
+            <!--    <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-depends-file</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin> -->
+        </plugins>
+    </build>
+</project>
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 (file)
index 0000000..0d38940
--- /dev/null
@@ -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 (file)
index 0000000..19836a2
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.2-SNAPSHOT</version>
+    <relativePath>../opendaylight/commons/opendaylight</relativePath>
+  </parent>
+  <artifactId>itests-controller</artifactId>
+  <packaging>pom</packaging>
+  <prerequisites>
+    <maven>3.0</maven>
+  </prerequisites>
+  <modules>
+    <module>base-features-it</module>
+  </modules>
+</project>
index d6c65a4..ce014fc 100644 (file)
     <northbound.jolokia.version>1.4.2-SNAPSHOT</northbound.jolokia.version>
     <opendaylight-l2-types.version>2013.08.27.4-SNAPSHOT</opendaylight-l2-types.version>
     <osgi-brandfragment.web.version>0.0.2-SNAPSHOT</osgi-brandfragment.web.version>
+    <pax.exam.version>4.0.0</pax.exam.version>
     <parboiled.version>1.1.6</parboiled.version>
     <parboiled.scala.version>1.1.6</parboiled.scala.version>
     <propertymavenplugin.version>1.0-alpha-2</propertymavenplugin.version>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.