📄 testhelper.java
字号:
package org.jbpm;
import java.io.*;
import java.util.*;
import org.jbpm.par.*;
public class TestHelper {
protected DefinitionService definitionService = null;
protected ExecutionService executionService = null;
public TestHelper() {
JbpmServiceLocator serviceLocator = JbpmServiceLocator.getInstance();
definitionService = serviceLocator.getDefinitionService();
executionService = serviceLocator.getExecutionService();
}
public static void initLogging() {
JbpmConfiguration.getInstance();
}
public DefinitionService getDefinitionService() {
return definitionService;
}
public ExecutionService getExecutionService() {
return executionService;
}
public void deployProcess(String processDefinitionResource) {
deployProcess( processDefinitionResource, null );
}
public void deployProcess(String processDefinitionResource, Map files) {
try {
// build a process archive from the files in the classpath
ArchiveBuilder archiveBuilder = new ArchiveBuilder( getResourceStream( processDefinitionResource ) );
if ( files != null ) {
Iterator iter = files.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
archiveBuilder.add( (String) entry.getKey(), getResourceStream( (String) entry.getValue() ) );
}
}
// deploy the process archive into the jbpm with the definition service
definitionService.deployProcessArchive( archiveBuilder.getJarInputStream() );
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException( "couldn't deploy process from resource '" + processDefinitionResource + "' : " + e.getMessage() );
}
}
/**
* finds resources relative to any of the following directories : doc/dtd, core/src/test/process, core/src/test/config
*/
public static InputStream getResourceStream( String resource ) {
return TestHelper.class.getClassLoader().getResourceAsStream( resource );
}
/**
* loads Properties from a file in the classpath.
* All properties that are not specified in the properties-file and for which jBpm has a default value, will be set to that default value.
* For proper test operation, the directories doc/dtd, core/src/test/process and core/src/test/config must be in the classpath.
*/
public static Properties getProperties( String resource ) {
Properties properties = new Properties();
properties.putAll( JbpmConfiguration.defaults );
try {
properties.load( getResourceStream( resource ) );
} catch (IOException e) {
throw new RuntimeException( "couldn't load properties from resource " + resource );
}
return properties;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -