📄 executionpersistencetest.java
字号:
package org.jbpm.model.execution.impl;
import java.util.*;
import org.jbpm.*;
import org.jbpm.model.definition.impl.*;
import org.jbpm.persistence.hibernate.*;
import junit.framework.*;
public class ExecutionPersistenceTest extends TestCase {
static { TestHelper.initLogging(); }
private static boolean isDefinitionLoaded = false;
private static Long processInstanceId = null;
private HibernateTestHelper hibernate = null;
private ProcessInstanceImpl processInstance = null;
public void setUp() throws Exception {
hibernate = new HibernateTestHelper();
if ( ! isDefinitionLoaded ) {
loadProcessInstance();
}
hibernate.startTransaction();
processInstance = (ProcessInstanceImpl) hibernate.getSession().load( ProcessInstanceImpl.class, processInstanceId );
}
public void tearDown() throws Exception {
hibernate.commitTransaction();
}
private void loadProcessInstance() throws Exception {
DefinitionImpl definition = new DefinitionImpl("holiday");
ProcessInstanceImpl processInstance = new ProcessInstanceImpl( definition );
TokenImpl root = (TokenImpl) processInstance.getRoot();
new TokenImpl( root, "child one" );
new TokenImpl( root, "child two" );
root.setActorId( "root swimlane id" );
new VariableInstanceImpl( "variable one", root, DefaultType.STRING );
new VariableInstanceImpl( "variable two", root, DefaultType.LONG );
new VariableInstanceImpl( "variable three", root, DefaultType.DOUBLE );
// save the definition using the persistence manager
hibernate.startTransaction();
hibernate.getSession().save( definition );
hibernate.getSession().save( processInstance );
hibernate.commitTransaction();
processInstanceId = processInstance.getId();
}
public void testProcessInstance() {
TokenImpl root = (TokenImpl)processInstance.getRoot();
assertEquals( "holiday", processInstance.getDefinition().getName() );
assertEquals( "root", root.getName() );
assertEquals( "root swimlane id", root.getActorId() );
Collection retrievedChildNames = root.getChildren().keySet();
Collection expectedChildNames = new HashSet( Arrays.asList( new String[]{ "child one", "child two" } ) );
assertEquals( expectedChildNames, retrievedChildNames );
Collection retrievedVariableNames = root.getVariableInstances().keySet();
Collection expectedVariableNames = new HashSet( Arrays.asList( new String[]{ "variable one", "variable two", "variable three" } ) );
assertEquals( expectedVariableNames, retrievedVariableNames );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -