felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1311695 - /felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
Date Tue, 10 Apr 2012 12:46:01 GMT
Author: cziegeler
Date: Tue Apr 10 12:46:00 2012
New Revision: 1311695

URL: http://svn.apache.org/viewvc?rev=1311695&view=rev
Log:
Add a simple stress test for event admin

Modified:
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java

Modified: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java?rev=1311695&r1=1311694&r2=1311695&view=diff
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
(original)
+++ felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
Tue Apr 10 12:46:00 2012
@@ -39,29 +39,27 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
-import org.osgi.service.event.EventHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 @RunWith(JUnit4TestRunner.class)
-public abstract class AbstractTest implements Runnable, EventHandler {
+public abstract class AbstractTest implements Runnable {
 
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    // the name of the system property providing the event admin version
+    /** the name of the system property providing the event admin version. */
     private static final String EVENT_ADMIN_VERSION_PROP = "eventadmin.version";
 
+    /** The logger. */
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
     @Inject
     protected BundleContext bundleContext;
 
-    protected EventAdmin eventAdmin;
-
-    protected ServiceReference eventAdminReference;
+    /** Event admin. */
+    private EventAdmin eventAdmin;
 
-    public void handleEvent(final Event event, final Object payload) {
-        this.handleEvent(event);
-    }
+    /** Event admin reference. */
+    private ServiceReference eventAdminReference;
 
     private volatile boolean running = false;
 
@@ -73,8 +71,19 @@ public abstract class AbstractTest imple
 
     private volatile String prefix;
 
+    /** Wait lock for syncing. */
     private final Object waitLock = new Object();
 
+    /**
+     * @param event
+     * @param payload
+     */
+    public void handleEvent(final Event event, final Object payload) {
+        if ( prefix == null || event.getTopic().startsWith(prefix) ) {
+            incCount();
+        }
+    }
+
     protected void send(String topic, Dictionary<String, Object> properties, boolean
sync) {
         final Event event = new Event(topic, properties);
         if ( sync ) {
@@ -91,15 +100,6 @@ public abstract class AbstractTest imple
         }
     }
 
-    /**
-     * @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
-     */
-    public void handleEvent(final Event event) {
-        if ( prefix == null || event.getTopic().startsWith(prefix) ) {
-            incCount();
-        }
-    }
-
     public synchronized int getCount() {
         return eventCount;
     }
@@ -142,7 +142,7 @@ public abstract class AbstractTest imple
         logger.info("Started test with {} threads and {} events.", nrThreads, nrEvents);
      }
 
-    public void waitForFinish() {
+    private void waitForFinish() {
         while ( this.running ) {
             synchronized ( this.waitLock ) {
                 try {
@@ -155,6 +155,7 @@ public abstract class AbstractTest imple
     }
 
     protected abstract void sendEvent(final int index);
+
     public abstract void start();
 
     /**
@@ -183,7 +184,7 @@ public abstract class AbstractTest imple
         this.listeners.add(new Listener(this.bundleContext, this, topic, payload));
     }
 
-    public void stop() {
+    private void stop() {
         for(final Listener l : listeners) {
             l.dispose();
         }



Mime
View raw message