added integration test for new BundleAdapterService annotation

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@918683 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
index 7ee686e..349cd3a 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
@@ -26,13 +26,16 @@
 import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.osgi.framework.Bundle;
 
+/**
+ * Simple Consumer which has a BundleDependency dependency.
+ */
 @Service
 public class Consumer
 {
     protected volatile boolean m_added;
     protected volatile boolean m_removed;
 
-    @ServiceDependency
+    @ServiceDependency(filter="(test=consumer)")
     private volatile Sequencer m_sequencer;
 
     @BundleDependency(required = false, removed = "removed", filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)")
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
new file mode 100644
index 0000000..a97276a
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
@@ -0,0 +1,43 @@
+/*
+* 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.bundle.annotation.bundledependency;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * ServiceInterface Consumer.
+ */
+@Service
+public class ServiceConsumer
+{
+    @ServiceDependency(filter="(test=adapter)")
+    Sequencer m_sequencer;
+
+    @ServiceDependency
+    ServiceInterface m_service;
+
+    @Start
+    void start() {
+        m_sequencer.step(2);
+        m_service.run();
+    }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
new file mode 100644
index 0000000..959b63f
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
@@ -0,0 +1,23 @@
+/*
+* 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.bundle.annotation.bundledependency;
+
+public interface ServiceInterface extends Runnable
+{
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
new file mode 100644
index 0000000..f1550f1
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
@@ -0,0 +1,61 @@
+/*
+* 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.bundle.annotation.bundledependency;
+
+import org.apache.felix.dm.annotation.api.BundleAdapterService;
+import org.apache.felix.dm.annotation.api.Param;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.Bundle;
+
+/**
+ * A BundleAdapter test, which adapts the dependency manager bundle to the ServiceInterface service.
+ */
+@BundleAdapterService(
+    filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)",
+    stateMask = Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE,
+    propagate = true,
+    properties = { @Param(name = "foo", value = "bar") })
+public class ServiceProvider implements ServiceInterface
+{
+    // Adapted bundle (injected by reflection).
+    protected Bundle m_bundle;
+
+    // Our Sequencer required dependency
+    @ServiceDependency(filter = "(test=adapter)")
+    Sequencer m_sequencer;
+
+    @Start
+    void start()
+    {
+        m_sequencer.step(1);
+    }
+
+    public void run()
+    {
+        if (m_bundle == null
+            || !m_bundle.getSymbolicName().equals("org.apache.felix.dependencymanager"))
+        {
+            throw new IllegalStateException("ServiceProvider did not get proper bundle: "
+                + m_bundle);
+        }
+        m_sequencer.step(3);
+    }
+}