use of org.activiti.engine.impl.persistence.entity.MessageEntity in project Activiti by Activiti.
the class JobExecutorCmdExceptionTest method testJobCommandsWith3Exceptions.
public void testJobCommandsWith3Exceptions() {
tweetExceptionHandler.setExceptionsRemaining(3);
commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = createTweetExceptionMessage();
commandContext.getJobEntityManager().send(message);
return message.getId();
}
});
Job job = managementService.createJobQuery().singleResult();
assertEquals(3, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("exception expected");
} catch (Exception e) {
// exception expected;
}
job = managementService.createJobQuery().singleResult();
assertEquals(2, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("exception expected");
} catch (Exception e) {
// exception expected;
}
job = managementService.createJobQuery().singleResult();
assertEquals(1, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("exception expected");
} catch (Exception e) {
// exception expected;
}
job = managementService.createJobQuery().singleResult();
assertEquals(0, job.getRetries());
managementService.deleteJob(job.getId());
}
use of org.activiti.engine.impl.persistence.entity.MessageEntity in project Activiti by Activiti.
the class JobExecutorCmdExceptionTest method testJobCommandsWith2Exceptions.
public void testJobCommandsWith2Exceptions() {
commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = createTweetExceptionMessage();
commandContext.getJobEntityManager().send(message);
return message.getId();
}
});
Job job = managementService.createJobQuery().singleResult();
assertEquals(3, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("exception expected");
} catch (Exception e) {
// exception expected;
}
job = managementService.createJobQuery().singleResult();
assertEquals(2, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("exception expected");
} catch (Exception e) {
// exception expected;
}
job = managementService.createJobQuery().singleResult();
assertEquals(1, job.getRetries());
managementService.executeJob(job.getId());
}
use of org.activiti.engine.impl.persistence.entity.MessageEntity in project Activiti by Activiti.
the class JobExecutorCmdHappyTest method testJobCommandsWithMessage.
public void testJobCommandsWithMessage() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
String jobId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = createTweetMessage("i'm coding a test");
commandContext.getJobEntityManager().send(message);
return message.getId();
}
});
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
assertEquals(jobId, job.getId());
assertEquals(0, tweetHandler.getMessages().size());
managementService.executeJob(job.getId());
assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
assertEquals(1, tweetHandler.getMessages().size());
}
Aggregations