Added test for OSGi metadata. 78/1678/5
authorMartin Vitez <mvitez@cisco.com>
Fri, 4 Oct 2013 14:26:12 +0000 (16:26 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 7 Feb 2014 17:28:44 +0000 (17:28 +0000)
Change-Id: I225ffa4b5b85fda03e31b238f51151fd89bb6b17
Signed-off-by: Martin Vitez <mvitez@cisco.com>
code-generator/binding-java-api-generator/pom.xml
code-generator/maven-sal-api-gen-plugin/pom.xml
yang/yang-model-util/pom.xml
yangtools-it/pom.xml [new file with mode: 0644]
yangtools-it/src/test/java/BundleStartTest.java [new file with mode: 0644]

index 57c1066a8ceb386df7e8bce28e4435e98ca0d089..6666e155a6dc4a708006e1032c294b1b2bb024f5 100644 (file)
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Import-Package>
+                            !org.sonatype.plexus.build.incremental,
+                            *
+                        </Import-Package>
                     </instructions>
                 </configuration>
             </plugin>
@@ -60,6 +64,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.eclipse.xtend</groupId>
index dc77859ec9dbccc34fca17451544ebf66c979439..d5bc18d4d990cda56de10e1b0799bb8d90b29fd6 100644 (file)
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Import-Package>
+                            !org.apache.maven.plugin.logging,
+                            !org.apache.maven.project
+                            *
+                        </Import-Package>
                     </instructions>
                 </configuration>
             </plugin>
index 5f6d18ee417c699da8878723c7d12304039764a5..8e8efe23d20e87e794c279e7862ea7d27d154ac1 100644 (file)
                 <groupId>org.eclipse.xtend</groupId>
                 <artifactId>xtend-maven-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/yangtools-it/pom.xml b/yangtools-it/pom.xml
new file mode 100644 (file)
index 0000000..789582a
--- /dev/null
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. This 
+    program and the accompanying materials are made available under the terms of the 
+    Eclipse Public License v1.0 which accompanies this distribution, and is available 
+    at http://www.eclipse.org/legal/epl-v10.html -->
+<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">
+
+    <parent>
+        <artifactId>yangtools</artifactId>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <version>0.6.2-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>yangtools-it</artifactId>
+
+    <properties>
+        <exam.version>3.0.0</exam.version>
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>thirdparty</id>
+            <name>thirdparty</name>
+            <url>${nexusproxy}/repositories/thirdparty/</url>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>equinoxSDK381</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.1.v20120830-144521</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.sonatype.plexus</groupId>
+            <artifactId>plexus-build-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-slf4j-logging</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-util</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>maven-sal-api-gen-plugin</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
+            <version>4.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>xtend-lib-osgi</artifactId>
+            <version>2.4.3</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <version>1.2.4</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <!--This plugin's configuration is used to store Eclipse m2e settings 
+                    only. It has no influence on the Maven build itself. -->
+                <plugin>
+                    <groupId>org.eclipse.m2e</groupId>
+                    <artifactId>lifecycle-mapping</artifactId>
+                    <version>1.0.0</version>
+                    <configuration>
+                        <lifecycleMappingMetadata>
+                            <pluginExecutions>
+                                <pluginExecution>
+                                    <pluginExecutionFilter>
+                                        <groupId>org.ops4j.pax.exam</groupId>
+                                        <artifactId>
+                                            maven-paxexam-plugin
+                                        </artifactId>
+                                        <versionRange>[1.2.4,)</versionRange>
+                                        <goals>
+                                            <goal>generate-depends-file</goal>
+                                        </goals>
+                                    </pluginExecutionFilter>
+                                    <action>
+                                        <ignore></ignore>
+                                    </action>
+                                </pluginExecution>
+                            </pluginExecutions>
+                        </lifecycleMappingMetadata>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+</project>
diff --git a/yangtools-it/src/test/java/BundleStartTest.java b/yangtools-it/src/test/java/BundleStartTest.java
new file mode 100644 (file)
index 0000000..f005f35
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+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.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+@RunWith(PaxExam.class)
+public class BundleStartTest {
+    private static final String GROUP = "org.opendaylight.yangtools";
+
+    @Inject
+    BundleContext ctx;
+
+    private List<Option> coreBundles() {
+        List<Option> options = new ArrayList<>();
+
+        options.add(mavenBundle("org.slf4j", "slf4j-api").versionAsInProject());
+        options.add(mavenBundle("ch.qos.logback", "logback-core").versionAsInProject());
+        options.add(mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject());
+        options.add(mavenBundle("com.google.guava", "guava").versionAsInProject());
+        options.add(mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject());
+        options.add(mavenBundle("org.opendaylight.yangtools.thirdparty", "antlr4-runtime-osgi-nohead")
+                .versionAsInProject());
+        options.add(mavenBundle("org.opendaylight.yangtools.thirdparty", "xtend-lib-osgi").versionAsInProject());
+        options.add(mavenBundle("org.sonatype.plexus", "plexus-build-api").versionAsInProject());
+        options.add(mavenBundle("org.codehaus.plexus", "plexus-slf4j-logging").versionAsInProject());
+        options.add(mavenBundle("org.javassist", "javassist").versionAsInProject());
+
+        options.add(mavenBundle(GROUP, "concepts").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-binding").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-common").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-data-api").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-data-impl").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-data-util").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-model-api").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-model-util").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-parser-api").versionAsInProject());
+        options.add(mavenBundle(GROUP, "yang-parser-impl").versionAsInProject());
+
+        options.add(mavenBundle(GROUP, "binding-generator-api").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-generator-impl").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-generator-spi").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-generator-util").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-java-api-generator").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-model-api").versionAsInProject());
+        options.add(mavenBundle(GROUP, "binding-type-provider").versionAsInProject());
+        options.add(mavenBundle(GROUP, "maven-sal-api-gen-plugin").versionAsInProject());
+
+        options.add(junitBundles());
+        return options;
+    }
+
+    @Configuration
+    public final Option[] config() {
+        final List<Option> options = coreBundles();
+        return options.toArray(new Option[0]);
+    }
+
+    @Test
+    public void testBundleActivation() throws BundleException {
+        testBundle("yang-binding");
+        testBundle("yang-common");
+        testBundle("yang-data-api");
+        testBundle("yang-data-impl");
+        testBundle("yang-data-util");
+        testBundle("yang-model-api");
+        testBundle("yang-model-util");
+        testBundle("yang-parser-api");
+        testBundle("yang-parser-impl");
+
+        testBundle("binding-generator-api");
+        testBundle("binding-generator-impl");
+        testBundle("binding-generator-spi");
+        testBundle("binding-generator-util");
+        testBundle("binding-model-api");
+        testBundle("binding-java-api-generator");
+        testBundle("binding-type-provider");
+        testBundle("maven-sal-api-gen-plugin");
+    }
+
+    private void testBundle(String name) throws BundleException {
+        Bundle bundle = getBundle(name);
+        assertNotNull("Bundle '" + name + "' not found", bundle);
+        assertEquals("Bundle '" + name + "' is not in ACTIVE state", Bundle.ACTIVE, bundle.getState());
+    }
+
+    private Bundle getBundle(final String name) {
+        final String bn = GROUP + "." + name;
+        for (Bundle b : ctx.getBundles()) {
+            if (bn.equals(b.getSymbolicName())) {
+                return b;
+            }
+        }
+        return null;
+    }
+
+}