[jbpm-commits] JBoss JBPM SVN: r3822 - jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Feb 10 00:46:42 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-02-10 00:46:42 -0500 (Tue, 10 Feb 2009)
New Revision: 3822
Modified:
jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
Log:
disable process instance deletion to make enterprise tests more stable
Modified: jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java 2009-02-10 04:07:11 UTC (rev 3821)
+++ jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java 2009-02-10 05:46:42 UTC (rev 3822)
@@ -28,7 +28,6 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
-import javax.jms.JMSException;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -85,21 +84,22 @@
protected CommandService createCommandService() throws Exception {
if (commandServiceHome == null) {
- commandServiceHome = lookup("ejb/CommandServiceBean", LocalCommandServiceHome.class);
+ commandServiceHome = (LocalCommandServiceHome) getEnvironment()
+ .lookup("ejb/CommandServiceBean");
}
return commandServiceHome.create();
}
protected ProcessDefinition deployProcessDefinition(String xml) {
- ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(new DeployProcessCommand(
- xml));
+ ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(
+ new DeployProcessCommand(xml));
processDefinitions.add(processDefinition);
return processDefinition;
}
protected ProcessDefinition deployProcessDefinition(byte[] processArchive) {
- ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(new DeployProcessCommand(
- processArchive));
+ ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(
+ new DeployProcessCommand(processArchive));
processDefinitions.add(processDefinition);
return processDefinition;
}
@@ -116,8 +116,8 @@
}
protected boolean hasProcessInstanceEnded(final long processInstanceId) {
- ProcessInstance processInstance = (ProcessInstance) commandService.execute(new GetProcessInstanceCommand(
- processInstanceId));
+ ProcessInstance processInstance = (ProcessInstance) commandService.execute(
+ new GetProcessInstanceCommand(processInstanceId));
return processInstance.hasEnded();
}
@@ -126,24 +126,30 @@
private static final long serialVersionUID = 1L;
public Object execute(JbpmContext jbpmContext) throws Exception {
- DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext
+ .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
return factory.getConfiguration().getProperty(Environment.DIALECT);
}
});
}
private void deleteProcessDefinition(long processDefinitionId) throws Exception {
- // deleting process definition seems to cause problems in sybase
- if (getHibernateDialect().contains("Sybase")) {
+ if (true) {
+ // [JBPM-1812] Fix tests that don't cleanup the database
+ // deleting process definition makes subsequent tests unstable
return;
}
- Command command = new DeleteProcessDefinitionCommand(processDefinitionId);
-
- Connection jmsConnection = createJmsConnection();
+ Connection jmsConnection = getConnectionFactory().createConnection();
try {
Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- jmsSession.createProducer(getCommandQueue()).send(jmsSession.createObjectMessage(command));
+ try {
+ Command command = new DeleteProcessDefinitionCommand(processDefinitionId);
+ jmsSession.createProducer(getCommandQueue()).send(jmsSession.createObjectMessage(command));
+ }
+ finally {
+ jmsSession.close();
+ }
}
finally {
jmsConnection.close();
@@ -152,22 +158,19 @@
private Destination getCommandQueue() throws NamingException {
if (commandQueue == null) {
- commandQueue = lookup("jms/CommandQueue", Destination.class);
+ commandQueue = (Destination) getEnvironment().lookup("jms/CommandQueue");
}
return commandQueue;
}
- private Connection createJmsConnection() throws NamingException, JMSException {
+ private ConnectionFactory getConnectionFactory() throws NamingException {
if (jmsConnectionFactory == null) {
- jmsConnectionFactory = lookup("jms/JbpmConnectionFactory", ConnectionFactory.class);
+ jmsConnectionFactory = (ConnectionFactory) getEnvironment()
+ .lookup("jms/JbpmConnectionFactory");
}
- return jmsConnectionFactory.createConnection();
+ return jmsConnectionFactory;
}
- private static <T> T lookup(String name, Class<T> type) throws NamingException {
- return type.cast(getEnvironment().lookup(name));
- }
-
private static Context getEnvironment() throws NamingException {
if (environment == null) {
Context initial = new InitialContext();
More information about the jbpm-commits
mailing list