Fix FELIX-2634 Rename the @Publisher annotation into @Publishes annotation to avoid collision
The @Publisher annotation  is deprecated from now.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1005120 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publisher.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publisher.java
index 0144d03..466d6f0 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publisher.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publisher.java
@@ -27,6 +27,7 @@
  * Be aware that despite is it provided in the annotations jar,
  * it refers to an external handler.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ * @deprecated replaced by Publishes
  */
 @Target(ElementType.FIELD)
 public @interface Publisher {
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publishes.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publishes.java
new file mode 100644
index 0000000..5102df4
--- /dev/null
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/event/Publishes.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ipojo.handlers.event;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+
+/**
+ * Event Admin Publisher handler.
+ * Be aware that despite is it provided in the annotations jar,
+ * it refers to an external handler.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Target(ElementType.FIELD)
+public @interface Publishes {
+
+    /**
+     * Sets the publisher name.
+     */
+    String name();
+
+    /**
+     * Sets topics on which event are sent.
+     * The topics are separated by a ',' such as in
+     * "foo, bar".
+     * Default : no topics (configured in the instance configuration)
+     */
+    String topics() default "";
+
+    /**
+     * Enables/Disables synchronous sending.
+     * Default : false (asynchronous)
+     */
+    boolean synchronous() default false;
+
+    /**
+     * Sets the data key in which the data is
+     * put.
+     * Default : user.data
+     */
+    String dataKey() default "user.data";
+
+}
diff --git a/ipojo/handler/eventadmin/metadata.xml b/ipojo/handler/eventadmin/metadata.xml
index 945451e..69b340b 100644
--- a/ipojo/handler/eventadmin/metadata.xml
+++ b/ipojo/handler/eventadmin/metadata.xml
@@ -6,9 +6,9 @@
 	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
@@ -25,10 +25,17 @@
 			<property field="m_topics" name="event.topics"/>
 		</provides>
 	</handler>
-	
+
+	<!-- This handler is duplicated to support the 'Publishes' annotation -->
 	<handler classname="org.apache.felix.ipojo.handlers.event.publisher.EventAdminPublisherHandler"
 		name="publisher"
 		namespace="org.apache.felix.ipojo.handlers.event">
 		<requires field="m_ea"/>
 	</handler>
+
+	<handler classname="org.apache.felix.ipojo.handlers.event.publisher.EventAdminPublisherHandler"
+		name="publishes"
+		namespace="org.apache.felix.ipojo.handlers.event">
+		<requires field="m_ea"/>
+	</handler>
 </ipojo>
\ No newline at end of file
diff --git a/ipojo/handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/publisher/EventAdminPublisherHandler.java b/ipojo/handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/publisher/EventAdminPublisherHandler.java
index 8880bf7..2338be7 100644
--- a/ipojo/handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/publisher/EventAdminPublisherHandler.java
+++ b/ipojo/handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/publisher/EventAdminPublisherHandler.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -36,7 +36,7 @@
 
 /**
  * Event Publisher Handler.
- * 
+ *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class EventAdminPublisherHandler extends PrimitiveHandler {
@@ -73,7 +73,7 @@
 
     /**
      * Initializes the component type.
-     * 
+     *
      * @param cd the component type description to populate
      * @param metadata the component type metadata
      * @throws ConfigurationException if the given metadata is incorrect.
@@ -93,6 +93,12 @@
 
         // Get Metadata publishers
         Element[] publishers = metadata.getElements("publisher", NAMESPACE);
+
+        // if publisher is null, look for 'publishes' elements
+        if (publishers == null  || publishers.length == 0) {
+        	publishers = metadata.getElements("publishes", NAMESPACE);
+        }
+
         if (publishers != null) {
 
             // Maps used to check name and field are unique
@@ -139,7 +145,7 @@
 
     /**
      * Constructor.
-     * 
+     *
      * @param metadata the component type metadata
      * @param conf the instance configuration
      * @throws ConfigurationException if one event publication is not correct
@@ -159,6 +165,11 @@
         // Get Metadata publishers
         Element[] publishers = metadata.getElements("publisher", NAMESPACE);
 
+        // if publisher is null, look for 'publishes' elements
+        if (publishers == null  || publishers.length == 0) {
+        	publishers = metadata.getElements("publishes", NAMESPACE);
+        }
+
         if (publishers != null) {
             // then check publishers are well formed and fill the publishers'
             // map
@@ -205,7 +216,7 @@
 
     /**
      * Starts the handler instance.
-     * 
+     *
      * This method does nothing.
      */
     // @Override
@@ -214,7 +225,7 @@
 
     /**
      * Stops the handler instance.
-     * 
+     *
      * This method does nothing.
      */
     // @Override
@@ -224,11 +235,11 @@
     /**
      * Field interceptor callback. This method is called when the component
      * attempt to one of its Publisher field.
-     * 
+     *
      * @param pojo the accessed field
      * @param fieldName the name of the accessed field
      * @param value the value of the field (useless here)
-     * 
+     *
      * @return the Publisher associated with the accessed field's name
      */
     // @Override
@@ -245,7 +256,7 @@
     /**
      * This method is called by managed publishers to obtain the current
      * EventAdmin service.
-     * 
+     *
      * @return the current EventAdmin service.
      */
     public EventAdmin getEventAdminService() {
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
index c768413..242a423 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
@@ -1,4 +1,4 @@
-/* 

+/*

  * 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

@@ -40,7 +40,7 @@
         ots.addTestSuite(PolicyDependency.class);

         ots.addTestSuite(FilteredDependency.class);

         ots.addTestSuite(RankedDependency.class);

-        

+

         // External handler annotations

         ots.addTestSuite(TemporalDependencies.class);

         ots.addTestSuite(JMX.class);

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java
index 4262f94..0993fa0 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java
@@ -7,24 +7,30 @@
 public class EventAdmin extends OSGiTestCase {
     String type = "org.apache.felix.ipojo.test.scenarios.component.event.PubSub";
     String deprecated = "org.apache.felix.ipojo.test.scenarios.component.event.PubSubDeprecated";
+    String publishes = "org.apache.felix.ipojo.test.scenarios.component.event.PubSubWithPublishes";
 
     String namespace = "org.apache.felix.ipojo.handlers.event";
 
     Element component;
     Element componentDeprecated;
+    Element componentWithPublishes;
     private IPOJOHelper helper;
 
     public void setUp() {
         helper = new IPOJOHelper(this);
         component = helper.getMetadata(type);
         componentDeprecated = helper.getMetadata(deprecated);
+        componentWithPublishes = helper.getMetadata(publishes);
         assertNotNull("Check component", component);
+        assertNotNull("Check deprecated", componentDeprecated);
+        assertNotNull("Check publishes", componentWithPublishes);
+
     }
 
     public void tearDown() {
         component = null;
         componentDeprecated = null;
-
+        componentWithPublishes = null;
     }
 
     public void testP1() {
@@ -37,6 +43,16 @@
         assertNull("Check data_key", elem.getAttribute("dataKey"));
     }
 
+    public void testP1WithPublishes() {
+        //P1, synchronous
+        Element elem = getPublishesByName("p1");
+        checkPublishes(elem);
+        assertNull("Check topics", elem.getAttribute("topics"));
+        assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
+        assertEquals("Check field", "publisher1", elem.getAttribute("field"));
+        assertNull("Check data_key", elem.getAttribute("dataKey"));
+    }
+
     public void testP1Deprecated() {
         //P1, synchronous
         Element elem = getDeprecatedElementByName("p1");
@@ -57,6 +73,16 @@
         assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
     }
 
+    public void testP2WithPublishes() {
+        //name="p2", synchronous=false, topics="foo,bar", data_key="data"
+        Element elem = getPublishesByName("p2");
+        checkPublishes(elem);
+        assertEquals("Check topics (" + elem.getAttribute("topics")+")", "foo,bar", elem.getAttribute("topics"));
+        assertEquals("Check synchronous", "false", elem.getAttribute("synchronous"));
+        assertEquals("Check field", "publisher2", elem.getAttribute("field"));
+        assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
+    }
+
     public void testP2Deprecated() {
         //name="p2", synchronous=false, topics="foo,bar", data_key="data"
         Element elem = getDeprecatedElementByName("p2");
@@ -77,6 +103,16 @@
         assertNull("Check data_key", elem.getAttribute("dataKey"));
     }
 
+    public void testWithPublishesP3() {
+        //name="p3", synchronous=true, topics="bar"
+        Element elem = getPublishesByName("p3");
+        checkPublishes(elem);
+        assertEquals("Check topics", "bar" ,elem.getAttribute("topics"));
+        assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
+        assertEquals("Check field", "publisher3", elem.getAttribute("field"));
+        assertNull("Check data_key", elem.getAttribute("dataKey"));
+    }
+
     public void testP3Deprecated() {
         //name="p3", synchronous=true, topics="bar"
         Element elem = getDeprecatedElementByName("p3");
@@ -165,6 +201,16 @@
         return null;
     }
 
+    public Element getPublishesByName(String name) {
+        Element [] elems = componentWithPublishes.getElements();
+        for (int i = 0; i < elems.length; i++) {
+            if (elems[i].containsAttribute("name") && elems[i].getAttribute("name").equals(name)) {
+                return elems[i];
+            }
+        }
+        return null;
+    }
+
     public Element getDeprecatedElementByName(String name) {
         Element [] elems = componentDeprecated.getElements();
         for (int i = 0; i < elems.length; i++) {
@@ -192,4 +238,12 @@
         assertEquals("Elem is not a publisher : bad name", "publisher", nm);
     }
 
+    public void checkPublishes(Element elem) {
+        assertNotNull("Can't check publisher : null element",elem);
+        String ns = elem.getNameSpace();
+        String nm = elem.getName();
+        assertEquals("Elem is not a publisher : bad namespace", namespace, ns);
+        assertEquals("Elem is not a publisher : bad name", "publishes", nm);
+    }
+
 }
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java
new file mode 100644
index 0000000..a40eb7e
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java
@@ -0,0 +1,38 @@
+package org.apache.felix.ipojo.test.scenarios.component.event;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.handlers.event.Publishes;
+import org.apache.felix.ipojo.handlers.event.Subscriber;
+import org.osgi.service.event.Event;
+
+
+@Component
+public class PubSubWithPublishes {
+    @Publishes(name="p1", synchronous=true)
+    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1;
+
+    @Publishes(name="p2", synchronous=false, topics="foo,bar", dataKey="data")
+    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2;
+
+    @Publishes(name="p3", synchronous=true, topics="bar")
+    org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3;
+
+    @Subscriber(name="s1", dataKey="data")
+    public void receive1(Object foo) {
+        // Nothing
+    }
+
+    @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)")
+    public void receive2(Event foo) {
+        // Nothing
+    }
+
+
+    @Subscriber(name="s3", topics="foo", dataKey="data", dataType="java.lang.String")
+    public void receive3(String foo) {
+        // Nothing
+    }
+
+
+
+}
diff --git a/ipojo/tests/handler/eventadmin/pom.xml b/ipojo/tests/handler/eventadmin/pom.xml
index 9a7785b..94234ec 100644
--- a/ipojo/tests/handler/eventadmin/pom.xml
+++ b/ipojo/tests/handler/eventadmin/pom.xml
@@ -30,37 +30,44 @@
     <packaging>bundle</packaging>

     <name>iPOJO Event Admin Handler Test Suite</name>

     <artifactId>tests.eventadmin.handler</artifactId>

-    <dependencies>

-        <dependency>

-            <groupId>org.apache.felix</groupId>

-            <artifactId>org.apache.felix.ipojo</artifactId>

-            <version>1.7.0-SNAPSHOT</version>

-        </dependency>

-        <dependency>

-            <groupId>org.osgi</groupId>

-            <artifactId>org.osgi.core</artifactId>

-        </dependency>

-        <dependency>

-            <groupId>org.apache.felix</groupId>

-            <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>

-            <version>1.7.0-SNAPSHOT</version>

-        </dependency>

-        <dependency>

-            <groupId>junit</groupId>

-            <artifactId>junit</artifactId>

-            <version>3.8.1</version>

-        </dependency>

-        <dependency>

-            <groupId>org.apache.felix</groupId>

-            <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

-            <version>1.1.0-SNAPSHOT</version>

-        </dependency>

-        <dependency>

-            <groupId>org.osgi</groupId>

-            <artifactId>org.osgi.compendium</artifactId>

-            <version>4.0.0</version>

-        </dependency>

-    </dependencies>

+

+	<dependencies>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.ipojo</artifactId>

+			<version>1.7.0-SNAPSHOT</version>

+		</dependency>

+		<dependency>

+			<groupId>org.osgi</groupId>

+			<artifactId>org.osgi.core</artifactId>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>

+			<version>1.7.0-SNAPSHOT</version>

+		</dependency>

+		<dependency>

+			<groupId>junit</groupId>

+			<artifactId>junit</artifactId>

+			<version>3.8.1</version>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

+			<version>1.1.0-SNAPSHOT</version>

+		</dependency>

+		<dependency>

+			<groupId>org.osgi</groupId>

+			<artifactId>org.osgi.compendium</artifactId>

+			<version>4.0.0</version>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.eventadmin</artifactId>

+			<version>1.2.2</version>

+			<scope>test</scope>

+		</dependency>

+	</dependencies>

     <build>

         <plugins>

             <plugin>

@@ -91,6 +98,26 @@
                     </execution>

                 </executions>

             </plugin>

+            <plugin>

+		        <groupId>org.apache.felix</groupId>

+		        <artifactId>maven-junit4osgi-plugin

+		        </artifactId>

+		        <version>1.1.0-SNAPSHOT</version>

+		        <executions>

+		          <execution>

+		            <goals>

+		              <goal>test</goal>

+		            </goals>

+		            <configuration>

+		              <hideOutputs>false</hideOutputs>

+		              <logService>false</logService>

+		              <configuration>

+		              <org.osgi.http.port>8083</org.osgi.http.port>

+		              </configuration>

+		            </configuration>

+		          </execution>

+		        </executions>

+		     </plugin>

         </plugins>

     </build>

 </project>

diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java
index 2f717c9..7eddfca 100644
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java
+++ b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java
@@ -43,6 +43,7 @@
         ots.addTestSuite(BadTests.class);
         ots.addTestSuite(GoodTests.class);
         ots.addTestSuite(GoodTestsWithNewAttributes.class);
+        ots.addTestSuite(PublishesTests.class);
         return ots;
     }
 
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java
new file mode 100644
index 0000000..0e3f6e9
--- /dev/null
+++ b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java
@@ -0,0 +1,766 @@
+/*
+ * 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.ipojo.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.MissingHandlerException;
+import org.apache.felix.ipojo.UnacceptableConfiguration;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.donut.Donut;
+import org.apache.felix.ipojo.test.donut.DonutConsumer;
+import org.apache.felix.ipojo.test.donut.DonutProvider;
+import org.apache.felix.ipojo.test.donut.EventTracker;
+import org.apache.felix.ipojo.test.util.EahTestUtils;
+import org.apache.felix.ipojo.test.util.IPojoTestUtils;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.event.Event;
+
+/**
+ * Test the good behaviour of the EventAdminHandler.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class PublishesTests extends OSGiTestCase {
+
+    /**
+     * The number of providers to test.
+     */
+    private static final int NUMBER_OF_PROVIDERS = 6;
+
+    /**
+     * The number of providers using the event admin handler to test.
+     */
+    private static final int NUMBER_OF_EAH_PROVIDERS = 4;
+
+    /**
+     * The number of consumers to test.
+     */
+    private static final int NUMBER_OF_CONSUMERS = 6;
+
+    /**
+     * The number of synchronous providers to test.
+     */
+    private static final int NUMBER_OF_SYNCHRONOUS_PROVIDERS = 3;
+
+    /**
+     * The number of slow consumers to test.
+     */
+    private static final int NUMBER_OF_QUICK_CONSUMERS = 3;
+
+    /**
+     * The list of topics to test.
+     */
+    private static final String[] TOPICS_LIST = { "foo", "bar", "nut",
+        "foo,bar", "bar,nut", "foo,nut", "foo,bar,nut" };
+
+    /**
+     * The utility class instance.
+     */
+    public EahTestUtils m_utils;
+
+    /**
+     * The providers' instances.
+     */
+    private ComponentInstance[] m_providersInstances;
+
+    /**
+     * The providers' service references.
+     */
+    private ServiceReference[] m_providersServices;
+
+    /**
+     * The providers' services.
+     */
+    private DonutProvider[] m_providers;
+
+    /**
+     * The synchronous providers' services.
+     */
+    private DonutProvider[] m_synchronousProviders;
+
+    /**
+     * The instances of providers that uses the event admin handler.
+     */
+    private ComponentInstance[] m_eahProvidersInstances;
+
+    /**
+     * The services of the providers that uses the event admin handler.
+     */
+    private DonutProvider[] m_eahProviders;
+
+    /**
+     * The synchronous donut event provider service.
+     */
+    private DonutProvider m_synchronousDonutEventProvider;
+
+    /**
+     * The consumers' instances.
+     */
+    private ComponentInstance[] m_consumersInstances;
+
+    /**
+     * The consumers' service references.
+     */
+    private ServiceReference[] m_consumersServices;
+
+    /**
+     * The consumers' services.
+     */
+    private DonutConsumer[] m_consumers;
+
+    /**
+     * The slow consumers' services.
+     */
+    private DonutConsumer[] m_quickConsumers;
+
+    /**
+     * The event tracker' instances.
+     */
+    private ComponentInstance m_eventTrackerInstance;
+
+    /**
+     * The event tracker' service references.
+     */
+    private ServiceReference m_eventTrackerService;
+
+    /**
+     * The event tracker service.
+     */
+    private EventTracker m_eventTracker;
+
+    /**
+     * The filtered consumers' instances.
+     */
+    private ComponentInstance[] m_filteredConsumersInstances;
+
+    /**
+     * The filtered consumers' service references.
+     */
+    private ServiceReference[] m_filteredConsumersServices;
+
+    /**
+     * The filtered consumers' services.
+     */
+    private DonutConsumer[] m_filteredConsumers;
+
+    /**
+     * The providers' instances with specified topics.
+     */
+    private ComponentInstance[] m_topicsProvidersInstances;
+
+    /**
+     * The providers' service references with specified topics.
+     */
+    private ServiceReference[] m_topicsProvidersServices;
+
+    /**
+     * The providers' service with specified topics.
+     */
+    private DonutProvider[] m_topicsProviders;
+
+    /**
+     * The provider that send donuts on the "foo" topic.
+     */
+    private DonutProvider m_fooProvider;
+
+    /**
+     * The provider that send donuts on the "bar" topic.
+     */
+    private DonutProvider m_barProvider;
+
+    /**
+     * The provider that send donuts on the "nut" topic.
+     */
+    private DonutProvider m_nutProvider;
+
+    /**
+     * The provider that send donuts on the "foo,bar" topics.
+     */
+    private DonutProvider m_fooBarProvider;
+
+    /**
+     * The provider that send donuts on the "bar,nut" topics.
+     */
+    private DonutProvider m_barNutProvider;
+
+    /**
+     * The provider that send donuts on the "foo,nut" topics.
+     */
+    private DonutProvider m_fooNutProvider;
+
+    /**
+     * The provider that send donuts on the "foo,bar,nut" topics.
+     */
+    private DonutProvider m_fooBarNutProvider;
+
+    /**
+     * The consumers' instances with specified topics.
+     */
+    private ComponentInstance[] m_topicsConsumersInstances;
+
+    /**
+     * The consumers' service references with specified topics.
+     */
+    private ServiceReference[] m_topicsConsumersServices;
+
+    /**
+     * The consumers' service references with specified topics.
+     */
+    private DonutConsumer[] m_topicsConsumers;
+
+    /**
+     * The consumer that receive donuts on the "foo" topic.
+     */
+    private DonutConsumer m_fooConsumer;
+
+    /**
+     * The consumer that receive donuts on the "bar" topic.
+     */
+    private DonutConsumer m_barConsumer;
+
+    /**
+     * The consumer that receive donuts on the "nut" topic.
+     */
+    private DonutConsumer m_nutConsumer;
+
+    /**
+     * The consumer that receive donuts on the "foo,bar" topics.
+     */
+    private DonutConsumer m_fooBarConsumer;
+
+    /**
+     * The consumer that receive donuts on the "bar,nut" topics.
+     */
+    private DonutConsumer m_barNutConsumer;
+
+    /**
+     * The consumer that receive donuts on the "foo,nut" topics.
+     */
+    private DonutConsumer m_fooNutConsumer;
+
+    /**
+     * The consumer that receive donuts on the "foo,bar,nut" topics.
+     */
+    private DonutConsumer m_fooBarNutConsumer;
+
+    /**
+     * Initialization before test cases.
+     *
+     * Create all the instances
+     *
+     * @throws UnacceptableConfiguration
+     *             something bad happened
+     * @throws MissingHandlerException
+     *             something bad happened
+     * @throws ConfigurationException
+     *             something bad happened
+     *
+     */
+    public void setUp()
+        throws UnacceptableConfiguration, MissingHandlerException,
+        ConfigurationException {
+
+        m_utils = new EahTestUtils(getContext());
+        Dictionary properties = new Hashtable();
+
+        // All the providers
+        m_providersInstances = new ComponentInstance[NUMBER_OF_PROVIDERS];
+        m_providersServices = new ServiceReference[NUMBER_OF_PROVIDERS];
+        m_providers = new DonutProvider[NUMBER_OF_PROVIDERS];
+        m_synchronousProviders = new DonutProvider[NUMBER_OF_SYNCHRONOUS_PROVIDERS];
+        m_eahProviders = new DonutProvider[NUMBER_OF_EAH_PROVIDERS];
+        m_eahProvidersInstances = new ComponentInstance[NUMBER_OF_EAH_PROVIDERS];
+        m_topicsProvidersInstances = new ComponentInstance[TOPICS_LIST.length];
+        m_topicsProvidersServices = new ServiceReference[TOPICS_LIST.length];
+        m_topicsProviders = new DonutProvider[TOPICS_LIST.length];
+
+        // Create the (asynchronous) donut provider
+        properties.put("instance.name","asynchronous donut provider");
+        m_providersInstances[0] = m_utils.getDonutProviderUsingPublishesFactory()
+                .createComponentInstance(properties);
+
+        // Create the synchronous donut provider
+        properties = new Hashtable();
+        properties.put("instance.name","synchronous donut provider");
+        m_providersInstances[1] = m_utils.getSynchronousDonutProviderFactory()
+                .createComponentInstance(properties);
+
+        // Create the (asynchronous) donut event provider
+        properties = new Hashtable();
+        properties.put("instance.name","asynchronous donut event provider");
+        m_providersInstances[2] = m_utils.getDonutEventProviderFactory()
+                .createComponentInstance(properties);
+
+        // Create the synchronous donut event provider
+        properties = new Hashtable();
+        properties.put("instance.name","synchronous donut event provider");
+        m_providersInstances[3] = m_utils
+                .getSynchronousDonutEventProviderFactory()
+                .createComponentInstance(properties);
+
+        // Create the (asynchronous) event provider
+        properties = new Hashtable();
+        properties.put("instance.name","asynchronous event provider");
+        m_providersInstances[4] = m_utils.getEventProviderFactory()
+                .createComponentInstance(properties);
+
+        // Create the synchronous event provider
+        properties = new Hashtable();
+        properties.put("instance.name","synchronous event provider");
+        m_providersInstances[5] = m_utils.getSynchronousEventProviderFactory()
+                .createComponentInstance(properties);
+
+        // Get all the services references
+        for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
+            m_providersServices[i] = IPojoTestUtils.getServiceReferenceByName(
+                    getContext(), DonutProvider.class.getName(),
+                    m_providersInstances[i].getInstanceName());
+            m_providers[i] = (DonutProvider) getContext()
+                    .getService(m_providersServices[i]);
+        }
+        m_synchronousProviders[0] = m_providers[1];
+        m_synchronousProviders[1] = m_providers[3];
+        m_synchronousProviders[2] = m_providers[5];
+        m_eahProviders[0] = m_providers[0];
+        m_eahProviders[1] = m_providers[1];
+        m_eahProviders[2] = m_providers[2];
+        m_eahProviders[3] = m_providers[3];
+        m_eahProvidersInstances[0] = m_providersInstances[0];
+        m_eahProvidersInstances[1] = m_providersInstances[1];
+        m_eahProvidersInstances[2] = m_providersInstances[2];
+        m_eahProvidersInstances[3] = m_providersInstances[3];
+        m_synchronousDonutEventProvider = m_providers[3];
+
+        // All the consumers
+        m_consumersInstances = new ComponentInstance[NUMBER_OF_CONSUMERS];
+        m_consumersServices = new ServiceReference[NUMBER_OF_CONSUMERS];
+        m_consumers = new DonutConsumer[NUMBER_OF_CONSUMERS];
+        m_quickConsumers = new DonutConsumer[NUMBER_OF_QUICK_CONSUMERS];
+        m_filteredConsumersInstances = new ComponentInstance[Donut.FLAVOURS.length];
+        m_filteredConsumersServices = new ServiceReference[Donut.FLAVOURS.length];
+        m_filteredConsumers = new DonutConsumer[Donut.FLAVOURS.length];
+        m_topicsConsumersInstances = new ComponentInstance[TOPICS_LIST.length];
+        m_topicsConsumersServices = new ServiceReference[TOPICS_LIST.length];
+        m_topicsConsumers = new DonutConsumer[TOPICS_LIST.length];
+
+        // Create the (quick) donut consumer
+        properties = new Hashtable();
+        properties.put("instance.name","quick donut consumer");
+        m_consumersInstances[0] = m_utils.getDonutConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Create the (quick) donut event consumer
+        properties = new Hashtable();
+        properties.put("instance.name","quick donut event consumer");
+        m_consumersInstances[1] = m_utils.getDonutEventConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Create the (quick) event consumer
+        properties = new Hashtable();
+        properties.put("instance.name","quick event consumer");
+        m_consumersInstances[2] = m_utils.getEventConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Create the slow donut consumer
+        properties = new Hashtable();
+        properties.put("slow", Boolean.TRUE);
+        properties.put("instance.name","slow donut consumer");
+        m_consumersInstances[3] = m_utils.getDonutConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Create the slow donut event consumer
+        properties = new Hashtable();
+        properties.put("instance.name","slow donut event consumer");
+        properties.put("slow", Boolean.TRUE);
+        m_consumersInstances[4] = m_utils.getDonutEventConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Create the slow event consumer
+        properties = new Hashtable();
+        properties.put("instance.name","slow event consumer");
+        properties.put("slow", Boolean.TRUE);
+        m_consumersInstances[5] = m_utils.getEventConsumerFactory()
+                .createComponentInstance(properties);
+
+        // Get all the services references
+        for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
+            m_consumersServices[i] = IPojoTestUtils.getServiceReferenceByName(
+                    getContext(), DonutConsumer.class.getName(),
+                    m_consumersInstances[i].getInstanceName());
+            m_consumers[i] = (DonutConsumer) getContext()
+                    .getService(m_consumersServices[i]);
+        }
+        m_quickConsumers[0] = m_consumers[0];
+        m_quickConsumers[1] = m_consumers[1];
+        m_quickConsumers[2] = m_consumers[2];
+
+        // Create the event tracker
+        properties = new Hashtable();
+        properties.put("instance.name","event tracker");
+        m_eventTrackerInstance = m_utils.getEventTrackerFactory()
+                .createComponentInstance(properties);
+        m_eventTrackerService = IPojoTestUtils.getServiceReferenceByName(
+                getContext(), EventTracker.class.getName(), m_eventTrackerInstance
+                        .getInstanceName());
+        m_eventTracker = (EventTracker) getContext()
+                .getService(m_eventTrackerService);
+
+        // Create the filtered consumer
+        Dictionary filter = new Hashtable();
+        for (int i = 0; i < Donut.FLAVOURS.length; i++) {
+            String flavour = Donut.FLAVOURS[i];
+            properties = new Hashtable();
+            filter.put("donut-event-subscriber", "(flavour=" + flavour + ")");
+            properties.put("instance.name",flavour + " donut consumer");
+            properties.put("event.filter", filter);
+            m_filteredConsumersInstances[i] = m_utils
+                    .getDonutEventConsumerFactory().createComponentInstance(
+                            properties);
+            m_filteredConsumersServices[i] = IPojoTestUtils
+                    .getServiceReferenceByName(getContext(), DonutConsumer.class
+                            .getName(), m_filteredConsumersInstances[i]
+                            .getInstanceName());
+            m_filteredConsumers[i] = (DonutConsumer) getContext()
+                    .getService(m_filteredConsumersServices[i]);
+        }
+
+        // Create the providers and consumers selling and receiving donuts on
+        // specific topics
+        Dictionary topics = new Hashtable();
+        for (int i = 0; i < TOPICS_LIST.length; i++) {
+            String topicsString = TOPICS_LIST[i];
+            properties = new Hashtable();
+            // Create provider
+            topics.put("donut-publisher", topicsString);
+            properties.put("event.topics", topics);
+            properties.put("instance.name",topicsString + " donut provider");
+            m_topicsProvidersInstances[i] = m_utils
+                    .getSynchronousDonutProviderFactory()
+                    .createComponentInstance(properties);
+            m_topicsProvidersServices[i] = IPojoTestUtils
+                    .getServiceReferenceByName(getContext(), DonutProvider.class
+                            .getName(), m_topicsProvidersInstances[i]
+                            .getInstanceName());
+            m_topicsProviders[i] = (DonutProvider) getContext()
+                    .getService(m_topicsProvidersServices[i]);
+
+            // Create consumer
+            properties = new Hashtable();
+            topics.put("donut-subscriber", topicsString);
+            properties.put("event.topics", topics);
+            properties.put("instance.name",topicsString + " donut consumer");
+
+            m_topicsConsumersInstances[i] = m_utils.getDonutConsumerFactory()
+                    .createComponentInstance(properties);
+            m_topicsConsumersServices[i] = IPojoTestUtils
+                    .getServiceReferenceByName(getContext(), DonutConsumer.class
+                            .getName(), m_topicsConsumersInstances[i]
+                            .getInstanceName());
+            m_topicsConsumers[i] = (DonutConsumer) getContext()
+                    .getService(m_topicsConsumersServices[i]);
+            topics.remove("donut-subscriber");
+        }
+
+        m_fooProvider = m_topicsProviders[0];
+        m_barProvider = m_topicsProviders[1];
+        m_nutProvider = m_topicsProviders[2];
+        m_fooBarProvider = m_topicsProviders[3];
+        m_barNutProvider = m_topicsProviders[4];
+        m_fooNutProvider = m_topicsProviders[5];
+        m_fooBarNutProvider = m_topicsProviders[6];
+        m_fooConsumer = m_topicsConsumers[0];
+        m_barConsumer = m_topicsConsumers[1];
+        m_nutConsumer = m_topicsConsumers[2];
+        m_fooBarConsumer = m_topicsConsumers[3];
+        m_barNutConsumer = m_topicsConsumers[4];
+        m_fooNutConsumer = m_topicsConsumers[5];
+        m_fooBarNutConsumer = m_topicsConsumers[6];
+
+    }
+
+    /**
+     * Creates a subscriber listening on a pattern topic (ending with '*').
+     * @throws ConfigurationException something bad happened.
+     * @throws MissingHandlerException something bad happened.
+     * @throws UnacceptableConfiguration something bad happened.
+     */
+    public void testSubscriberWithPatternTopic() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+    	Dictionary properties = new Hashtable();
+    	Dictionary topics = new Hashtable();
+
+        // Create the donut consumer instance, listening on a pattern topic
+        properties.put("instance.name","subscriber with pattern topic");
+        topics.put("donut-subscriber", "a/pattern/topic/*");
+        properties.put("event.topics", topics);
+
+        ComponentInstance instance = m_utils.getDonutConsumerFactory()
+                .createComponentInstance(properties);
+        instance.dispose();
+    }
+
+    /**
+     * Test the event handler reliability by sending events with all kinds of
+     * publisher and check they are received by all kinds of subscriber.
+     */
+    public void testReliability() {
+
+        // Flush donut list for each consumer
+        for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
+            m_consumers[i].clearDonuts();
+        }
+
+        // Send a lot of donut with each provider
+        List sentDonuts = new ArrayList(NUMBER_OF_PROVIDERS
+                * EahTestUtils.NUMBER_OF_TESTS);
+        for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
+            for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
+                sentDonuts.add(m_providers[i].sellDonut());
+            }
+        }
+
+        // Wait a respectable amount of time
+        EahTestUtils.sleep(EahTestUtils.BLACK_LIST_TIME
+                + EahTestUtils.A_LONG_TIME);
+
+        // Collect all received donuts for each consumer
+        for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
+            List receivedDonuts = Arrays.asList(m_consumers[i].getAllDonuts());
+            assertEquals(
+                    "The number of received donuts must be the same as the number of sent donuts.",
+                    sentDonuts.size(), receivedDonuts.size());
+            assertTrue("The receiver must have eaten all sent donuts.",
+                    receivedDonuts.containsAll(sentDonuts));
+        }
+    }
+
+    /**
+     * Test the synchronism of event sending for the component.
+     *
+     * This test consists to send synchronously a big amount of donuts and to
+     * check immediately if it has been received (by all quick consumers).
+     */
+    public void testSynchronism() {
+
+        // Flush donut list for quick consumers
+        for (int i = 0; i < NUMBER_OF_QUICK_CONSUMERS; i++) {
+            m_quickConsumers[i].clearDonuts();
+        }
+
+        // Send a lot of donuts and check they are immediately received.
+        Donut sentDonut;
+        Donut receivedDonut;
+        for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
+            for (int j = 0; j < NUMBER_OF_SYNCHRONOUS_PROVIDERS; j++) {
+                sentDonut = m_synchronousProviders[j].sellDonut();
+                for (int k = 0; k < NUMBER_OF_QUICK_CONSUMERS; k++) {
+                    receivedDonut = m_quickConsumers[k].getDonut();
+                    assertEquals(
+                            "The donut must have been received immediately and be the be the same as the sent one.",
+                            sentDonut, receivedDonut);
+                }
+            }
+        }
+    }
+
+    /**
+     * Test that the received events contains the instance name of the sender.
+     */
+    public void testInstanceName() {
+
+        // Flush event list of the event tracker
+        m_eventTracker.clearEvents();
+
+        // Check that the publishes handler is here
+        HandlerFactory[] handlers = IPojoTestUtils.getHandlerFactories(context);
+        for (int i = 0; i < handlers.length; i++) {
+            String name = handlers[i].getHandlerName();
+            if ("composite".equals(handlers[i].getType())) {
+                name = name + " [composite]";
+            }
+            if (handlers[i].getMissingHandlers().size() == 0) {
+                System.out.println("Handler " + name + " (VALID)");
+            } else {
+            	System.out.println("Handler " + name + " (INVALID : " + handlers[i].getMissingHandlers() + ")");
+            }
+        }
+
+        Factory factory = IPojoTestUtils.getFactoryByName(context, "donut-provider-publishes");
+        assertNotNull(factory);
+        System.out.println(factory.getDescription());
+
+        // Send donuts and check the sender instance name
+        Event receivedEvent;
+        for (int i = 0; i < NUMBER_OF_EAH_PROVIDERS; i++) {
+            m_eahProviders[i].sellDonut();
+            receivedEvent = m_eventTracker.waitForEvent();
+            assertEquals(
+                    "The instance name property of the received message must be the same as the sender instance name.",
+                    m_eahProvidersInstances[i].getInstanceName(), receivedEvent
+                            .getProperty("publisher.instance.name"));
+        }
+    }
+
+    /**
+     * Test the event filtering.
+     *
+     * This test send donuts with different flavours. Each filtered consumer
+     * must receive only a certain kind of donut. Of course, all donuts must
+     * have been received too.
+     */
+    public void testFilters() {
+
+        // The sent donuts, sorted by flavour
+        List[] sentDonuts = new List[Donut.FLAVOURS.length];
+
+        // Flush donut list for each filtered consumer
+        for (int i = 0; i < Donut.FLAVOURS.length; i++) {
+            m_filteredConsumers[i].clearDonuts();
+            sentDonuts[i] = new ArrayList(EahTestUtils.NUMBER_OF_TESTS
+                    / Donut.FLAVOURS.length);
+        }
+
+        // Send donuts
+        for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
+            Donut donut = m_synchronousDonutEventProvider.sellDonut();
+            sentDonuts[EahTestUtils.flavourIndex(donut.getFlavour())]
+                    .add(donut);
+        }
+
+        // Check the received donuts
+        for (int i = 0; i < Donut.FLAVOURS.length; i++) {
+            Donut[] receivedDonuts = m_filteredConsumers[i].getAllDonuts();
+            assertEquals(
+                    "The number of received donuts must be the same as the number of sent donuts with the matching flavour.",
+                    sentDonuts[i].size(), receivedDonuts.length);
+            assertTrue(
+                    "The receiver must have eaten all sent donuts matching the wanted flavour.",
+                    Arrays.asList(receivedDonuts).containsAll(sentDonuts[i]));
+        }
+
+    }
+
+    /**
+     * Test the event topic.
+     *
+     * This test send donuts on several topics. Each consumer (who listens to
+     * one or several topics) must receive donuts sent on his specifics topics.
+     */
+    public void testTopics() {
+
+        // The sent donuts, sorted by topic
+        int foos = 0;
+        int bars = 0;
+        int nuts = 0;
+
+        // Flush consumers
+        m_fooConsumer.clearDonuts();
+        m_barConsumer.clearDonuts();
+        m_nutConsumer.clearDonuts();
+        m_fooBarConsumer.clearDonuts();
+        m_barNutConsumer.clearDonuts();
+        m_fooNutConsumer.clearDonuts();
+        m_fooBarNutConsumer.clearDonuts();
+
+        // Send donuts
+        for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
+            m_fooProvider.sellDonut();
+            foos++;
+
+            m_barProvider.sellDonut();
+            bars++;
+
+            m_nutProvider.sellDonut();
+            nuts++;
+
+            m_fooBarProvider.sellDonut();
+            foos++;
+            bars++;
+
+            m_barNutProvider.sellDonut();
+            bars++;
+            nuts++;
+
+            m_fooNutProvider.sellDonut();
+            foos++;
+            nuts++;
+
+            m_fooBarNutProvider.sellDonut();
+            foos++;
+            bars++;
+            nuts++;
+        }
+
+        // Check received donuts
+        assertEquals("The number of received donuts must be correct.", foos,
+                m_fooConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", bars,
+                m_barConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", nuts,
+                m_nutConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", foos
+                + bars, m_fooBarConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", bars
+                + nuts, m_barNutConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", foos
+                + nuts, m_fooNutConsumer.getAllDonuts().length);
+        assertEquals("The number of received donuts must be correct.", foos
+                + bars + nuts, m_fooBarNutConsumer.getAllDonuts().length);
+
+    }
+
+    /**
+     * Finalization after test cases.
+     *
+     * Release all services references and destroy instances.
+     */
+    public void tearDown() {
+        int index;
+        for (index = 0; index < NUMBER_OF_PROVIDERS; index++) {
+            getContext().ungetService(m_providersServices[index]);
+            m_providersInstances[index].dispose();
+        }
+        for (index = 0; index < NUMBER_OF_CONSUMERS; index++) {
+            getContext().ungetService(m_consumersServices[index]);
+            m_consumersInstances[index].dispose();
+        }
+        getContext().ungetService(m_eventTrackerService);
+        m_eventTrackerInstance.dispose();
+        for (int i = 0; i < Donut.FLAVOURS.length; i++) {
+            getContext().ungetService(m_filteredConsumersServices[i]);
+            m_filteredConsumersInstances[i].dispose();
+        }
+        for (int i = 0; i < TOPICS_LIST.length; i++) {
+            getContext().ungetService(m_topicsProvidersServices[i]);
+            m_topicsProvidersInstances[i].dispose();
+            getContext().ungetService(m_topicsConsumersServices[i]);
+            m_topicsConsumersInstances[i].dispose();
+        }
+
+    }
+
+}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java
index 913af68..7119584 100644
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java
+++ b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java
@@ -75,6 +75,15 @@
     }

 

     /**

+     * Return the (asynchronous) donut provider using publishes factory.

+     *

+     * @return the (asynchronous) donut provider using publishes factory

+     */

+    public Factory getDonutProviderUsingPublishesFactory() {

+        return IPojoTestUtils.getFactoryByName(m_context, "donut-provider-publishes");

+    }

+

+    /**

      * Return the synchronous donut provider factory.

      *

      * @return the synchronous donut provider factory

diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java
index bd53b96..cd4fdbb 100644
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java
+++ b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java
@@ -1,4 +1,4 @@
-/* 

+/*

  * 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

@@ -33,7 +33,7 @@
 

 /**

  * Useful iPOJO methods used for the tests of the Event Admin Handler.

- * 

+ *

  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

  */

 public class IPojoTestUtils {

@@ -152,6 +152,24 @@
         }

     }

 

+    public static HandlerFactory[] getHandlerFactories(BundleContext bc) {

+        ServiceReference[] refs;

+        try {

+            refs = bc.getServiceReferences(HandlerFactory.class.getName(), null);

+            if (refs == null) {

+                System.err.println("Cannot get the handler factories");

+                return null;

+            }

+            HandlerFactory[] factories = new HandlerFactory[refs.length];

+            for (int i = 0; i < factories.length; i++) {

+            	factories[i] = (HandlerFactory) bc.getService(refs[i]);

+            }

+            return factories;

+        } catch (InvalidSyntaxException e) {

+            return null;

+        }

+    }

+

     public static Object getServiceObject(BundleContext bc, String itf,

             String filter) {

         ServiceReference ref = getServiceReference(bc, itf, filter);

diff --git a/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml b/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml
index 77fe217..7f443fd 100644
--- a/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml
+++ b/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml
@@ -16,6 +16,18 @@
 			topics="food/donuts" data-key="food" synchronous="false"/>
 	</component>
 
+		<!-- The (asynchronous) donut provider using publishes -->
+	<component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
+		name="donut-provider-publishes">
+		<!-- Expose the donut provider service -->
+		<provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
+			<property name="name" field="m_name" value="Unknown donut vendor"/>
+		</provides>
+		<!-- Donut publisher -->
+		<ev:publishes name="donut-publisher" field="m_publisher"
+			topics="food/donuts" dataKey="food" synchronous="false"/>
+	</component>
+
 	<!-- The synchronous donut provider -->
 	<component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
 		name="synchronous-donut-provider">