reworked annotation junit tests
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@911581 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java
new file mode 100644
index 0000000..44c3cd3
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.aspect;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+
+@Service
+public class AspectTest
+{
+ @ServiceDependency
+ void bind(ServiceInterface service)
+ {
+ service.run();
+ }
+
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java
new file mode 100644
index 0000000..f7f8b76
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java
@@ -0,0 +1,24 @@
+/*
+ * 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.aspect;
+
+public interface ServiceInterface
+{
+ public void run();
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java
new file mode 100644
index 0000000..3dda109
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java
@@ -0,0 +1,35 @@
+/*
+ * 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.aspect;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+@Service
+public class ServiceProvider implements ServiceInterface
+{
+ @ServiceDependency(filter = "(test=aspect.ServiceProvider)")
+ protected Sequencer m_sequencer;
+
+ public void run()
+ {
+ m_sequencer.step(1);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java
new file mode 100644
index 0000000..6051ba8
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java
@@ -0,0 +1,19 @@
+package org.apache.felix.dm.test.bundle.annotation.aspect;
+
+import org.apache.felix.dm.annotation.api.AspectService;
+import org.apache.felix.dm.annotation.api.Param;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.Constants;
+
+@AspectService(filter = "(!(" + Constants.SERVICE_RANKING + "=*))", properties = { @Param(name = Constants.SERVICE_RANKING, value = "1") })
+public class ServiceProviderAspect implements ServiceInterface
+{
+ @ServiceDependency(filter = "(test=aspect.ServiceProviderAspect)")
+ protected Sequencer m_sequencer;
+
+ public void run()
+ {
+ m_sequencer.step(2);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/AspectLifecycleTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/AspectLifecycleTest.java
new file mode 100644
index 0000000..234e202
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/AspectLifecycleTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.aspectlifecycle;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+
+/**
+ * Tests an aspect service, and ensure that its lifecycle methods are properly invoked (init/start/stop/destroy)
+ */
+@Service
+public class AspectLifecycleTest
+{
+ @ServiceDependency
+ void bind(ServiceInterface service)
+ {
+ service.run();
+ }
+
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceInterface.java
new file mode 100644
index 0000000..dbf5c53
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceInterface.java
@@ -0,0 +1,24 @@
+/*
+ * 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.aspectlifecycle;
+
+public interface ServiceInterface
+{
+ public void run();
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProvider.java
new file mode 100644
index 0000000..79da1ab
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProvider.java
@@ -0,0 +1,35 @@
+/*
+ * 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.aspectlifecycle;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+@Service
+public class ServiceProvider implements ServiceInterface
+{
+ @ServiceDependency(filter = "(test=aspectLifecycle.ServiceProvider)")
+ protected Sequencer m_sequencer;
+
+ public void run()
+ {
+ m_sequencer.step(1);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProviderAspect.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProviderAspect.java
new file mode 100644
index 0000000..b6d778f
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspectlifecycle/ServiceProviderAspect.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.dm.test.bundle.annotation.aspectlifecycle;
+
+import org.apache.felix.dm.annotation.api.AspectService;
+import org.apache.felix.dm.annotation.api.Destroy;
+import org.apache.felix.dm.annotation.api.Init;
+import org.apache.felix.dm.annotation.api.Param;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.Constants;
+
+@AspectService(filter = "(!(" + Constants.SERVICE_RANKING + "=*))", properties = { @Param(name = Constants.SERVICE_RANKING, value = "1") })
+public class ServiceProviderAspect implements ServiceInterface
+{
+ protected boolean m_initCalled;
+ protected Sequencer m_sequencer;
+
+ @ServiceDependency(filter = "(test=aspectLifecycle.ServiceProviderAspect)")
+ protected void bind(Sequencer sequencer)
+ {
+ m_sequencer = sequencer;
+ m_sequencer.step(2);
+ }
+
+ @Init
+ void init()
+ {
+ m_initCalled = true;
+ }
+
+ @Start
+ void start()
+ {
+ if (!m_initCalled)
+ {
+ throw new IllegalStateException("start method called, but init method was not called");
+ }
+ m_sequencer.step(3);
+ }
+
+ public void run()
+ {
+ m_sequencer.step(4);
+ }
+
+ @Stop()
+ void stop()
+ {
+ m_sequencer.step(5);
+ }
+
+ @Destroy
+ void destroy()
+ {
+ m_sequencer.step(6);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/Factory.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/Factory.java
new file mode 100644
index 0000000..bc75252
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/Factory.java
@@ -0,0 +1,27 @@
+/*
+ * 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.factory;
+
+public class Factory
+{
+ public FactoryTest createFactoryTest()
+ {
+ return new FactoryTest("factory");
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/FactoryTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/FactoryTest.java
new file mode 100644
index 0000000..e602fa1
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/FactoryTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.factory;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * Validate DependencyManager Factories declared with annotations.
+ */
+@Service(factory = Factory.class, factoryMethod = "createFactoryTest")
+public class FactoryTest
+{
+ String m_id;
+
+ @ServiceDependency
+ Sequencer m_sequencer;
+
+ public FactoryTest(String id)
+ {
+ m_id = id;
+ }
+
+ @Start
+ void start()
+ {
+ if (!"factory".equals(m_id))
+ {
+ throw new IllegalStateException();
+ }
+ m_sequencer.step(1);
+ }
+
+}
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
new file mode 100644
index 0000000..519e63f
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Composite.java
@@ -0,0 +1,29 @@
+/*
+ * 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/Factory.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Factory.java
new file mode 100644
index 0000000..d4429ad
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/Factory.java
@@ -0,0 +1,38 @@
+/*
+ * 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 class Factory
+{
+ public ServiceConsumer createServiceConsumer()
+ {
+ return new ServiceConsumer();
+ }
+
+ public ServiceProvider createServiceProvider()
+ {
+ return new ServiceProvider();
+ }
+
+ public ServiceProvider2 createServiceProvider2()
+ {
+ return new ServiceProvider2();
+ }
+}
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
new file mode 100644
index 0000000..9be1753
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceConsumer.java
@@ -0,0 +1,48 @@
+/*
+ * 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.Service;
+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;
+
+@Service(factory = Factory.class, factoryMethod = "createServiceConsumer")
+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
new file mode 100644
index 0000000..1510cc8
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceInterface.java
@@ -0,0 +1,25 @@
+/*
+ * 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
new file mode 100644
index 0000000..ce4d92f
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider.java
@@ -0,0 +1,67 @@
+/*
+ * 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.Param;
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+@Service(properties = { @Param(name = "foo", value = "bar") }, factory = Factory.class, factoryMethod = "createServiceProvider")
+public class ServiceProvider implements ServiceInterface
+{
+ @ServiceDependency
+ Sequencer m_sequencer;
+
+ ServiceProvider2 m_serviceProvider2;
+
+ @ServiceDependency(removed = "unbind")
+ void bind(ServiceProvider2 provider2)
+ {
+ m_serviceProvider2 = provider2;
+ }
+
+ void unbind(ServiceProvider2 provider2)
+ {
+ m_sequencer.step(10);
+ }
+
+ @Start
+ void start()
+ {
+ if (m_serviceProvider2 != null)
+ {
+ m_sequencer.step(4);
+ }
+ m_sequencer.step(5);
+ }
+
+ @Stop
+ void stop()
+ {
+ m_sequencer.step(9);
+ }
+
+ 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
new file mode 100644
index 0000000..c26f2be
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/ServiceProvider2.java
@@ -0,0 +1,62 @@
+/*
+ * 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.Composition;
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+@Service(provide = { ServiceProvider2.class }, factory = Factory.class, factoryMethod = "createServiceProvider2")
+public class ServiceProvider2
+{
+ Composite m_composite = new Composite();
+ Sequencer m_sequencer;
+
+ @ServiceDependency(required = false, filter = "(foo=bar)")
+ 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();
+ }
+
+ @Stop
+ void stop()
+ {
+ m_sequencer.step(11);
+ }
+
+ @Composition
+ Object[] getComposition()
+ {
+ return new Object[] { this, m_composite };
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java
new file mode 100644
index 0000000..d62a867
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/sequencer/Sequencer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sequencer;
+
+/**
+ * Service used to ensure that steps happens in the expected order.
+ */
+public interface Sequencer
+{
+ /**
+ * Crosses a given step.
+ * @param step the step we are crossing
+ */
+ void step(int step);
+
+ /**
+ * Wait for a given step to occur.
+ * @param nr the step we are waiting for
+ * @param timeout max milliseconds to wait.
+ */
+ void waitForStep(int step, int timeout);
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Consumer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Consumer.java
new file mode 100644
index 0000000..547ff53
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Consumer.java
@@ -0,0 +1,49 @@
+/*
+ * 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.simple;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * Consumes a service which is provided by the {@link Producer} class.
+ */
+@Service
+public class Consumer
+{
+ @ServiceDependency
+ Runnable m_runnable;
+
+ @ServiceDependency
+ Sequencer m_sequencer;
+
+ @Start
+ protected void start() {
+ m_sequencer.step(2);
+ m_runnable.run();
+ }
+
+ @Stop
+ protected void stop() {
+ m_sequencer.step(4);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Producer.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Producer.java
new file mode 100644
index 0000000..39253e0
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/simple/Producer.java
@@ -0,0 +1,50 @@
+/*
+ * 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.simple;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * Provides a <code>Runnable</code> service, which is required by the {@link Consumer} class.
+ */
+@Service
+public class Producer implements Runnable
+{
+ @ServiceDependency
+ Sequencer m_sequencer;
+
+ @Start
+ protected void start() {
+ m_sequencer.step(1);
+ }
+
+ @Stop
+ protected void stop() {
+ m_sequencer.step(5);
+ }
+
+ public void run()
+ {
+ m_sequencer.step(3);
+ }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
new file mode 100644
index 0000000..7a5195a
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.temporal;
+
+import org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.annotation.api.TemporalServiceDependency;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+
+/**
+ * Service using an annotated Temporal Service dependendency.
+ */
+@Service(provide = {})
+public class TemporalTest implements Runnable
+{
+ Thread m_thread;
+
+ @ServiceDependency
+ Sequencer m_sequencer;
+
+ @TemporalServiceDependency(timeout = 1000L, filter = "(test=temporal)")
+ Runnable m_service;
+
+ @Start
+ protected void start()
+ {
+ m_thread = new Thread(this);
+ m_thread.start();
+ }
+
+ @Stop
+ protected void stop()
+ {
+ m_thread.interrupt();
+ try
+ {
+ m_thread.join();
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+
+ public void run()
+ {
+ m_service.run();
+ m_sequencer.waitForStep(2, 15000);
+ m_service.run(); // we should block here
+ m_sequencer.waitForStep(4, 15000);
+ try
+ {
+ m_service.run(); // should raise IllegalStateException
+ }
+ catch (IllegalStateException e)
+ {
+ m_sequencer.step(5);
+ }
+ }
+}