pax-exam 3.0.0 migration ...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1531749 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1.java
deleted file mode 100644
index 5496f15..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1.java
+++ /dev/null
@@ -1,108 +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.composite;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.Composition;
-import org.apache.felix.dm.annotation.api.Destroy;
-import org.apache.felix.dm.annotation.api.Init;
-import org.apache.felix.dm.annotation.api.Registered;
-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.ServiceRegistration;
-
-/**
- * This service is also composed of the Component object.
- */
-@Component
-public class C1 implements C1Service
-{
- /* We are composed of this object, which will also be injected with our dependencies */
- private C2 m_c2 = new C2();
-
- /* This dependency filter will be configured from our init method */
- @ServiceDependency(name = "D")
- public volatile Runnable m_runnable;
-
- /* Object used to check that methods are called in the proper sequence */
- @ServiceDependency(filter="(name=C1)")
- private volatile Sequencer m_sequencer;
-
- /**
- * Dynamically configure our "D" dependency, using a dependency customization map
- */
- @Init
- Map<String, String> init()
- {
- m_sequencer.step(1);
- // Configure a filter for our dependency whose name is "D"
- Map<String, String> customization = new HashMap<String, String>();
- customization.put("D.filter", "(foo=bar2)");
- customization.put("D.required", "true");
- return customization;
- }
-
- /**
- * Return the list of object our service is composed of
- */
- @Composition
- Object[] getComposition()
- {
- return new Object[] { this, m_c2 };
- }
-
- /**
- * Our Service is starting, and our Composites will also be
- */
- @Start
- void start()
- {
- System.out.println("start: m_runnable=" + m_runnable);
- m_sequencer.step(3);
- m_runnable.run(); /* step 4 */
- // Our Component.start() method should be called once this method returns.
- }
-
- /**
- * Our provided service has been registered into the OSGi service registry.
- */
- @Registered
- void registered(ServiceRegistration sr)
- {
- m_sequencer.step(7);
- }
-
- /**
- * Our Service is stopping, and our Composites will also be
- */
- @Stop
- void stop()
- {
- m_sequencer.step(9);
- // Our Component.stop() method should be called once this method returns.
- }
-
- /**
- * Our Service is destroying, and our Composites will also be.
- */
- @Destroy
- void destroy()
- {
- m_sequencer.step(11);
- // Our Component.destroy() method should be called once this method returns.
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1Service.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1Service.java
deleted file mode 100644
index a4ce49c..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C1Service.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.felix.dm.test.bundle.annotation.composite;
-
-public interface C1Service
-{
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C2.java
deleted file mode 100644
index 9d486d0..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/C2.java
+++ /dev/null
@@ -1,61 +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.composite;
-
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * The CompositeService is also made up of this Class.
- */
-public class C2
-{
- // Injected dependency (from CompositeService)
- private volatile Sequencer m_sequencer;
-
- // Injected dependency (from CompositeService)
- public volatile Runnable m_runnable;
-
- // lifecycle callback (same method as the one from CompositeService)
- void init()
- {
- m_sequencer.step(2);
- }
-
- // lifecycle callback (same method as the one from CompositeService)
- void start()
- {
- m_sequencer.step(5);
- m_runnable.run(); /* step 6 */
- }
-
- void registered(ServiceRegistration sr)
- {
- if (sr == null)
- {
- m_sequencer.throwable(new Exception("null service registration"));
- }
- m_sequencer.step(8);
- }
-
- // lifecycle callback (same method as the one from CompositeService)
- void stop()
- {
- m_sequencer.step(10);
- }
-
- // lifecycle callback (same method as the one from CompositeService)
- void destroy()
- {
- m_sequencer.step(12);
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java
deleted file mode 100644
index 8f0d569..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java
+++ /dev/null
@@ -1,36 +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.composite;
-
-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.test.bundle.annotation.sequencer.Sequencer;
-
-@Component(properties = @Property(name = "foo", value = "bar1"))
-public class Dependency1 implements Runnable
-{
- @ServiceDependency(filter="(name=Dependency1)")
- Sequencer m_sequencer;
-
- @Start
- void start()
- {
- System.out.println("Dependency1.start");
- }
-
- public void run()
- {
- m_sequencer.step(Integer.MAX_VALUE); // Makes the test fail.
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java
deleted file mode 100644
index 1f6bb56..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java
+++ /dev/null
@@ -1,36 +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.composite;
-
-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.test.bundle.annotation.sequencer.Sequencer;
-
-@Component(properties = @Property(name = "foo", value = "bar2"))
-public class Dependency2 implements Runnable
-{
- @ServiceDependency(filter="(name=Dependency2)")
- Sequencer m_sequencer;
-
- @Start
- void start()
- {
- System.out.println("Dependency2.start");
- }
-
- public void run()
- {
- m_sequencer.step();
- }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java
deleted file mode 100644
index 6f89054..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java
+++ /dev/null
@@ -1,77 +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.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 Composite annotated services.
- */
-@RunWith(JUnit4TestRunner.class)
-public class CompositeAnnotationsTest 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, "CompositeAnnotationsTest")
- .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
- .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.composite")
- .set("Import-Package", "*")
- .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn")
- .build()));
- }
-
- @Test
- public void testComposite(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the "Component" service.
- m.add(makeSequencer(m, "C1"));
- m.add(makeSequencer(m, "Dependency1"));
- m.add(makeSequencer(m, "Dependency2"));
- // Check if the components have been initialized orderly
- m_ensure.waitForStep(4, 10000);
- // Stop the bundle
- stopBundle("CompositeAnnotationsTest", context);
- // And check if the components lifecycle callbacks are called orderly
- m_ensure.waitForStep(12, 10000);
- }
-}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/CompositeAnnotations.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/CompositeAnnotations.java
new file mode 100644
index 0000000..041d693
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/CompositeAnnotations.java
@@ -0,0 +1,181 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Composition;
+import org.apache.felix.dm.annotation.api.Destroy;
+import org.apache.felix.dm.annotation.api.Init;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.Registered;
+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.ServiceRegistration;
+
+public class CompositeAnnotations {
+ public interface C1Service {
+ }
+
+ /**
+ * This service is also composed of the Component object.
+ */
+ @Component
+ public static class C1 implements C1Service {
+ /* We are composed of this object, which will also be injected with our dependencies */
+ private final C2 m_c2 = new C2();
+
+ /* This dependency filter will be configured from our init method */
+ @ServiceDependency(name = "D")
+ public volatile Runnable m_runnable;
+
+ /* Object used to check that methods are called in the proper sequence */
+ @ServiceDependency(filter = "(name=test.compositeAnnotation.c1)")
+ private volatile Ensure m_sequencer;
+
+ /**
+ * Dynamically configure our "D" dependency, using a dependency customization map
+ */
+ @Init
+ Map<String, String> init() {
+ m_sequencer.step(1);
+ // Configure a filter for our dependency whose name is "D"
+ Map<String, String> customization = new HashMap<String, String>();
+ customization.put("D.filter", "(foo=bar2)");
+ customization.put("D.required", "true");
+ return customization;
+ }
+
+ /**
+ * Return the list of object our service is composed of
+ */
+ @Composition
+ Object[] getComposition() {
+ return new Object[]{this, m_c2};
+ }
+
+ /**
+ * Our Service is starting, and our Composites will also be
+ */
+ @Start
+ void start() {
+ m_sequencer.step(3);
+ m_runnable.run(); /* step 4 */
+ // Our Component.start() method should be called once this method returns.
+ }
+
+ /**
+ * Our provided service has been registered into the OSGi service registry.
+ */
+ @Registered
+ void registered(ServiceRegistration sr) {
+ m_sequencer.step(7);
+ }
+
+ /**
+ * Our Service is stopping, and our Composites will also be
+ */
+ @Stop
+ void stop() {
+ m_sequencer.step(9);
+ // Our Component.stop() method should be called once this method returns.
+ }
+
+ /**
+ * Our Service is destroying, and our Composites will also be.
+ */
+ @Destroy
+ void destroy() {
+ m_sequencer.step(11);
+ // Our Component.destroy() method should be called once this method returns.
+ }
+ }
+
+ /**
+ * The CompositeService is also made up of this Class.
+ */
+ public static class C2 {
+ // Injected dependency (from CompositeService)
+ private volatile Ensure m_sequencer;
+
+ // Injected dependency (from CompositeService)
+ public volatile Runnable m_runnable;
+
+ // lifecycle callback (same method as the one from CompositeService)
+ void init() {
+ m_sequencer.step(2);
+ }
+
+ // lifecycle callback (same method as the one from CompositeService)
+ void start() {
+ m_sequencer.step(5);
+ m_runnable.run(); /* step 6 */
+ }
+
+ void registered(ServiceRegistration sr) {
+ if (sr == null) {
+ m_sequencer.throwable(new Exception("null service registration"));
+ }
+ m_sequencer.step(8);
+ }
+
+ // lifecycle callback (same method as the one from CompositeService)
+ void stop() {
+ m_sequencer.step(10);
+ }
+
+ // lifecycle callback (same method as the one from CompositeService)
+ void destroy() {
+ m_sequencer.step(12);
+ }
+ }
+
+ @Component(properties = @Property(name = "foo", value = "bar1"))
+ public static class Dependency1 implements Runnable {
+ @ServiceDependency(filter = "(name=test.compositeAnnotation.dependency1)")
+ volatile Ensure m_sequencer;
+
+ @Start
+ void start() {
+ System.out.println("Dependency1.start");
+ }
+
+ public void run() {
+ m_sequencer.step(Integer.MAX_VALUE); // Makes the test fail.
+ }
+ }
+
+ @Component(properties = @Property(name = "foo", value = "bar2"))
+ public static class Dependency2 implements Runnable {
+ @ServiceDependency(filter = "(name=test.compositeAnnotation.dependency2)")
+ volatile Ensure m_sequencer;
+
+ @Start
+ void start() {
+ System.out.println("Dependency2.start");
+ }
+
+ public void run() {
+ m_sequencer.step();
+ }
+ }
+}
diff --git a/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/CompositeAnnotationsTest.java b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/CompositeAnnotationsTest.java
new file mode 100644
index 0000000..ccff547
--- /dev/null
+++ b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/CompositeAnnotationsTest.java
@@ -0,0 +1,46 @@
+/*
+* 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 Composite annotated services.
+ */
+@RunWith(PaxExam.class)
+public class CompositeAnnotationsTest extends TestBase {
+ @Test
+ public void testComposite() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr1 = register(e, "test.compositeAnnotation.c1");
+ ServiceRegistration sr2 = register(e, "test.compositeAnnotation.dependency1");
+ ServiceRegistration sr3 = register(e, "test.compositeAnnotation.dependency2");
+ e.waitForStep(4, 10000);
+ stopTestComponentsBundle();
+ e.waitForStep(12, 10000);
+ sr3.unregister();
+ sr2.unregister();
+ sr1.unregister();
+ }
+}