Added test case regarding annotation support (this requires the new test.annotation bundle)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@898084 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/pom.xml b/dependencymanager/test/pom.xml
index 1520a9f..a5cea0c 100644
--- a/dependencymanager/test/pom.xml
+++ b/dependencymanager/test/pom.xml
@@ -44,6 +44,18 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.apache.felix.dependencymanager.runtime</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.apache.felix.dependencymanager.test.annotation</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
       <artifactId>pax-exam</artifactId>
       <version>1.2.0</version>
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
new file mode 100644
index 0000000..d69fc3f
--- /dev/null
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
@@ -0,0 +1,90 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.felix.dm.test;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+
+import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.test.annotation.Sequencer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+@RunWith(JUnit4TestRunner.class)
+public class AnnotationTest implements Sequencer
+{
+    Ensure m_ensure;
+
+    @Configuration
+    public static Option[] configuration()
+    {
+        return options(provision(
+            mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version("4.1.0"),
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager").versionAsInProject(),
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.runtime").versionAsInProject(),
+            mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.test.annotation").versionAsInProject()));
+    }
+
+    @Test
+    public void testSimpleAnnotations(BundleContext context)
+    {
+        m_ensure = new Ensure();
+        DependencyManager m = new DependencyManager(context);
+        // We provide ourself as a "Sequencer" service: this will active the "org.apache.felix.dependencymanager.test.annotation" bundle
+        m.add(m.createService().setImplementation(this).setInterface(Sequencer.class.getName(), null));
+        // Check if the test.annotation components have been initialized orderly
+        m_ensure.waitForStep(7, 10000);
+        // Stop the test.annotation bundle
+        boolean found = false;
+        for (Bundle b : context.getBundles())
+        {
+            if (b.getSymbolicName().equals("org.apache.felix.dependencymanager.test.annotation"))
+            {
+                try
+                {
+                    found = true;
+                    b.stop();
+                }
+                catch (BundleException e)
+                {
+                    e.printStackTrace();
+                }
+            }
+        }
+        if (! found) 
+        {
+            throw new IllegalStateException("org.apache.felix.dependencymanager.test.annotation bundle not found");
+        }
+        // And check if the test.annotation bundle has been deactivated orderly
+        m_ensure.waitForStep(11, 10000);
+    }
+
+    // The test.annotation bundle will call back us here
+    public void next(int step)
+    {
+        m_ensure.step(step);
+    }
+}