[jbpm-commits] JBoss JBPM SVN: r1923 - jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Aug 18 08:44:47 EDT 2008
Author: porcherg
Date: 2008-08-18 08:44:46 -0400 (Mon, 18 Aug 2008)
New Revision: 1923
Added:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java
Modified:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
Log:
generate an error message with a deterministic length instead of a stacktrace.
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java (from rev 1921, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailRecursivelyTestCommand.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java 2008-08-18 12:44:46 UTC (rev 1923)
@@ -0,0 +1,67 @@
+/*
+ * 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.pvm.internal.jobexecutor;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ *
+ * Simple command that will create an exception during execution.
+ * The exception will generate a stacktrace with variable length
+ * (controlled by the length parameter).
+ *
+ * This class is to test the persistence of exception stacktrace in jobs.
+ */
+public class GenerateExceptionTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ int length;
+
+ public GenerateExceptionTestCommand() {
+ }
+
+ public static CommandMessage createMessage(int recursionInitialDepth) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
+ commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ StringBuilder stringBuilder = new StringBuilder();
+ while (stringBuilder.length() < length) {
+ stringBuilder.append("This is a test message. ");
+ }
+ throw new RuntimeException(stringBuilder.toString());
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-08-18 12:19:12 UTC (rev 1922)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-08-18 12:44:46 UTC (rev 1923)
@@ -209,13 +209,13 @@
jobExecutor.start();
try {
commandService.execute(new Command<Object>() {
- // size of the recursion (to create a long stacktrace)
- // 10 creates an exception if there is a limit of 4000 characters
- int recursiveDepth = 10;
+ // size of the error message to generate
+ // (currently there is a limit of 4000 characters)
+ int msgLength = 4100;
public Object execute(Environment environment) throws Exception {
MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailRecursivelyTestCommand.createMessage(recursiveDepth);
+ CommandMessage commandMessage = GenerateExceptionTestCommand.createMessage(msgLength);
messageSession.send(commandMessage);
return null;
}
More information about the jbpm-commits
mailing list