felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1311693 - in /felix/sandbox/cziegeler/eventadmin-tests: ./ src/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/felix/ src/test/java/org/apache/felix/eventadmin/ src/test/java/org/apache/felix...
Date Tue, 10 Apr 2012 12:25:12 GMT
Author: cziegeler
Date: Tue Apr 10 12:25:11 2012
New Revision: 1311693

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

Added:
    felix/sandbox/cziegeler/eventadmin-tests/   (with props)
    felix/sandbox/cziegeler/eventadmin-tests/pom.xml   (with props)
    felix/sandbox/cziegeler/eventadmin-tests/src/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
  (with props)
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
  (with props)
    felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
  (with props)

Propchange: felix/sandbox/cziegeler/eventadmin-tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 10 12:25:11 2012
@@ -0,0 +1 @@
+target

Added: felix/sandbox/cziegeler/eventadmin-tests/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/eventadmin-tests/pom.xml?rev=1311693&view=auto
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/pom.xml (added)
+++ felix/sandbox/cziegeler/eventadmin-tests/pom.xml Tue Apr 10 12:25:11 2012
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>felix-parent</artifactId>
+        <version>2.1</version>    </parent>
+
+    <artifactId>org.apache.felix.eventadmin.tests.</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <name>Apache Felix Event Admin Integration Test</name>
+    <description>
+        This bundle provides tests for the event admin.
+    </description>
+
+    <properties>
+        <eventadmin.version>1.2.15-SNAPSHOT</eventadmin.version>
+    </properties>
+
+    <build>
+        <plugins>
+                <!-- Compile for Java 5 and higher -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>2.3.2</version>
+                    <configuration>
+                        <source>1.5</source>
+                        <target>1.5</target>
+                    </configuration>
+                </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>java6</id>
+            <activation>
+                <jdk>1.6</jdk>
+            </activation>
+            <build>
+                <plugins>
+                  <!-- integration tests run with pax-exam -->
+                    <plugin>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <version>2.12</version>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <systemProperties>
+                                <property>
+                                    <name>eventadmin.version</name>
+                                    <value>${eventadmin.version}</value>
+                                </property>
+                            </systemProperties>
+                            <includes>
+                                <include>**/*IT.java</include>
+                            </includes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+      <!-- Unit Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jmock</groupId>
+            <artifactId>jmock-junit4</artifactId>
+            <version>2.5.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.5.2</version>
+            <scope>test</scope>
+        </dependency>
+      <!-- Integration Testing with Pax Exam -->
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>2.4.0.RC1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>2.4.0.RC1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>2.4.0.RC1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>1.4.0.RC1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-wrap</artifactId>
+            <version>1.4.0.RC1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.base</groupId>
+            <artifactId>ops4j-base-lang</artifactId>
+            <version>1.2.3</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.base</groupId>
+            <artifactId>ops4j-base-net</artifactId>
+            <version>1.2.3</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>4.0.2</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: felix/sandbox/cziegeler/eventadmin-tests/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/eventadmin-tests/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: felix/sandbox/cziegeler/eventadmin-tests/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1311693&view=auto
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
(added)
+++ felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
Tue Apr 10 12:25:11 2012
@@ -0,0 +1,305 @@
+/*
+ * 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.eventadmin.tests;
+
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.Constants.START_LEVEL_SYSTEM_BUNDLES;
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.AbstractDelegateProvisionOption;
+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 {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    // the name of the system property providing the event admin version
+    private static final String EVENT_ADMIN_VERSION_PROP = "eventadmin.version";
+
+    @Inject
+    protected BundleContext bundleContext;
+
+    protected EventAdmin eventAdmin;
+
+    protected ServiceReference eventAdminReference;
+
+    public void handleEvent(final Event event, final Object payload) {
+        this.handleEvent(event);
+    }
+
+    private volatile boolean running = false;
+
+    private volatile int nrEvents;
+
+    private volatile int eventCount = 0;
+
+    private volatile int finishEventCount;
+
+    private volatile String prefix;
+
+    private final Object waitLock = new Object();
+
+    protected void send(String topic, Dictionary<String, Object> properties, boolean
sync) {
+        final Event event = new Event(topic, properties);
+        if ( sync ) {
+            getEventAdmin().sendEvent(event);
+        } else {
+            getEventAdmin().postEvent(event);
+        }
+    }
+
+    private synchronized void incCount() {
+        eventCount++;
+        if ( eventCount >= finishEventCount) {
+            logger.info("Finished tests, received {} events", eventCount);
+        }
+    }
+
+    /**
+     * @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;
+    }
+
+    protected void start(final String prefix, final int nrThreads, final int nrEvents, final
int finishCount) {
+        this.prefix = prefix;
+        this.nrEvents = nrEvents;
+        finishEventCount = finishCount;
+        eventCount = 0;
+        logger.info("Preparing test with {} threads and {} events.", nrThreads, nrEvents);
+        logger.info("Expecting {} events.", finishCount);
+        this.running = true;
+        final Thread[] threads = new Thread[nrThreads];
+        for(int i = 0; i < threads.length; i++) {
+            threads[i] = new Thread(this);
+        }
+        for(int i = 0; i < threads.length; i++) {
+            threads[i].start();
+        }
+        final Thread infoT = new Thread(new Runnable() {
+            public void run() {
+                while ( running ) {
+                    logger.info("Received {} events so far.", getCount());
+                    try {
+                        Thread.sleep(1000 * 5);
+                    } catch (InterruptedException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+                    if ( getCount() >= finishCount) {
+                        running = false;
+                        synchronized ( waitLock ) {
+                            waitLock.notify();
+                        }
+                    }
+                }
+            }
+        });
+        infoT.start();
+        logger.info("Started test with {} threads and {} events.", nrThreads, nrEvents);
+     }
+
+    public void waitForFinish() {
+        while ( this.running ) {
+            synchronized ( this.waitLock ) {
+                try {
+                    this.waitLock.wait();
+                } catch (final InterruptedException e) {
+                    // ignore
+                }
+            }
+        }
+    }
+
+    protected abstract void sendEvent(final int index);
+    public abstract void start();
+
+    /**
+     * @see java.lang.Runnable#run()
+     */
+    public void run() {
+        try {
+            Thread.sleep(1000 * 10);
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        logger.info("Started thread");
+        int index = 0;
+        while ( this.running && index < nrEvents ) {
+            this.sendEvent(index);
+
+            index++;
+        }
+        logger.info("Send {} events.", index);
+    }
+
+    private final List<Listener> listeners = new ArrayList<Listener>();
+
+    public void addListener(final String topic, final Object payload) {
+        this.listeners.add(new Listener(this.bundleContext, this, topic, payload));
+    }
+
+    public void stop() {
+        for(final Listener l : listeners) {
+            l.dispose();
+        }
+        listeners.clear();
+    }
+
+    /**
+     * Helper method to get a service of the given type
+     */
+    @SuppressWarnings("unchecked")
+	protected <T> T getService(Class<T> clazz) {
+    	final ServiceReference ref = bundleContext.getServiceReference(clazz.getName());
+    	assertNotNull("getService(" + clazz.getName() + ") must find ServiceReference", ref);
+    	final T result = (T)(bundleContext.getService(ref));
+    	assertNotNull("getService(" + clazz.getName() + ") must find service", result);
+    	return result;
+    }
+
+    protected EventAdmin getEventAdmin() {
+        if ( eventAdminReference == null || eventAdminReference.getBundle() == null ) {
+            eventAdmin = null;
+            eventAdminReference = bundleContext.getServiceReference(EventAdmin.class.getName());
+        }
+        if ( eventAdmin == null && eventAdminReference != null ) {
+            eventAdmin = (EventAdmin) bundleContext.getService(eventAdminReference);
+        }
+        return eventAdmin;
+    }
+
+    @Configuration
+    public static Option[] configuration() {
+        final String eventAdminVersion = System.getProperty( EVENT_ADMIN_VERSION_PROP );
+        return options(
+            provision(
+                mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles", "1.0.0" ),
+                mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "2.1.2"),
+                mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.2.8"),
+                mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.0.4"),
+                mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", eventAdminVersion),
+                mavenBundle("org.ops4j.pax.url", "pax-url-mvn", "1.3.5")
+             ),
+             // below is instead of normal Pax Exam junitBundles() to deal
+             // with build server issue
+             new DirectURLJUnitBundlesOption(),
+             systemProperty("pax.exam.invoker").value("junit"),
+             bundle("link:classpath:META-INF/links/org.ops4j.pax.exam.invoker.junit.link")
+        );
+    }
+
+    /**
+     * Start the test.
+     */
+    public void startTest() {
+        logger.info("Starting eventing tests....");
+        this.execute();
+        logger.info("Finished with eventing tests....");
+    }
+
+    /**
+     * Execute a single test.
+     * @param test
+     */
+    private void execute() {
+        logger.info("Starting eventing test {}", this.getClass().getSimpleName());
+        this.start();
+        this.waitForFinish();
+        this.stop();
+        logger.info("Finished eventing test {}", this.getClass().getSimpleName());
+        try {
+            Thread.sleep(15 * 1000);
+        } catch (final InterruptedException ie) {
+            // ignore
+        }
+    }
+
+
+    @Test
+    public void testEventAdmin() throws Exception {
+        // check class loader
+        assertNotNull(getEventAdmin());
+    }
+
+    /**
+     * Clone of Pax Exam's JunitBundlesOption which uses a direct
+     * URL to the SpringSource JUnit bundle to avoid some weird
+     * repository issues on the Apache build server.
+     */
+    private static class DirectURLJUnitBundlesOption
+        extends AbstractDelegateProvisionOption<DirectURLJUnitBundlesOption> {
+
+        /**
+         * Constructor.
+         */
+        public DirectURLJUnitBundlesOption(){
+            super(
+                bundle("http://repository.springsource.com/ivy/bundles/external/org.junit/com.springsource.org.junit/4.9.0/com.springsource.org.junit-4.9.0.jar")
+            );
+            noUpdate();
+            startLevel(START_LEVEL_SYSTEM_BUNDLES);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public String toString() {
+            return String.format("DirectURLJUnitBundlesOption{url=%s}", getURL());
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        protected DirectURLJUnitBundlesOption itself() {
+            return this;
+        }
+
+    }
+}
\ No newline at end of file

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/AbstractTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java?rev=1311693&view=auto
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
(added)
+++ felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
Tue Apr 10 12:25:11 2012
@@ -0,0 +1,61 @@
+/*
+ * 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.eventadmin.tests;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+
+public class Listener implements EventHandler {
+
+    private final ServiceRegistration reg;
+
+    private final Object payload;
+
+    private final AbstractTest test;
+
+    public Listener(final BundleContext ctx, final AbstractTest test, final String topic,
final Object payload) {
+        this(ctx, test, topic != null ? new String[] {topic} : null, payload);
+    }
+
+    public Listener(final BundleContext ctx, final AbstractTest test, final String[] topics,
final Object payload) {
+        final Dictionary<String, Object> props = new Hashtable<String, Object>();
+        if ( topics != null ) {
+            props.put("event.topics", topics);
+        } else {
+            props.put("event.topics", "*");
+        }
+        this.test = test;
+        this.reg = ctx.registerService(EventHandler.class.getName(), this, props);
+        this.payload = payload;
+    }
+
+    public void dispose() {
+        this.reg.unregister();
+    }
+
+    /**
+     * @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
+     */
+    public void handleEvent(final Event event) {
+        this.test.handleEvent(event, this.payload);
+    }
+}

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/Listener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java?rev=1311693&view=auto
==============================================================================
--- felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
(added)
+++ felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
Tue Apr 10 12:25:11 2012
@@ -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 org.apache.felix.eventadmin.tests;
+
+import org.junit.Test;
+
+public class StressTestIT extends AbstractTest {
+
+    private static final String PREFIX = "org/apache/felix/eventing/test";
+    private static final int THREADS = 15;
+    private static final int EVENTS_PER_THREAD = 10000;
+
+    public void start() {
+        this.addListener(PREFIX + "/0", null);
+        this.addListener(PREFIX + "/1", null);
+        this.addListener(PREFIX + "/2", null);
+        this.addListener(PREFIX + "/3", null);
+        this.addListener(PREFIX + "/4", null);
+        this.addListener(PREFIX + "/5", null);
+        this.addListener(PREFIX + "/6", null);
+        this.addListener(PREFIX + "/7", null);
+        this.addListener(PREFIX + "/8", null);
+        this.addListener(PREFIX + "/9", null);
+        this.addListener(PREFIX + "/*", null);
+        this.addListener("org/apache/felix/eventing/*", null);
+        this.addListener("org/apache/felix/*", null);
+        this.addListener("org/apache/*", null);
+        this.addListener("org/*", null);
+        this.addListener("*", null);
+        super.start(PREFIX, THREADS, EVENTS_PER_THREAD, THREADS * EVENTS_PER_THREAD * (1
+ 6));
+    }
+
+    @Override
+    protected void sendEvent(int index) {
+        final String postFix = String.valueOf(index % 10);
+        final String topic = PREFIX + '/' + postFix;
+        this.send(topic, null, true);
+    }
+
+    @Test
+    public void testEventing() throws Exception {
+        this.startTest();
+    }
+}

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/cziegeler/eventadmin-tests/src/test/java/org/apache/felix/eventadmin/tests/StressTestIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message