You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2014/05/14 17:51:26 UTC

svn commit: r1594622 [2/2] - in /felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it: components/ tests/

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ResourceAnnotation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ResourceAnnotation.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ResourceAnnotation.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ResourceAnnotation.java Wed May 14 15:51:25 2014
@@ -0,0 +1,289 @@
+/*
+* 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 dm.runtime.it.components;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import junit.framework.Assert;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+import dm.DependencyManager;
+import dm.ResourceHandler;
+import dm.ResourceUtil;
+import dm.annotation.api.Component;
+import dm.annotation.api.Destroy;
+import dm.annotation.api.Init;
+import dm.annotation.api.Inject;
+import dm.annotation.api.Property;
+import dm.annotation.api.ResourceAdapterService;
+import dm.annotation.api.ResourceDependency;
+import dm.annotation.api.ServiceDependency;
+import dm.annotation.api.Start;
+import dm.annotation.api.Stop;
+import dm.it.Ensure;
+
+public class ResourceAnnotation {
+    public final static String ENSURE_RESOURCE = "ResourceAnnotation.resource";
+    public final static String ENSURE_FIELD = "ResourceAnnotation.field";
+    public final static String ENSURE_ADAPTER = "ResourceAnnotation.adapter";
+    public final static String ENSURE_PROVIDER = "ResourceAnnotation.provider";
+
+    /**
+     * A Service provided the ServiceProvider, which is a ResourceAdapter.
+     */
+    public interface ServiceInterface extends Runnable {
+    }
+
+     /**
+     * A Component which has a resource dependency.
+     */
+    @Component
+    public static class ResourceConsumer {
+        @ServiceDependency(required = true, filter = "(name=" + ENSURE_RESOURCE + ")")
+        volatile Ensure m_sequencer;
+
+        private volatile int m_resourcesSeen;
+
+        @Start
+        void start() {
+            System.out.println("ResourceConsumer.start: sequencer=" + m_sequencer);
+        }
+        
+        @ResourceDependency(required = false, filter = "(&(path=/path/to/*.txt)(host=localhost))")
+        public void add(URL resource) {
+            System.out.println("ResourceConsumer.add: resource=" + resource + ", m_sequencer=" + m_sequencer);
+            if (match(resource, "file://localhost/path/to/test1.txt")) {
+                m_resourcesSeen++;
+                return;
+            }
+
+            if (match(resource, "file://localhost/path/to/test2.txt")) {
+                m_resourcesSeen++;
+                return;
+            }
+
+            Assert.fail("Got unexpected resource: " + resource);
+        }
+
+        private boolean match(URL resource, String url) {
+            return url.equals(resource.toString());
+        }
+
+        @Stop
+        void stop() {
+            System.out.println("ResourceConsumer.stop: m_sequencer=" + m_sequencer);
+            Assert.assertEquals(2, m_resourcesSeen);
+            m_sequencer.step(1);
+        }
+    }
+
+    /**
+     * A Component which as a resource dependency, using a class field.
+     */
+    @Component
+    public static class ResourceConsumerField {
+        @ServiceDependency(required = true, filter = "(name=" + ENSURE_FIELD + ")")
+        volatile Ensure m_sequencer;
+
+        @ResourceDependency(filter = "(&(path=*/test1.txt)(host=localhost))")
+        URL m_resource;
+
+        @Init
+        void init() {
+            if (m_resource != null) {
+                Assert.assertTrue("file://localhost/path/to/test1.txt".equals(m_resource.toString()));
+                m_sequencer.step(1);
+            }
+        }
+    }
+
+    /**
+     * Provides some simple resources.
+     */
+    @Component
+    public static class ResourceProvider {
+        @ServiceDependency(required = true, filter = "(name=" + ENSURE_PROVIDER + ")")
+        volatile Ensure m_sequencer;
+
+        @Inject
+        private volatile BundleContext m_context;
+        private final Map m_handlers = new HashMap();
+        private final URL[] m_resources;
+
+        public ResourceProvider() throws Exception {
+            m_resources = new URL[]{
+                    new URL("file://localhost/path/to/test1.txt"),
+                    new URL("file://localhost/path/to/test2.txt"), 
+                    new URL("file://localhost/path/to/README.doc")};
+        }
+
+        /**
+         * Handles a new Resource consumer
+         * @param serviceProperties
+         * @param handler
+         */
+        @ServiceDependency(removed = "remove", required = false)
+        public void add(Map serviceProperties, ResourceHandler handler) {
+            System.out.println("ResourceProvider.addResourceHandler " + handler);
+            String filterString = (String) serviceProperties.get("filter");
+            Filter filter = null;
+            if (filterString != null) {
+                try {
+                    filter = m_context.createFilter(filterString);
+                } catch (InvalidSyntaxException e) {
+                    Assert.fail("Could not create filter for resource handler: " + e);
+                    return;
+                }
+            }
+            synchronized (m_handlers) {
+                m_handlers.put(handler, filter);
+            }
+            for (int i = 0; i < m_resources.length; i++) {
+                if (filter == null || filter.match(ResourceUtil.createProperties(m_resources[i]))) {
+                    System.out.println("ResourceProvider: calling handled.added(" + m_resources[i] + ")");
+                    handler.added(m_resources[i], null);
+                }
+            }
+        }
+
+        /**
+         * Remove a Resource consumer.
+         * @param handler
+         */
+        public void remove(ResourceHandler handler) {
+            System.out.println("ResourceProvider.removeResourceHandler " + handler);
+
+            Filter filter;
+            synchronized (m_handlers) {
+                filter = (Filter) m_handlers.remove(handler);
+            }
+            removeResources(handler, filter);
+        }
+
+        private void removeResources(ResourceHandler handler, Filter filter) {
+            for (int i = 0; i < m_resources.length; i++) {
+                if (filter == null || filter.match(ResourceUtil.createProperties(m_resources[i]))) {
+                    handler.removed(m_resources[i], null);
+                }
+            }
+        }
+
+        /**
+         * Our component is being destroyed: notify all our registered Resource consumers that we don't
+         * provide our Resources anymore.
+         */
+        @Destroy
+        public void destroy() {
+            Entry[] handlers;
+            synchronized (m_handlers) {
+                handlers = (Entry[]) m_handlers.entrySet().toArray(new Entry[m_handlers.size()]);
+            }
+            for (int i = 0; i < handlers.length; i++) {
+                removeResources((ResourceHandler) handlers[i].getKey(), (Filter) handlers[i].getValue());
+            }
+        }
+    }
+
+    /**
+     * Our ServiceInterface provider, which service is activated by a ResourceAdapter.
+     */
+    @ResourceAdapterService(filter = "(&(path=/path/to/test1.txt)(host=localhost))", properties = {@Property(name = "foo", value = "bar")}, propagate = true)
+    public static class ServiceProvider implements ServiceInterface {
+        // Injected by reflection
+        URL m_resource;
+
+        @ServiceDependency(filter = "(name=" + ENSURE_ADAPTER + ")")
+        Ensure m_sequencer;
+
+        // Check auto config injections
+        @Inject
+        BundleContext m_bc;
+        BundleContext m_bcNotInjected;
+
+        @Inject
+        DependencyManager m_dm;
+        DependencyManager m_dmNotInjected;
+
+        @Inject
+        dm.Component m_component;
+        dm.Component m_componentNotInjected;
+
+        public void run() {
+            checkInjectedFields();
+            Assert.assertNotNull("Resource has not been injected in the adapter", m_resource);
+            Assert.assertEquals("ServiceProvider did not get expected resource", "file://localhost/path/to/test1.txt",
+                    m_resource.toString());
+            m_sequencer.step(2);
+        }
+
+        private void checkInjectedFields() {
+            if (m_bc == null) {
+                m_sequencer.throwable(new Exception("Bundle Context not injected"));
+                return;
+            }
+            if (m_bcNotInjected != null) {
+                m_sequencer.throwable(new Exception("Bundle Context must not be injected"));
+                return;
+            }
+
+            if (m_dm == null) {
+                m_sequencer.throwable(new Exception("DependencyManager not injected"));
+                return;
+            }
+            if (m_dmNotInjected != null) {
+                m_sequencer.throwable(new Exception("DependencyManager must not be injected"));
+                return;
+            }
+
+            if (m_component == null) {
+                m_sequencer.throwable(new Exception("Component not injected"));
+                return;
+            }
+            if (m_componentNotInjected != null) {
+                m_sequencer.throwable(new Exception("Component must not be injected"));
+                return;
+            }
+        }
+    }
+    
+    /**
+     * A Component with a dependency over the ServiceInterface, which is actually provided
+     * by a ResourceAdapter.
+     */
+    @Component
+    public static class ServiceConsumer {
+        @ServiceDependency
+        ServiceInterface m_serviceInterface;
+
+        @ServiceDependency(filter = "(name=" + ENSURE_ADAPTER + ")")
+        Ensure m_sequencer;
+
+        @Start
+        void start() {
+            m_sequencer.step(1);
+            m_serviceInterface.run();
+        }
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceFactoryAnnotation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceFactoryAnnotation.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceFactoryAnnotation.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceFactoryAnnotation.java Wed May 14 15:51:25 2014
@@ -0,0 +1,176 @@
+/*
+* 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 dm.runtime.it.components;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import dm.annotation.api.Component;
+import dm.annotation.api.Init;
+import dm.annotation.api.Property;
+import dm.annotation.api.ServiceDependency;
+import dm.annotation.api.Start;
+import dm.annotation.api.Stop;
+import dm.it.Ensure;
+
+public class ServiceFactoryAnnotation {
+    public final static String FACTORY = "ServiceFactoryAnnotation.Factory";
+    public final static String ENSURE = "ServiceFactoryAnnotation.Ensure";
+
+    public interface MyServiceInterface {
+        public void added(String instanceId);
+
+        public void changed(String modified);
+
+        public void removed();
+    }
+
+    @Component(properties = @Property(name = "foo", value = "bar"))
+    public static class ExtraDependency1 implements Runnable {
+        public void run() {
+        }
+    }
+
+    @Component(properties = @Property(name = "foo", value = "bar2"))
+    public static class ExtraDependency2 implements Runnable {
+        public void run() {
+            System.out.println("ExtraDependency2.run()");
+        }
+    }
+
+    /**
+     * This service is instantiated using a "factory set" from the
+     * ServiceFactoryAnnotationTest class.
+     * 
+     * @see org.apache.felix.dm.test.annotation.ServiceFactoryAnnotationTest
+     */
+    @Component(factorySet = FACTORY, factoryConfigure = "configure", properties = {@Property(name = "foo", value = "bar")})
+    public static class MyService implements MyServiceInterface {
+        /**
+         * The configuration provided by MyServiceFactory
+         */
+        @SuppressWarnings("unchecked")
+        volatile Dictionary m_configuration;
+
+        /**
+         * Our sequencer.
+         */
+        @ServiceDependency(filter = "(name=" + ENSURE + ")")
+        volatile Ensure m_sequencer;
+
+        /**
+         * An extra dependency (we'll dynamically configure the filter from our
+         * init() method).
+         */
+        @ServiceDependency(name = "extra")
+        Runnable m_extra;
+
+        /**
+         * This is the first method called: we are provided with the
+         * MyServiceFactory configuration.
+         */
+        public void configure(Dictionary<?, ?> configuration) {
+            if (m_configuration == null) {
+                m_configuration = configuration;
+            } else {
+                m_sequencer.step(5);
+            }
+        }
+
+        /**
+         * Initialize our Service: we'll dynamically configure our dependency whose
+         * name is "extra".
+         */
+        @Init
+        Map init() {
+            return new HashMap() {
+                {
+                    put("extra.filter", "(foo=bar2)");
+                    put("extra.required", "true");
+                }
+            };
+        }
+
+        /**
+         * our Service is starting: at this point, all required dependencies have
+         * been injected.
+         */
+        @Start
+        public void start() {
+            Assert.assertNotNull("Extra dependency not injected", m_extra);
+            m_extra.run();
+            m_sequencer.step(2);
+        }
+
+        /**
+         * Our service is stopping.
+         */
+        @Stop
+        public void stop() {
+            m_sequencer.step(10);
+        }
+
+        public void added(String instanceId) {
+            if (instanceId.equals(m_configuration.get("instance.id"))) {
+                m_sequencer.step(4);
+            }
+        }
+
+        public void changed(String modified) {
+            if (modified.equals(m_configuration.get("instance.modified"))) {
+                m_sequencer.step(7);
+            }
+        }
+
+        public void removed() {
+            m_sequencer.step(9);
+        }
+    }
+
+    @Component
+    public static class MyServiceClient {
+        @ServiceDependency(filter = "(name=" + ENSURE + ")")
+        volatile Ensure m_sequencer;
+
+        @Start
+        void start() {
+            m_sequencer.step(1);
+        }
+
+        @ServiceDependency(required = false, changed = "update", removed = "removed")
+        void bind(Map serviceProperties, MyServiceInterface service) {
+            m_sequencer.step(3);
+            Assert.assertEquals("bar", serviceProperties.get("foo"));
+            Assert.assertNull(serviceProperties.get(".private.param"));
+            service.added((String) serviceProperties.get("instance.id"));
+        }
+
+        void update(Map serviceProperties, MyServiceInterface service) {
+            m_sequencer.step(6);
+            service.changed((String) serviceProperties.get("instance.modified"));
+        }
+
+        void removed(MyServiceInterface service) {
+            m_sequencer.step(8);
+            service.removed();
+        }
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceTestWthPublisher.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceTestWthPublisher.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceTestWthPublisher.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/ServiceTestWthPublisher.java Wed May 14 15:51:25 2014
@@ -0,0 +1,92 @@
+/*
+ * 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 dm.runtime.it.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import dm.annotation.api.Component;
+import dm.annotation.api.Init;
+import dm.annotation.api.LifecycleController;
+import dm.annotation.api.Property;
+import dm.annotation.api.ServiceDependency;
+import dm.annotation.api.Start;
+import dm.it.Ensure;
+
+/**
+ * A Service that just registers/unregisters its service, using the @ServiceLifecycle annotation.
+ */
+public class ServiceTestWthPublisher {
+    public final static String ENSURE = "ServiceTestWthPublisher";
+    
+    public interface Provider {
+    }
+
+    @Component
+    public static class Consumer {
+        @ServiceDependency(filter = "(name=" + ENSURE + ")")
+        volatile Ensure m_sequencer;
+
+        @ServiceDependency(required = false, removed = "unbind")
+        void bind(Map properties, Provider provider) {
+            m_sequencer.step(1);
+            if ("bar".equals(properties.get("foo"))) {
+                m_sequencer.step(2);
+            }
+            if ("bar2".equals(properties.get("foo2"))) {
+                m_sequencer.step(3);
+            }
+        }
+
+        void unbind(Provider provider) {
+            m_sequencer.step(4);
+        }
+    }
+
+    @Component(properties = {@Property(name = "foo", value = "bar")})
+    public static class ProviderImpl implements Provider {
+        @LifecycleController
+        volatile Runnable m_publisher; // injected and used to register our service
+
+        @LifecycleController(start = false)
+        volatile Runnable m_unpublisher; // injected and used to unregister our service
+
+        @ServiceDependency(filter = "(name=" + ENSURE + ")")
+        volatile Ensure m_sequencer;
+
+        @Init
+        void init() {
+            // register service in 1 second
+            Utils.schedule(m_publisher, 1000);
+            // unregister the service in 2 seconds
+            Utils.schedule(m_unpublisher, 2000);
+        }
+
+        @Start
+        Map start() {
+            // Add some extra service properties ... they will be appended to the one we have defined
+            // in the @Service annotation.
+            return new HashMap() {
+                {
+                    put("foo2", "bar2");
+                }
+            };
+        }
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/TemporalAnnotations.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/TemporalAnnotations.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/TemporalAnnotations.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/TemporalAnnotations.java Wed May 14 15:51:25 2014
@@ -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 dm.runtime.it.components;
+
+import dm.annotation.api.Component;
+import dm.annotation.api.ServiceDependency;
+import dm.annotation.api.Start;
+import dm.annotation.api.Stop;
+import dm.it.Ensure;
+
+/**
+ * Service using an annotated Temporal Service dependency.
+ */
+@Component(provides = {})
+public class TemporalAnnotations implements Runnable {
+    public final static String ENSURE = "TemporalAnnotations";
+    Thread m_thread;
+
+    @ServiceDependency(filter = "(name=" + ENSURE + ")")
+    volatile Ensure m_sequencer;
+
+    @ServiceDependency(timeout = 1000L, filter = "(test=temporal)")
+    volatile 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);
+        }
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/Utils.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/Utils.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/Utils.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/Utils.java Wed May 14 15:51:25 2014
@@ -0,0 +1,39 @@
+/*
+ * 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 dm.runtime.it.components;
+
+public class Utils {
+    public static final String DM_BSN = "dm"; // FIXME replace by org.apache.felix.dependencymanager
+    public static final String DM_RUNTIME_IT_COMPONENTS_BSN = "dm.runtime.it.components"; // FIXME replace by proper package
+
+    public static void schedule(final Runnable task, final long n) {
+        Thread t = new Thread() {
+            public void run() {
+                try {
+                    sleep(n);
+                } catch (InterruptedException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+                task.run();
+            }
+        };
+        t.start();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AdapterAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AdapterAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AdapterAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/AdapterAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,80 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.AdapterAnnotation.S1Impl;
+import dm.runtime.it.components.AdapterAnnotation.S1ToS3AdapterAutoConfig;
+import dm.runtime.it.components.AdapterAnnotation.S1ToS3AdapterAutoConfigField;
+import dm.runtime.it.components.AdapterAnnotation.S1ToS3AdapterCallback;
+import dm.runtime.it.components.AdapterAnnotation.S2Impl;
+
+/**
+ * Use case: Verify Aspect Annotations usage.
+ */
+public class AdapterAnnotationTest extends TestBase {
+    /**
+     * Check if an adapter gets injected with its adaptee using default auto config mode.
+     * @throws Throwable 
+     */
+    public void testAnnotatedAdapterAutoConfig() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr1 = register(e, S1ToS3AdapterAutoConfig.ENSURE);
+        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
+        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
+        e.waitForStep(3, 10000);
+        e.ensure();
+        sr1.unregister();
+        sr2.unregister();
+        sr3.unregister();
+    }
+
+    /**
+     * Check if an adapter gets injected with its adaptee in a named class field.
+     */
+    public void testAnnotatedAdapterAutoConfigField() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr1 = register(e, S1ToS3AdapterAutoConfigField.ENSURE);
+        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
+        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
+        e.waitForStep(3, 10000);
+        e.ensure();
+        sr1.unregister();
+        sr2.unregister();
+        sr3.unregister();
+    }
+
+    /**
+     * Check if an adapter gets injected with its adaptee in a callback method.
+     */
+    public void testAnnotatedAdapterCallback() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr1 = register(e, S1ToS3AdapterCallback.ENSURE);
+        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
+        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
+        e.waitForStep(2, 10000);
+        sr1.unregister();
+        e.waitForStep(4, 10000);
+        sr2.unregister();
+        sr3.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/BundleDependencyAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/BundleDependencyAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/BundleDependencyAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/BundleDependencyAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,57 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.BundleDependencyAnnotation;
+import dm.runtime.it.components.Utils;
+
+/**
+ * Use case: Verify Bundle Dependency annotations usage.
+ */
+public class BundleDependencyAnnotationTest extends TestBase {
+    /**
+     * Tests a simple Consumer, which has a BundleDependency over the dependency manager bundle.
+     */
+    public void testBundleDependencyAnnotation() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, BundleDependencyAnnotation.ENSURE_CONSUMER);
+        e.waitForStep(1, 10000);
+        stopBundle(Utils.DM_RUNTIME_IT_COMPONENTS_BSN);
+        e.waitForStep(2, 10000);
+        sr.unregister();
+        startBundle(Utils.DM_RUNTIME_IT_COMPONENTS_BSN);
+    }
+
+    /**
+     * Tests a Bundle Adapter, which adapts the dependency manager bundle to a "ServiceInterface" service.
+     * @throws Throwable 
+     */
+    public void testBundleAdapterServiceAnnotation() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, BundleDependencyAnnotation.ENSURE_ADAPTER);
+        e.waitForStep(3, 10000);
+        e.ensure();
+        sr.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/CompositeAnnotationsTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/CompositeAnnotationsTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/CompositeAnnotationsTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/CompositeAnnotationsTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,44 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.CompositeAnnotations.C1;
+import dm.runtime.it.components.CompositeAnnotations.Dependency1;
+import dm.runtime.it.components.CompositeAnnotations.Dependency2;
+
+/**
+ * Use case: Verify Composite annotated services.
+ */
+public class CompositeAnnotationsTest extends TestBase {
+    public void testComposite() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr1 = register(e, C1.ENSURE);
+        ServiceRegistration sr2 = register(e, Dependency1.ENSURE);
+        ServiceRegistration sr3 = register(e, Dependency2.ENSURE);
+        e.waitForStep(4, 10000);
+        sr3.unregister();
+        sr2.unregister();
+        sr1.unregister();
+        e.waitForStep(12, 10000);
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ExtraServicePropertiesTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ExtraServicePropertiesTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ExtraServicePropertiesTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ExtraServicePropertiesTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,73 @@
+/*
+ * 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.ExtraAdapterServiceProperties;
+import dm.runtime.it.components.ExtraFactoryServiceProperties;
+import dm.runtime.it.components.ExtraServiceProperties;
+
+/**
+ * Use case: Verify the a Service may provide its service properties dynamically from its start method.
+ */
+public class ExtraServicePropertiesTest extends TestBase {
+    /**
+     * Tests if a Service can provide its service properties from its start method.
+     */
+    public void testExtraServiceProperties() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ExtraServiceProperties.ENSURE);
+        e.waitForStep(2, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Tests if a Service instantiated by a Factory can provide its service properties from its start method.
+     */
+    public void testExtraFactoryServiceProperties() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ExtraFactoryServiceProperties.ENSURE);
+        e.waitForStep(3, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Tests if an AdapterService can provide its service properties from its start method.
+     */
+    public void testExtraAdapterServiceProperties() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ExtraAdapterServiceProperties.ENSURE);
+        e.waitForStep(3, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Tests if an AspectService can provide its service properties from its start method.
+     */
+    // TODO
+    public void testExtraAspectServiceProperties() {
+//        Ensure e = new Ensure();
+//        ServiceRegistration sr = register(e, ExtraAspectServiceProperties.ENSURE);
+//        e.waitForStep(3, 10000);
+//        sr.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/FactoryConfigurationAdapterAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/FactoryConfigurationAdapterAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/FactoryConfigurationAdapterAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/FactoryConfigurationAdapterAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,74 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+import junit.framework.Assert;
+
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.FactoryConfigurationAdapterAnnotation.ServiceProvider;
+
+/**
+ * Use case: Verify that an annotated Configuration Factory Adapter Service is properly created when a factory configuration
+ * is created from Config Admin.
+ */
+public class FactoryConfigurationAdapterAnnotationTest extends TestBase {
+    private final static int MAXWAIT = 10000;
+
+    public void testFactoryConfigurationAdapterAnnotation() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ServiceProvider.ENSURE);
+        ConfigurationAdmin cm = (ConfigurationAdmin) context.getService(context.getServiceReference(ConfigurationAdmin.class.getName()));
+        try {
+            // Create a factory configuration in order to instantiate the ServiceProvider
+            org.osgi.service.cm.Configuration cf = cm.createFactoryConfiguration("FactoryPidTest", null);
+            cf.update(new Hashtable() {
+                {
+                    put("foo2", "bar2");
+                }
+            });
+            // Wait for the ServiceProvider activation.
+            e.waitForStep(2, MAXWAIT);
+            // Update conf
+            cf.update(new Hashtable() {
+                {
+                    put("foo2", "bar2_modified");
+                }
+            });
+            // Wait for effective update
+            e.waitForStep(4, MAXWAIT);
+            // Remove configuration.
+            cf.delete();
+            // Check if ServiceProvider has been stopped.
+            e.waitForStep(6, MAXWAIT);
+            e.ensure();
+            sr.unregister();
+        }
+        catch (IOException err) {
+            err.printStackTrace();
+            Assert.fail("can't create factory configuration");
+        }
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4050Test.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4050Test.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4050Test.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4050Test.java Wed May 14 15:51:25 2014
@@ -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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.Felix4050;
+
+/**
+ * Test for FELIX-4050 issue: It validates that component state calculation does not mess up
+ * when an @Init method adds an available dependency using the API, and also returns a Map for
+ * configuring a named dependency.
+ */
+public class Felix4050Test extends TestBase {
+    public void testFelix4050() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, Felix4050.ENSURE);
+        // wait for S to be started
+        e.waitForStep(3, 10000);
+        // remove our sequencer: this will stop S
+        sr.unregister();
+        // ensure that S is stopped and destroyed
+        e.waitForStep(5, 10000);
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4357Test.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4357Test.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4357Test.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/Felix4357Test.java Wed May 14 15:51:25 2014
@@ -0,0 +1,40 @@
+/*
+ * 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.Felix4357;
+
+/**
+ * Test for FELIX-4357 issue: It validates the types of some service component properties
+ * defined with @Property annotation.
+ */
+public class Felix4357Test extends TestBase {
+    public void testPropertiesWithTypes() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, Felix4357.ENSURE);
+        // wait for S to be started
+        e.waitForStep(30, 10000);
+        // remove our sequencer: this will stop S
+        sr.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/MultipleAnnotationsTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/MultipleAnnotationsTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/MultipleAnnotationsTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/MultipleAnnotationsTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,39 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.MultipleAnnotations;
+import dm.runtime.it.components.Utils;
+
+/**
+ * Use case: Verify complex Annotation usage.
+ */
+public class MultipleAnnotationsTest extends TestBase {
+    public void testMultipleAnnotations() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, MultipleAnnotations.ENSURE);
+        e.waitForStep(7, 10000);
+        sr.unregister();
+        e.waitForStep(11, 10000);
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PropagateAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PropagateAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PropagateAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PropagateAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,37 @@
+/*
+ * 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.PropagateAnnotation;
+
+/**
+ * Use case: Verify that dependency "propagate" option is properly propagating properties to provided service.
+ */
+public class PropagateAnnotationTest extends TestBase {
+    public void testServiceDependencyPropagate() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, PropagateAnnotation.ENSURE);
+        e.waitForStep(3, 10000);
+        sr.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PublisherAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PublisherAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PublisherAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/PublisherAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,93 @@
+/*
+ * 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.AdapterServiceTestWithPublisher;
+import dm.runtime.it.components.BundleAdapterServiceTestWithPublisher;
+import dm.runtime.it.components.FactoryConfigurationAdapterServiceTestWithPublisher;
+import dm.runtime.it.components.FactoryServiceTestWthPublisher;
+import dm.runtime.it.components.ResourceAdapterServiceTestWithPublisher;
+import dm.runtime.it.components.ServiceTestWthPublisher;
+
+public class PublisherAnnotationTest extends TestBase {
+    /**
+     * A Service that just registers/unregisters its service, using the @ServiceLifecycle annotation.
+     */
+    public void testServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ServiceTestWthPublisher.ENSURE);
+        e.waitForStep(4, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * A Service instantiated from a FactorySet, and which registers/unregisters its service,
+     * using the @ServiceLifecycle annotation.
+     */
+    public void testFactoryServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, FactoryServiceTestWthPublisher.ENSURE);
+        e.waitForStep(5, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Test an AdapterService which provides its interface using a @ServiceLifecycle.
+     */
+    public void testAdapterServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, AdapterServiceTestWithPublisher.ENSURE);
+        e.waitForStep(6, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Test a BundleAdapterService which provides its interface using a @ServiceLifecycle.
+     */
+    public void testBundleAdapterServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, BundleAdapterServiceTestWithPublisher.ENSURE);
+        e.waitForStep(5, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Test a ResourceAdapterService which provides its interface using a @ServiceLifecycle.
+     */
+    public void TestResourceAdapterServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ResourceAdapterServiceTestWithPublisher.ENSURE);
+        e.waitForStep(5, 10000);
+        sr.unregister();
+    }
+
+    /**
+     * Test a FactoryConfigurationAdapterService which provides its interface using a @ServiceLifecycle.
+     */
+    public void testFactoryAdapterServiceWithPublisher() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, FactoryConfigurationAdapterServiceTestWithPublisher.ENSURE);
+        e.waitForStep(5, 10000);
+        sr.unregister();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ResourceAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ResourceAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ResourceAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ResourceAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,69 @@
+/*
+* 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 dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.ResourceAnnotation;
+
+/**
+ * Use case: Verify Bundle Dependency annotations usage.
+ */
+public class ResourceAnnotationTest extends TestBase {
+    /**
+     * Tests a simple ResourceConsumer
+     * @param context
+     */
+    public void testResourceAnnotation() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ResourceAnnotation.ENSURE_RESOURCE);
+        ServiceRegistration sr2 = register(e, ResourceAnnotation.ENSURE_PROVIDER);
+        sr.unregister();
+        sr2.unregister();
+        e.waitForStep(1, 10000);
+    }
+
+    /**
+     * Tests a simple ResourceConsumer using a class field for resource injection
+     */
+    public void testResourceAnnotationAutoConfig() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ResourceAnnotation.ENSURE_FIELD);
+        ServiceRegistration sr2 = register(e, ResourceAnnotation.ENSURE_PROVIDER);
+        sr.unregister();
+        sr2.unregister();
+        e.waitForStep(1, 10000);
+    }
+
+    /**
+      * Tests a ResourceAdapter
+      * @param context
+      */
+    public void testResourceAdapterAnnotation() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, ResourceAnnotation.ENSURE_ADAPTER);
+        ServiceRegistration sr2 = register(e, ResourceAnnotation.ENSURE_PROVIDER);
+        sr.unregister();
+        sr2.unregister();
+        e.waitForStep(2, 10000);
+        e.ensure();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ServiceFactoryAnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ServiceFactoryAnnotationTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ServiceFactoryAnnotationTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/ServiceFactoryAnnotationTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,71 @@
+/*
+ * 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 dm.runtime.it.tests;
+
+import java.util.Hashtable;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.DependencyManager;
+import dm.annotation.api.Component;
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.ServiceFactoryAnnotation;
+
+public class ServiceFactoryAnnotationTest extends TestBase {
+    private final Ensure m_ensure = new Ensure();
+
+    public void testServiceFactory() {
+        ServiceRegistration sr = register(m_ensure, ServiceFactoryAnnotation.ENSURE);
+
+        DependencyManager m = new DependencyManager(context);
+        // Wait for the factory.
+        m.add(m.createComponent()
+                .setImplementation(this)
+                .add(m.createServiceDependency()
+                        .setService(Set.class,
+                                "(" + Component.FACTORY_NAME + "=" + ServiceFactoryAnnotation.FACTORY + ")")
+                        .setRequired(true).setCallbacks("bindFactory", null)));
+
+        // Check if the test.annotation components have been initialized orderly
+        m_ensure.waitForStep(10, 5000);
+        m.clear();
+        sr.unregister();
+    }
+
+    void bindFactory(Set factory) {
+        // create a service instance with this configuration
+        Hashtable conf = new Hashtable();
+        conf.put("instance.id", "instance");
+        conf.put(".private.param", "private");
+        Assert.assertTrue(factory.add(conf));
+        m_ensure.waitForStep(4, 5000);
+
+        // update the service instance
+        conf.put("instance.modified", "true");
+        Assert.assertFalse(factory.add(conf));
+        m_ensure.waitForStep(7, 5000);
+
+        // remove instance
+        Assert.assertTrue(factory.remove(conf));
+    }
+}

Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/TemporalAnnotationsTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/TemporalAnnotationsTest.java?rev=1594622&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/TemporalAnnotationsTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/TemporalAnnotationsTest.java Wed May 14 15:51:25 2014
@@ -0,0 +1,58 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package dm.runtime.it.tests;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.TemporalAnnotations;
+
+/**
+ * Use case: Verify Temporal Service dependency Annotations usage.
+ */
+public class TemporalAnnotationsTest extends TestBase {
+    public void testTemporalServiceDependency() {
+        Ensure ensure = new Ensure();
+        ServiceRegistration ensureReg = register(ensure, TemporalAnnotations.ENSURE);
+        Dictionary props = new Hashtable() {
+            {
+                put("test", "temporal");
+            }
+        };
+        Runnable r = Ensure.createRunnableStep(ensure, 1);
+        ServiceRegistration sr = context.registerService(Runnable.class.getName(), r, props);
+        ensure.waitForStep(1, 15000);
+        System.out.println("unregistering R");
+        sr.unregister();
+        ensure.step(2);
+        sleep(500);
+        r = Ensure.createRunnableStep(ensure, 3);
+        sr = context.registerService(Runnable.class.getName(), r, props);
+        ensure.waitForStep(3, 15000);
+        sr.unregister();
+        ensure.step(4);
+        sleep(1500);
+        ensure.waitForStep(5, 15000);
+        ensureReg.unregister();
+    }
+}