pax-exam 3.0.0 migration ...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1531751 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAdapterServiceProperties.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAdapterServiceProperties.java
deleted file mode 100644
index 5a096eb..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAdapterServiceProperties.java
+++ /dev/null
@@ -1,97 +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.extraproperties;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.dm.annotation.api.AdapterService;
-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;
-
-/**
- * This test validates that an adapter Service may specify some extra service properties
- * from it's start callback
- */
-public class ExtraAdapterServiceProperties
-{
- public interface Provider
- {
- }
-
- public interface Provider2
- {
- }
-
-
- @Component(properties={@Property(name="foo", value="bar")})
- public static class ProviderImpl implements Provider
- {
- }
-
- @AdapterService(provides=Provider2.class, properties={@Property(name="foo2", value="bar2")}, adapteeService=Provider.class)
- public static class Provider2Impl implements Provider2
- {
- protected Provider m_adaptee;
-
- @Start
- Map<String, String> start()
- {
- return new HashMap<String, String>() {{ put("foo3", "bar3"); }};
- }
- }
-
- @Component
- public static class Consumer
- {
- @ServiceDependency(filter="(test=ExtraAdapterServiceProperties)")
- Sequencer m_sequencer;
-
- private Map m_properties;
-
- @ServiceDependency
- void bind(Map properties, Provider2 provider2)
- {
- m_properties = properties;
- }
-
- @Start
- void start()
- {
- System.out.println("provider2 service properties: " + m_properties);
- if ("bar".equals(m_properties.get("foo")))
- {
- m_sequencer.step(1);
- }
-
- if ("bar2".equals(m_properties.get("foo2")))
- {
- m_sequencer.step(2);
- }
-
- if ("bar3".equals(m_properties.get("foo3")))
- {
- m_sequencer.step(3);
- }
- }
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAspectServiceProperties.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAspectServiceProperties.java
deleted file mode 100644
index 50b885c..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraAspectServiceProperties.java
+++ /dev/null
@@ -1,90 +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.extraproperties;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.felix.dm.annotation.api.AspectService;
-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;
-
-/**
- * This test validates that an adapter Service may specify some extra service properties
- * from it's start callback
- */
-public class ExtraAspectServiceProperties
-{
- public interface Provider
- {
- }
-
- @Component(properties={@Property(name="foo", value="bar")})
- public static class ProviderImpl implements Provider
- {
- }
-
- @AspectService(ranking=10, properties={@Property(name="foo2", value="bar2")})
- public static class ProviderAspectImpl implements Provider
- {
- @Start
- Map<String, String> start()
- {
- return new HashMap<String, String>() {{ put("foo3", "aspect"); }};
- }
- }
-
- @Component
- public static class Consumer
- {
- @ServiceDependency(filter="(test=ExtraAspectServiceProperties)")
- Sequencer m_sequencer;
-
- private Map m_properties;
-
- @ServiceDependency
- void bind(Map properties, Provider provider)
- {
- m_properties = properties;
- }
-
- @Start
- void start()
- {
- System.out.println("provider aspect service properties: " + m_properties);
- if ("bar".equals(m_properties.get("foo")))
- {
- m_sequencer.step(1);
- }
-
- if ("bar2".equals(m_properties.get("foo2")))
- {
- m_sequencer.step(2);
- }
-
- if ("aspect".equals(m_properties.get("foo3")))
- {
- m_sequencer.step(3);
- }
- }
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraFactoryServiceProperties.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraFactoryServiceProperties.java
deleted file mode 100644
index 8ae5587..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraFactoryServiceProperties.java
+++ /dev/null
@@ -1,96 +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.extraproperties;
-
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-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;
-
-public class ExtraFactoryServiceProperties
-{
- public interface Provider
- {
- }
-
- @Component(properties={@Property(name="foo", value="bar")}, factorySet="MyFactory")
- public static class ProviderImpl implements Provider
- {
- @Start
- Map<String, String> start()
- {
- return new HashMap<String, String>() {{ put("foo2", "bar2"); }};
- }
- }
-
- @Component
- public static class ProviderImplFactory
- {
- @ServiceDependency
- Set<Dictionary> m_factory;
-
- @Start
- void start()
- {
- m_factory.add(new Hashtable() {{ put("foo3", "bar3"); }});
- }
- }
-
- @Component
- public static class Consumer
- {
- @ServiceDependency(filter="(test=ExtraFactoryServiceProperties)")
- Sequencer m_sequencer;
-
- private Map m_properties;
-
- @ServiceDependency
- void bindProvider(Map properties, Provider m_provider)
- {
- m_properties = properties;
- }
-
- @Start
- void start()
- {
- System.out.println("provider service properties: " + m_properties);
- if ("bar".equals(m_properties.get("foo")))
- {
- m_sequencer.step(1);
- }
-
- if ("bar2".equals(m_properties.get("foo2")))
- {
- m_sequencer.step(2);
- }
-
- if ("bar3".equals(m_properties.get("foo3")))
- {
- m_sequencer.step(3);
- }
- }
- }
-}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/ExtraServicePropertiesTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/ExtraServicePropertiesTest.java
deleted file mode 100644
index 979a22b..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/ExtraServicePropertiesTest.java
+++ /dev/null
@@ -1,116 +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.Hashtable;
-
-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 the a Service may provide its service properties dynamically from its start method.
- */
-@RunWith(JUnit4TestRunner.class)
-public class ExtraServicePropertiesTest 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, "ExtraPropertiesTest")
- .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
- .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.extraproperties")
- .set("Import-Package", "*")
- .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
- .build()));
- }
-
- /**
- * Tests if a Service can provide its service properties from its start method.
- */
- @Test
- public void testExtraServiceProperties(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the "Component" service.
- m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(),
- new Hashtable() {{ put("test", "ExtraServiceProperties"); }}));
- m_ensure.waitForStep(2, 10000);
- }
-
- /**
- * Tests if a Service instantiated by a Factory can provide its service properties from its start method.
- */
- @Test
- public void testExtraFactoryServiceProperties(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the "Component" service.
- m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(),
- new Hashtable() {{ put("test", "ExtraFactoryServiceProperties"); }}));
- m_ensure.waitForStep(3, 10000);
- }
-
- /**
- * Tests if an AdapterService can provide its service properties from its start method.
- */
- @Test
- public void testExtraAdapterServiceProperties(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the "Component" service.
- m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(),
- new Hashtable() {{ put("test", "ExtraAdapterServiceProperties"); }}));
- m_ensure.waitForStep(3, 10000);
- }
-
- /**
- * Tests if an AspectService can provide its service properties from its start method.
- */
- @Test
- public void testExtraAspectServiceProperties(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the "Component" service.
- m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(),
- new Hashtable() {{ put("test", "ExtraAspectServiceProperties"); }}));
- m_ensure.waitForStep(3, 10000);
- }
-}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAdapterServiceProperties.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAdapterServiceProperties.java
new file mode 100644
index 0000000..ccba089
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAdapterServiceProperties.java
@@ -0,0 +1,87 @@
+/*
+ * 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.AdapterService;
+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;
+
+/**
+ * This test validates that an adapter Service may specify some extra service properties
+ * from it's start callback
+ */
+public class ExtraAdapterServiceProperties {
+ public interface Provider {
+ }
+
+ public interface Provider2 {
+ }
+
+ @Component(properties = {@Property(name = "foo", value = "bar")})
+ public static class ProviderImpl implements Provider {
+ }
+
+ @AdapterService(provides = Provider2.class, properties = {@Property(name = "foo2", value = "bar2")}, adapteeService = Provider.class)
+ public static class Provider2Impl implements Provider2 {
+ protected Provider m_adaptee;
+
+ @Start
+ Map<String, String> start() {
+ return new HashMap<String, String>() {
+ {
+ put("foo3", "bar3");
+ }
+ };
+ }
+ }
+
+ @Component
+ public static class Consumer {
+ @ServiceDependency(filter = "(name=testExtraAdapterServiceProperties)")
+ volatile Ensure m_sequencer;
+
+ private volatile Map m_properties;
+
+ @ServiceDependency
+ void bind(Map properties, Provider2 provider2) {
+ m_properties = properties;
+ }
+
+ @Start
+ void start() {
+ System.out.println("provider2 service properties: " + m_properties);
+ if ("bar".equals(m_properties.get("foo"))) {
+ m_sequencer.step(1);
+ }
+
+ if ("bar2".equals(m_properties.get("foo2"))) {
+ m_sequencer.step(2);
+ }
+
+ if ("bar3".equals(m_properties.get("foo3"))) {
+ m_sequencer.step(3);
+ }
+ }
+ }
+}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAspectServiceProperties.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAspectServiceProperties.java
new file mode 100644
index 0000000..7b2c7c6
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraAspectServiceProperties.java
@@ -0,0 +1,82 @@
+/*
+ * 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.AspectService;
+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;
+
+/**
+ * This test validates that an adapter Service may specify some extra service properties
+ * from it's start callback
+ */
+public class ExtraAspectServiceProperties {
+ public interface Provider {
+ }
+
+ @Component(properties = {@Property(name = "foo", value = "bar")})
+ public static class ProviderImpl implements Provider {
+ }
+
+ @AspectService(ranking = 10, properties = {@Property(name = "foo2", value = "bar2")})
+ public static class ProviderAspectImpl implements Provider {
+ @Start
+ Map<String, String> start() {
+ return new HashMap<String, String>() {
+ {
+ put("foo3", "aspect");
+ }
+ };
+ }
+ }
+
+ @Component
+ public static class Consumer {
+ @ServiceDependency(filter = "(name=testExtraAspectServiceProperties)")
+ volatile Ensure m_sequencer;
+
+ private volatile Map m_properties;
+
+ @ServiceDependency
+ void bind(Map properties, Provider provider) {
+ m_properties = properties;
+ }
+
+ @Start
+ void start() {
+ System.out.println("provider aspect service properties: " + m_properties);
+ if ("bar".equals(m_properties.get("foo"))) {
+ m_sequencer.step(1);
+ }
+
+ if ("bar2".equals(m_properties.get("foo2"))) {
+ m_sequencer.step(2);
+ }
+
+ if ("aspect".equals(m_properties.get("foo3"))) {
+ m_sequencer.step(3);
+ }
+ }
+ }
+}
diff --git a/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraFactoryServiceProperties.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraFactoryServiceProperties.java
new file mode 100644
index 0000000..a39b5f3
--- /dev/null
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraFactoryServiceProperties.java
@@ -0,0 +1,91 @@
+/*
+ * 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.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+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;
+
+public class ExtraFactoryServiceProperties {
+ public interface Provider {
+ }
+
+ @Component(properties = {@Property(name = "foo", value = "bar")}, factorySet = "MyFactory")
+ public static class ProviderImpl implements Provider {
+ @Start
+ Map<String, String> start() {
+ return new HashMap<String, String>() {
+ {
+ put("foo2", "bar2");
+ }
+ };
+ }
+ }
+
+ @Component
+ public static class ProviderImplFactory {
+ @ServiceDependency
+ volatile Set<Dictionary> m_factory;
+
+ @Start
+ void start() {
+ m_factory.add(new Hashtable() {
+ {
+ put("foo3", "bar3");
+ }
+ });
+ }
+ }
+
+ @Component
+ public static class Consumer {
+ @ServiceDependency(filter = "(name=testExtraFactoryServiceProperties)")
+ volatile Ensure m_sequencer;
+
+ private volatile Map m_properties;
+
+ @ServiceDependency
+ void bindProvider(Map properties, Provider m_provider) {
+ m_properties = properties;
+ }
+
+ @Start
+ void start() {
+ System.out.println("provider service properties: " + m_properties);
+ if ("bar".equals(m_properties.get("foo"))) {
+ m_sequencer.step(1);
+ }
+
+ if ("bar2".equals(m_properties.get("foo2"))) {
+ m_sequencer.step(2);
+ }
+
+ if ("bar3".equals(m_properties.get("foo3"))) {
+ m_sequencer.step(3);
+ }
+ }
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraServiceProperties.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraServiceProperties.java
similarity index 61%
rename from dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraServiceProperties.java
rename to dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraServiceProperties.java
index 388e3e6..530aa7a 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/extraproperties/ExtraServiceProperties.java
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/ExtraServiceProperties.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.dm.test.bundle.annotation.extraproperties;
+package org.apache.felix.dependencymanager.test2.components;
import java.util.HashMap;
import java.util.Map;
@@ -25,55 +25,49 @@
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;
/**
* This test validates that a basic Service may specify some extra service properties
* from it's start callback
*/
-public class ExtraServiceProperties
-{
- public interface Provider
- {
+public class ExtraServiceProperties {
+ public interface Provider {
}
- @Component(properties={@Property(name="foo", value="bar")})
- public static class ProviderImpl implements Provider
- {
+ @Component(properties = {@Property(name = "foo", value = "bar")})
+ public static class ProviderImpl implements Provider {
@Start
- Map<String, String> start()
- {
- return new HashMap<String, String>() {{ put("foo2", "bar2"); }};
+ Map<String, String> start() {
+ return new HashMap<String, String>() {
+ {
+ put("foo2", "bar2");
+ }
+ };
}
}
-
+
@Component
- public static class Consumer
- {
- @ServiceDependency(filter="(test=ExtraServiceProperties)")
- Sequencer m_sequencer;
-
- private Map m_properties;
-
+ public static class Consumer {
+ @ServiceDependency(filter = "(name=testExtraServiceProperties)")
+ volatile Ensure m_sequencer;
+
+ private volatile Map m_properties;
+
@ServiceDependency
- void bindProvider(Map properties, Provider m_provider)
- {
+ void bindProvider(Map properties, Provider m_provider) {
m_properties = properties;
}
-
+
@Start
- void start()
- {
+ void start() {
System.out.println("provider service properties: " + m_properties);
- if ("bar".equals(m_properties.get("foo")))
- {
+ if ("bar".equals(m_properties.get("foo"))) {
m_sequencer.step(1);
}
-
- if ("bar2".equals(m_properties.get("foo2")))
- {
+
+ if ("bar2".equals(m_properties.get("foo2"))) {
m_sequencer.step(2);
- }
+ }
}
}
}
diff --git a/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/ExtraServicePropertiesTest.java b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/ExtraServicePropertiesTest.java
new file mode 100644
index 0000000..b5f1060
--- /dev/null
+++ b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/ExtraServicePropertiesTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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 the a Service may provide its service properties dynamically from its start method.
+ */
+@RunWith(PaxExam.class)
+public class ExtraServicePropertiesTest extends TestBase {
+ /**
+ * Tests if a Service can provide its service properties from its start method.
+ */
+ @Test
+ public void testExtraServiceProperties() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr = register(e, "testExtraServiceProperties");
+ e.waitForStep(2, 10000);
+ sr.unregister();
+ }
+
+ /**
+ * Tests if a Service instantiated by a Factory can provide its service properties from its start method.
+ */
+ @Test
+ public void testExtraFactoryServiceProperties() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr = register(e, "testExtraFactoryServiceProperties");
+ e.waitForStep(3, 10000);
+ sr.unregister();
+ }
+
+ /**
+ * Tests if an AdapterService can provide its service properties from its start method.
+ */
+ @Test
+ public void testExtraAdapterServiceProperties() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr = register(e, "testExtraAdapterServiceProperties");
+ e.waitForStep(3, 10000);
+ sr.unregister();
+ }
+
+ /**
+ * Tests if an AspectService can provide its service properties from its start method.
+ */
+ @Test
+ public void testExtraAspectServiceProperties() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr = register(e, "testExtraAspectServiceProperties");
+ e.waitForStep(3, 10000);
+ sr.unregister();
+ }
+}