pax-exam 3.0.0 migration ...


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1531748 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
deleted file mode 100644
index 0544d02..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/Consumer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* 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.BundleDependency;
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.annotation.api.Start;
-import org.apache.felix.dm.annotation.api.Stop;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-import org.osgi.framework.Bundle;
-
-/**
- * Simple Consumer which has a BundleDependency dependency.
- */
-@Component
-public class Consumer
-{
-    protected volatile boolean m_added;
-    protected volatile boolean m_removed;
-
-    @ServiceDependency(filter="(test=consumer)")
-    private volatile Sequencer m_sequencer;
-
-    @BundleDependency(required = false, removed = "removed", filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)")
-    public void add(Bundle b)
-    {
-        if (b != null && b.getSymbolicName().equals("org.apache.felix.dependencymanager"))
-        {
-            m_added = true;
-        }
-    }
-
-    protected void removed(Bundle b)
-    {
-        m_removed = true;
-    }
-
-    @Start
-    public void start()
-    {
-        m_sequencer.step(1);
-    }
-
-    @Stop
-    public void stop()
-    {
-        if (!m_added)
-        {
-            throw new IllegalStateException("Did not get DependencyManager bundle");
-        }
-
-        if (!m_removed)
-        {
-            throw new IllegalStateException("Did not remove DependencyManager bundle");
-        }
-        m_sequencer.step(2);
-    }
-}
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
deleted file mode 100644
index 0dd455c..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceConsumer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* 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.Component;
-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.
- */
-@Component
-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
deleted file mode 100644
index 959b63f..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceInterface.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* 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
deleted file mode 100644
index a63111c..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/bundledependency/ServiceProvider.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-* 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.DependencyManager;
-import org.apache.felix.dm.annotation.api.BundleAdapterService;
-import org.apache.felix.dm.annotation.api.Inject;
-import org.apache.felix.dm.annotation.api.Property;
-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;
-import org.osgi.framework.BundleContext;
-
-/**
- * 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 = { @Property(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;
-
-    // Check auto config injections
-    @Inject
-    BundleContext m_bc;
-    BundleContext m_bcNotInjected;
-    
-    @Inject
-    DependencyManager m_dm;
-    DependencyManager m_dmNotInjected;
-    
-    @Inject
-    org.apache.felix.dm.Component m_component;
-    org.apache.felix.dm.Component m_componentNotInjected;
-
-    @Start
-    void start()
-    {
-        checkInjectedFields();
-        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);
-    }
-    
-    private void checkInjectedFields()
-    {
-        if (m_bc == null)
-        {
-            m_sequencer.throwable(new Exception("Bundle Context not injected"));
-            return;
-        }
-        if (m_bcNotInjected != null)
-        {
-            m_sequencer.throwable(new Exception("Bundle Context must not be injected"));
-            return;
-        }
-
-        if (m_dm == null)
-        {
-            m_sequencer.throwable(new Exception("DependencyManager not injected"));
-            return;
-        }
-        if (m_dmNotInjected != null)
-        {
-            m_sequencer.throwable(new Exception("DependencyManager must not be injected"));
-            return;
-        }
-
-        if (m_component == null)
-        {
-            m_sequencer.throwable(new Exception("Component not injected"));
-            return;
-        }
-        if (m_componentNotInjected != null)
-        {
-            m_sequencer.throwable(new Exception("Component must not be injected"));
-            return;
-        }
-    }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/BundleDependencyAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/BundleDependencyAnnotationTest.java
deleted file mode 100644
index ca358a5..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/BundleDependencyAnnotationTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* 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.annotation;
-
-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 static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import java.util.Properties;
-
-import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.test.Base;
-import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.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.BundleContext;
-import org.osgi.framework.Constants;
-
-/**
- * Use case: Verify Bundle Dependency annotations usage.
- */
-@RunWith(JUnit4TestRunner.class)
-public class BundleDependencyAnnotationTest extends AnnotationBase
-{
-    @Configuration
-    public static Option[] configuration()
-    {
-        return options(
-            systemProperty(DMLOG_PROPERTY).value( "true" ),
-            provision(
-                mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version(Base.OSGI_SPEC_VERSION),
-                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager").versionAsInProject(),
-                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.runtime").versionAsInProject()),
-            provision(
-                new BundleGenerator()
-                    .set(Constants.BUNDLE_SYMBOLICNAME, "BundleDependencyTest")
-                    .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
-                    .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.bundledependency")
-                    .set("Import-Package", "*")
-                    .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
-                    .build()));           
-    }
-
-    /**
-     * Tests a simple Consumer, which has a BundleDependency over the dependency manager bundle.
-     * @param context
-     */
-    @Test
-    public void testBundleDependencyAnnotation(BundleContext context)
-    {
-        DependencyManager m = new DependencyManager(context);
-        Properties props = new Properties() {{ put("test", "consumer"); }};
-        m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props));
-        m_ensure.waitForStep(1, 10000);
-        super.stopBundle("BundleDependencyTest", context);
-        m_ensure.waitForStep(2, 10000);
-    }
-    
-    /**
-     * Tests a Bundle Adapter, which adapts the dependency manager bundle to a "ServiceInterface" service.
-     * @param context
-     * @throws Throwable 
-     */
-    @Test
-    public void testBundleAdapterServiceAnnotation(BundleContext context) throws Throwable
-    {
-        DependencyManager m = new DependencyManager(context);
-        Properties props = new Properties() {{ put("test", "adapter"); }};
-        m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props));
-        m_ensure.waitForStep(3, 10000);
-        m_ensure.ensure();
-    }    
-}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/BundleDependencyAnnotation.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/BundleDependencyAnnotation.java
new file mode 100644
index 0000000..73dc79e
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/BundleDependencyAnnotation.java
@@ -0,0 +1,163 @@
+/*
+* 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.dependencymanager.test2.components;
+
+import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.annotation.api.BundleAdapterService;
+import org.apache.felix.dm.annotation.api.BundleDependency;
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Inject;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+public class BundleDependencyAnnotation {
+    public interface ServiceInterface extends Runnable {
+    }
+
+    /**
+     * Simple Consumer which has a BundleDependency dependency.
+     */
+    @Component
+    public static class Consumer {
+        protected volatile boolean m_added;
+        protected volatile boolean m_removed;
+
+        @ServiceDependency(filter = "(name=bundleDependencyTest.consumer)")
+        private volatile Ensure m_sequencer;
+
+        @BundleDependency(required = false, removed = "removed", filter = "(Bundle-SymbolicName=org.apache.felix.dependencymanager)")
+        public void add(Bundle b) {
+            if (b != null && b.getSymbolicName().equals("org.apache.felix.dependencymanager")) {
+                m_added = true;
+            }
+        }
+
+        protected void removed(Bundle b) {
+            m_removed = true;
+        }
+
+        @Start
+        public void start() {
+            m_sequencer.step(1);
+        }
+
+        @Stop
+        public void stop() {
+            if (!m_added) {
+                throw new IllegalStateException("Did not get DependencyManager bundle");
+            }
+
+            if (!m_removed) {
+                throw new IllegalStateException("Did not remove DependencyManager bundle");
+            }
+            m_sequencer.step(2);
+        }
+    }
+
+    /**
+     * ServiceInterface Consumer.
+     */
+    @Component
+    public static class ServiceConsumer {
+        @ServiceDependency(filter = "(name=bundleDependencyTest.adapter)")
+        volatile Ensure m_sequencer;
+
+        @ServiceDependency
+        volatile ServiceInterface m_service;
+
+        @Start
+        void start() {
+            m_sequencer.step(2);
+            m_service.run();
+        }
+    }
+
+    /**
+     * 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 = {@Property(name = "foo", value = "bar")})
+    public static class ServiceProvider implements ServiceInterface {
+        // Adapted bundle (injected by reflection).
+        protected volatile Bundle m_bundle;
+
+        // Our Sequencer required dependency
+        @ServiceDependency(filter = "(name=bundleDependencyTest.adapter)")
+        volatile Ensure m_sequencer;
+
+        // Check auto config injections
+        @Inject
+        volatile BundleContext m_bc;
+        BundleContext m_bcNotInjected;
+
+        @Inject
+        volatile DependencyManager m_dm;
+        DependencyManager m_dmNotInjected;
+
+        @Inject
+        volatile org.apache.felix.dm.Component m_component;
+        org.apache.felix.dm.Component m_componentNotInjected;
+
+        @Start
+        void start() {
+            checkInjectedFields();
+            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);
+        }
+
+        private void checkInjectedFields() {
+            if (m_bc == null) {
+                m_sequencer.throwable(new Exception("Bundle Context not injected"));
+                return;
+            }
+            if (m_bcNotInjected != null) {
+                m_sequencer.throwable(new Exception("Bundle Context must not be injected"));
+                return;
+            }
+
+            if (m_dm == null) {
+                m_sequencer.throwable(new Exception("DependencyManager not injected"));
+                return;
+            }
+            if (m_dmNotInjected != null) {
+                m_sequencer.throwable(new Exception("DependencyManager must not be injected"));
+                return;
+            }
+
+            if (m_component == null) {
+                m_sequencer.throwable(new Exception("Component not injected"));
+                return;
+            }
+            if (m_componentNotInjected != null) {
+                m_sequencer.throwable(new Exception("Component must not be injected"));
+                return;
+            }
+        }
+    }
+}
diff --git a/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/BundleDependencyAnnotationTest.java b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/BundleDependencyAnnotationTest.java
new file mode 100644
index 0000000..8b4a1c4
--- /dev/null
+++ b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/BundleDependencyAnnotationTest.java
@@ -0,0 +1,58 @@
+/*
+* 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.dependencymanager.test2.integration.annotations;
+
+import org.apache.felix.dependencymanager.test2.components.Ensure;
+import org.apache.felix.dependencymanager.test2.integration.common.TestBase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Use case: Verify Bundle Dependency annotations usage.
+ */
+@RunWith(PaxExam.class)
+public class BundleDependencyAnnotationTest extends TestBase {
+    /**
+     * Tests a simple Consumer, which has a BundleDependency over the dependency manager bundle.
+     */
+    @Test
+    public void testBundleDependencyAnnotation() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, "bundleDependencyTest.consumer");        
+        e.waitForStep(1, 10000);
+        stopTestComponentsBundle();
+        e.waitForStep(2, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Tests a Bundle Adapter, which adapts the dependency manager bundle to a "ServiceInterface" service.
+     * @throws Throwable 
+     */
+    @Test
+    public void testBundleAdapterServiceAnnotation() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, "bundleDependencyTest.adapter");        
+        e.waitForStep(3, 10000);
+        e.ensure();
+        sr.unregister();
+    }
+}