pax-exam 3.0.0 migration ...


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1531757 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Composite.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Composite.java
deleted file mode 100644
index 519e63f..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Composite.java
+++ /dev/null
@@ -1,29 +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.multiple;
-
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-public class Composite
-{
-    void bind(Sequencer seq)
-    {
-        seq.step(2);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceConsumer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceConsumer.java
deleted file mode 100644
index 2285e7b..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceConsumer.java
+++ /dev/null
@@ -1,48 +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.multiple;
-
-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;
-
-@Component
-public class ServiceConsumer
-{
-    @ServiceDependency
-    volatile Sequencer m_sequencer;
-
-    @ServiceDependency(filter = "(foo=bar)")
-    volatile ServiceInterface m_service;
-
-    @Start
-    void start()
-    {
-        m_sequencer.step(6);
-        m_service.doService();
-    }
-
-    @Stop
-    void stop()
-    {
-        m_sequencer.step(8);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceInterface.java
deleted file mode 100644
index 1510cc8..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceInterface.java
+++ /dev/null
@@ -1,25 +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.multiple;
-
-
-public interface ServiceInterface
-{
-    public void doService();
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider.java
deleted file mode 100644
index eec473d..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider.java
+++ /dev/null
@@ -1,64 +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.multiple;
-
-import org.apache.felix.dm.annotation.api.Component;
-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.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@Component(properties = { @Property(name = "foo", value = "bar") })
-public class ServiceProvider implements ServiceInterface
-{
-    @ServiceDependency
-    Sequencer m_sequencer;
-
-    ServiceProvider2 m_serviceProvider2;
-
-    @ServiceDependency(removed = "unbind")
-    void bind(ServiceProvider2 provider2)
-    {
-        m_serviceProvider2 = provider2;
-    }
-
-    @Start
-    void start()
-    {
-        m_serviceProvider2.step(4);
-        m_sequencer.step(5);
-    }
-
-    @Stop
-    void stop()
-    {
-        m_sequencer.step(9);
-    }
-
-    void unbind(ServiceProvider2 provider2)
-    {
-        m_sequencer.step(10);
-    }
-
-    public void doService()
-    {
-        m_sequencer.step(7);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider2.java
deleted file mode 100644
index 05a4798..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider2.java
+++ /dev/null
@@ -1,70 +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.multiple;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.Composition;
-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;
-
-@Component(provides = { ServiceProvider2.class }, factoryMethod="create")
-public class ServiceProvider2
-{
-    Composite m_composite = new Composite();
-    Sequencer m_sequencer;
-
-    static ServiceProvider2 create() {
-        return new ServiceProvider2();
-    }
-    
-    @ServiceDependency(required = false, filter = "(foo=bar)") // NullObject
-    Runnable m_runnable;
-
-    @ServiceDependency(service = Sequencer.class)
-    void bind(Sequencer seq)
-    {
-        m_sequencer = seq;
-        m_sequencer.step(1);
-    }
-
-    @Start
-    void start()
-    {
-        m_sequencer.step(3);
-        m_runnable.run(); // NullObject
-    }
-
-    public void step(int step) { // called by ServiceProvider.start() method
-        m_sequencer.step(step);
-    }
-    
-    @Stop
-    void stop()
-    {
-        m_sequencer.step(11);
-    }
-
-    @Composition
-    Object[] getComposition()
-    {
-        return new Object[] { this, m_composite };
-    }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java
deleted file mode 100644
index e1c8f5d..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java
+++ /dev/null
@@ -1,78 +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 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 complex Annotation usage.
- */
-@RunWith(JUnit4TestRunner.class)
-public class MultipleAnnotationsTest 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, "MultipleAnnotationsTest")
-                    .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
-                    .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.multiple")
-                    .set("Import-Package", "*")
-                    .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
-                    .build()));            
-    }
-
-    @Test
-    public void testMultipleAnnotations(BundleContext context)
-    {
-        DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer service to the MultipleAnnotationsTest class.
-        m.add(m.createComponent()
-            .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
-        stopBundle("MultipleAnnotationsTest", context);
-        // And check if the test.annotation bundle has been deactivated orderly
-        m_ensure.waitForStep(11, 10000);
-    }
-}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java
new file mode 100644
index 0000000..4e82155
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java
@@ -0,0 +1,129 @@
+/*
+* 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.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Composition;
+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;
+
+public class MultipleAnnotations {
+    public static class Composite {
+        void bind(Ensure seq) {
+            seq.step(2);
+        }
+    }
+
+    @Component
+    public static class ServiceConsumer {
+        @ServiceDependency(filter="(name=test.MultipleAnnotationsTest)")
+        volatile Ensure m_sequencer;
+
+        @ServiceDependency(filter = "(foo=bar)")
+        volatile ServiceInterface m_service;
+
+        @Start
+        void start() {
+            m_sequencer.step(6);
+            m_service.doService();
+        }
+
+        @Stop
+        void stop() {
+            m_sequencer.step(8);
+        }
+    }
+
+    public interface ServiceInterface {
+        public void doService();
+    }
+
+    @Component(properties = {@Property(name = "foo", value = "bar")})
+    public static class ServiceProvider implements ServiceInterface {
+        @ServiceDependency(filter="(name=test.MultipleAnnotationsTest)")
+        volatile Ensure m_sequencer;
+
+        volatile ServiceProvider2 m_serviceProvider2;
+
+        @ServiceDependency(removed = "unbind")
+        void bind(ServiceProvider2 provider2) {
+            m_serviceProvider2 = provider2;
+        }
+
+        @Start
+        void start() {
+            m_serviceProvider2.step(4);
+            m_sequencer.step(5);
+        }
+
+        @Stop
+        void stop() {
+            m_sequencer.step(9);
+        }
+
+        void unbind(ServiceProvider2 provider2) {
+            m_sequencer.step(10);
+        }
+
+        public void doService() {
+            m_sequencer.step(7);
+        }
+    }
+
+    @Component(provides = {ServiceProvider2.class}, factoryMethod = "create")
+    public static class ServiceProvider2 {
+        final Composite m_composite = new Composite();
+        volatile Ensure m_sequencer;
+
+        static ServiceProvider2 create() {
+            return new ServiceProvider2();
+        }
+
+        @ServiceDependency(required = false, filter = "(foo=bar)") // NullObject
+        volatile Runnable m_runnable;
+
+        @ServiceDependency(service = Ensure.class, filter="(name=test.MultipleAnnotationsTest)")
+        void bind(Ensure seq) {
+            m_sequencer = seq;
+            m_sequencer.step(1);
+        }
+
+        @Start
+        void start() {
+            m_sequencer.step(3);
+            m_runnable.run(); // NullObject
+        }
+
+        public void step(int step) { // called by ServiceProvider.start() method
+            m_sequencer.step(step);
+        }
+
+        @Stop
+        void stop() {
+            m_sequencer.step(11);
+        }
+
+        @Composition
+        Object[] getComposition() {
+            return new Object[]{this, m_composite};
+        }
+    }
+}
diff --git a/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java
new file mode 100644
index 0000000..f86c50b
--- /dev/null
+++ b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.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.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 complex Annotation usage.
+ */
+@RunWith(PaxExam.class)
+public class MultipleAnnotationsTest extends TestBase {
+    @Test
+    public void testMultipleAnnotations() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, "test.MultipleAnnotationsTest");
+        e.waitForStep(7, 10000);
+        stopTestComponentsBundle();
+        // And check if the test.annotation bundle has been deactivated orderly
+        e.waitForStep(11, 10000);
+        sr.unregister();
+    }
+}