[jbpm-commits] JBoss JBPM SVN: r3939 - jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Feb 19 04:10:48 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-02-19 04:10:48 -0500 (Thu, 19 Feb 2009)
New Revision: 3939
Added:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
Log:
[JBPM-2043] Add jBPM performance test coverage
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java (from rev 3930, jbpm3/trunk/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-19 09:10:48 UTC (rev 3939)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.perf;
+
+// $Id$
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.StartProcessInstanceCommand;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * This tests creates 10000 process instances. Every instance has an async call
+ * to the test class. See JIRA bugs SOA-1175 and JBPM-2043.
+ *
+ * @author mvecera at redhat.com
+ * @author pmacik at redhat.com
+ * @author thomas.diesler at jboss.com
+ * @since 18-Feb-2009
+ */
+public class AsyncCallTest extends AbstractDbTestCase
+{
+ private static final Log log = LogFactory.getLog(AsyncCallTest.class);
+
+ private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
+ private static final int INSTANCES = 1000;
+ private static int count;
+
+ ProcessDefinition processDefinition;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition xmlns='urn:jbpm.org:jpdl-3.1' name='processDefinition1'>" +
+ " <start-state name='start'>" +
+ " <transition name='to_state' to='end'>" +
+ " <action class='" + PerfActionHandler.class.getName() + "'/>" +
+ " </transition>" +
+ " </start-state>" +
+ " <end-state name='end'/>" +
+ "</process-definition>");
+
+ saveAndReload(processDefinition);
+ }
+
+ public void tearDown() throws Exception
+ {
+ beginSessionTransaction();
+ jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
+ super.tearDown();
+ }
+
+ public void testAsyncCall()
+ {
+ long start = System.currentTimeMillis();
+
+ commitAndCloseSession();
+ startJobExecutor();
+
+ for (count = 0; count < INSTANCES; count++)
+ {
+ beginSessionTransaction();
+ StartProcessInstanceCommand startCommand = new StartProcessInstanceCommand();
+ startCommand.setProcessId(processDefinition.getId());
+ startCommand.setProcessName("processDefinition1");
+ ProcessInstance pi = (ProcessInstance)commandService.execute(startCommand);
+ commitAndCloseSession();
+ }
+
+ stopJobExecutor();
+
+ long stop = System.currentTimeMillis();
+ System.out.println("=== Test finished processing " + INSTANCES + " instances in " + (stop - start) + "ms ===");
+ System.out.println("=== This is " + Math.round(1000 * INSTANCES / (stop - start)) + " instances per second ===");
+ }
+
+ public static class PerfActionHandler implements ActionHandler
+ {
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ //System.out.println(count);
+ }
+ }
+}
More information about the jbpm-commits
mailing list