use of junit.framework.AssertionFailedError in project Activiti by Activiti.
the class SecureScriptingBaseTest method assertProcessEnded.
public void assertProcessEnded(final String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
// Verify historical data if end times are correctly set
if (processEngine.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// process instance
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
Assert.assertEquals(processInstanceId, historicProcessInstance.getId());
Assert.assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
Assert.assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());
// tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).list();
if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
Assert.assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
}
}
// activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
Assert.assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
}
}
}
}
use of junit.framework.AssertionFailedError in project Activiti by Activiti.
the class AbstractPlaybackTest method runPlayback.
private void runPlayback() throws Throwable {
SimulationDebugger simDebugger = null;
try {
// init simulation run
Clock clock = new ThreadLocalClock(new DefaultClockFactory());
FactoryBean<ProcessEngineImpl> simulationProcessEngineFactory = new SimulationProcessEngineFactory(ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault());
final SimpleSimulationRun.Builder builder = new SimpleSimulationRun.Builder();
builder.processEngine(simulationProcessEngineFactory.getObject()).eventCalendar((new SimpleEventCalendarFactory(clock, new SimulationEventComparator(), listener.getSimulationEvents())).getObject()).eventHandlers(getHandlers());
simDebugger = builder.build();
simDebugger.init(new NoExecutionVariableScope());
this.processEngine = SimulationRunContext.getProcessEngine();
initializeServices();
deploymentIdFromDeploymentAnnotation = TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());
simDebugger.runContinue();
_checkStatus();
} catch (AssertionFailedError e) {
log.warn("Playback simulation {} has failed", getName());
log.error(EMPTY_LINE);
log.error("ASSERTION FAILED: {}", e, e);
exception = e;
throw e;
} catch (Throwable e) {
log.warn("Playback simulation {} has failed", getName());
log.error(EMPTY_LINE);
log.error("EXCEPTION: {}", e, e);
exception = e;
throw e;
} finally {
if (simDebugger != null) {
TestHelper.annotationDeploymentTearDown(processEngine, deploymentIdFromDeploymentAnnotation, getClass(), getName());
simDebugger.close();
assertAndEnsureCleanDb();
}
this.processEngineConfiguration.getClock().reset();
// Can't do this in the teardown, as the teardown will be called as part of the super.runBare
closeDownProcessEngine();
}
}
use of junit.framework.AssertionFailedError in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method testPlayMediaObjectStreamNoStartNoPrepare.
public void testPlayMediaObjectStreamNoStartNoPrepare() throws InterruptedException {
final Context c = getInstrumentation().getTargetContext();
final CountDownLatch countDownLatch = new CountDownLatch(2);
PlaybackServiceMediaPlayer.PSMPCallback callback = new DefaultPSMPCallback() {
@Override
public void statusChanged(LocalPSMP.PSMPInfo newInfo) {
try {
checkPSMPInfo(newInfo);
if (newInfo.playerStatus == PlayerStatus.ERROR)
throw new IllegalStateException("MediaPlayer error");
if (countDownLatch.getCount() == 0) {
fail();
} else if (countDownLatch.getCount() == 2) {
assertEquals(PlayerStatus.INITIALIZING, newInfo.playerStatus);
countDownLatch.countDown();
} else {
assertEquals(PlayerStatus.INITIALIZED, newInfo.playerStatus);
countDownLatch.countDown();
}
} catch (AssertionFailedError e) {
if (assertionError == null)
assertionError = e;
}
}
};
PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback);
Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null);
psmp.playMediaObject(p, true, false, false);
boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS);
if (assertionError != null)
throw assertionError;
assertTrue(res);
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.INITIALIZED);
assertFalse(psmp.isStartWhenPrepared());
psmp.shutdown();
}
use of junit.framework.AssertionFailedError in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method testPlayMediaObjectStreamStartPrepare.
public void testPlayMediaObjectStreamStartPrepare() throws InterruptedException {
final Context c = getInstrumentation().getTargetContext();
final CountDownLatch countDownLatch = new CountDownLatch(5);
PlaybackServiceMediaPlayer.PSMPCallback callback = new DefaultPSMPCallback() {
@Override
public void statusChanged(LocalPSMP.PSMPInfo newInfo) {
try {
checkPSMPInfo(newInfo);
if (newInfo.playerStatus == PlayerStatus.ERROR)
throw new IllegalStateException("MediaPlayer error");
if (countDownLatch.getCount() == 0) {
fail();
} else if (countDownLatch.getCount() == 5) {
assertEquals(PlayerStatus.INITIALIZING, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 4) {
assertEquals(PlayerStatus.INITIALIZED, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 3) {
assertEquals(PlayerStatus.PREPARING, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 2) {
assertEquals(PlayerStatus.PREPARED, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 1) {
assertEquals(PlayerStatus.PLAYING, newInfo.playerStatus);
}
countDownLatch.countDown();
} catch (AssertionFailedError e) {
if (assertionError == null)
assertionError = e;
}
}
};
PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback);
Playable p = writeTestPlayable(PLAYABLE_FILE_URL, null);
psmp.playMediaObject(p, true, true, true);
boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS);
if (assertionError != null)
throw assertionError;
assertTrue(res);
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING);
psmp.shutdown();
}
use of junit.framework.AssertionFailedError in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method testPlayMediaObjectLocalStartPrepare.
public void testPlayMediaObjectLocalStartPrepare() throws InterruptedException {
final Context c = getInstrumentation().getTargetContext();
final CountDownLatch countDownLatch = new CountDownLatch(5);
PlaybackServiceMediaPlayer.PSMPCallback callback = new DefaultPSMPCallback() {
@Override
public void statusChanged(LocalPSMP.PSMPInfo newInfo) {
try {
checkPSMPInfo(newInfo);
if (newInfo.playerStatus == PlayerStatus.ERROR)
throw new IllegalStateException("MediaPlayer error");
if (countDownLatch.getCount() == 0) {
fail();
} else if (countDownLatch.getCount() == 5) {
assertEquals(PlayerStatus.INITIALIZING, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 4) {
assertEquals(PlayerStatus.INITIALIZED, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 3) {
assertEquals(PlayerStatus.PREPARING, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 2) {
assertEquals(PlayerStatus.PREPARED, newInfo.playerStatus);
} else if (countDownLatch.getCount() == 1) {
assertEquals(PlayerStatus.PLAYING, newInfo.playerStatus);
}
} catch (AssertionFailedError e) {
if (assertionError == null)
assertionError = e;
} finally {
countDownLatch.countDown();
}
}
};
PlaybackServiceMediaPlayer psmp = new LocalPSMP(c, callback);
Playable p = writeTestPlayable(PLAYABLE_FILE_URL, PLAYABLE_LOCAL_URL);
psmp.playMediaObject(p, false, true, true);
boolean res = countDownLatch.await(LATCH_TIMEOUT_SECONDS, TimeUnit.SECONDS);
if (assertionError != null)
throw assertionError;
assertTrue(res);
assertTrue(psmp.getPSMPInfo().playerStatus == PlayerStatus.PLAYING);
psmp.shutdown();
}
Aggregations