[jbpm-commits] JBoss JBPM SVN: r6394 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/stream and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jun 4 04:48:08 EDT 2010
Author: alex.guizar at jboss.com
Date: 2010-06-04 04:48:07 -0400 (Fri, 04 Jun 2010)
New Revision: 6394
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/ForkSwimlaneTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java
Log:
JBPM-2746: do not replace non-latin letters away from process definition key
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java 2010-06-03 19:13:17 UTC (rev 6393)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java 2010-06-04 08:48:07 UTC (rev 6394)
@@ -125,7 +125,7 @@
if (processDefinitionKey==null) {
// derive the key from the name
// replace any non-word character with an underscore
- processDefinitionKey = processDefinitionName.replaceAll("\\W", "_");
+ processDefinitionKey = processDefinitionName.replaceAll("[^\\p{L}\\p{N}]", "_");
processDefinition.setKey(processDefinitionKey);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java 2010-06-03 19:13:17 UTC (rev 6393)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java 2010-06-04 08:48:07 UTC (rev 6394)
@@ -23,22 +23,28 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
-
/**
* @author Tom Baeyens
*/
public class StringStreamInput extends StreamInput {
-
- String string;
-
+
+ private String string;
+
public StringStreamInput(String string) {
this.name = "string";
this.string = string;
}
public InputStream openStream() {
- byte[] bytes = string.getBytes();
- return new ByteArrayInputStream(bytes);
+ try {
+ byte[] bytes = string.getBytes("UTF-8");
+ return new ByteArrayInputStream(bytes);
+ }
+ catch (UnsupportedEncodingException e) {
+ // every implementation of the Java platform is required to support UTF-8
+ throw new AssertionError(e);
+ }
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/ForkSwimlaneTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/ForkSwimlaneTest.java 2010-06-03 19:13:17 UTC (rev 6393)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/ForkSwimlaneTest.java 2010-06-04 08:48:07 UTC (rev 6394)
@@ -22,17 +22,7 @@
package org.jbpm.test.activity.task;
import java.util.List;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.history.HistoryEvent;
-import org.jbpm.pvm.internal.history.events.VariableCreate;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.repository.RepositoryCache;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.type.Variable;
import org.jbpm.api.task.Task;
import org.jbpm.test.JbpmTestCase;
@@ -91,8 +81,7 @@
}
public void testSwimlane() {
- ProcessInstance processInstance = executionService
- .startProcessInstanceByKey("ForkSwimlane");
+ executionService.startProcessInstanceByKey("ForkSwimlane");
takeAndCompleteTask("lingo");
takeAndCompleteTask("lingo");
completeTask("lingo");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java 2010-06-03 19:13:17 UTC (rev 6393)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java 2010-06-04 08:48:07 UTC (rev 6394)
@@ -30,7 +30,6 @@
import org.jbpm.api.ProcessInstance;
import org.jbpm.test.JbpmTestCase;
-
/**
* @author Tom Baeyens
*/
@@ -374,4 +373,33 @@
assertTrue(execution.isEnded());
}
+
+ /**
+ * Non-latin letters are replaced away from process definition key.
+ * @see <a href="https://jira.jboss.org/browse/JBPM-2746">JBPM-2746</a>
+ */
+ public void testNonLatinProcessName() {
+ // "Lev Trotskij"
+ deployJpdlXmlString("<process name='\u041B\u0435\u0412 \u0422\u0440\u043E\u0446\u043A\u0438\u0439'>" +
+ " <start/>" +
+ "</process>");
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionKey("\u041B\u0435\u0412_\u0422\u0440\u043E\u0446\u043A\u0438\u0439")
+ .uniqueResult();
+
+ assertEquals("\u041B\u0435\u0412 \u0422\u0440\u043E\u0446\u043A\u0438\u0439", processDefinition.getName());
+ }
+
+ public void testNumberProcessName() {
+ deployJpdlXmlString("<process name='jbpm 2746'>" +
+ " <start/>" +
+ "</process>");
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionKey("jbpm_2746")
+ .uniqueResult();
+
+ assertEquals("jbpm 2746", processDefinition.getName());
+ }
}
More information about the jbpm-commits
mailing list