Search in sources :

Example 56 with AssertionFailedError

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());
            }
        }
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) AssertionFailedError(junit.framework.AssertionFailedError) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 57 with AssertionFailedError

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();
    }
}
Also used : NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) Clock(org.activiti.engine.runtime.Clock) DefaultClockFactory(org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory) SimulationProcessEngineFactory(org.activiti.crystalball.simulator.impl.SimulationProcessEngineFactory) AssertionFailedError(junit.framework.AssertionFailedError) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 58 with AssertionFailedError

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();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.core.util.playback.Playable) LocalPSMP(de.danoeh.antennapod.core.service.playback.LocalPSMP) PlaybackServiceMediaPlayer(de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer) CountDownLatch(java.util.concurrent.CountDownLatch) AssertionFailedError(junit.framework.AssertionFailedError)

Example 59 with AssertionFailedError

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();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.core.util.playback.Playable) LocalPSMP(de.danoeh.antennapod.core.service.playback.LocalPSMP) PlaybackServiceMediaPlayer(de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer) CountDownLatch(java.util.concurrent.CountDownLatch) AssertionFailedError(junit.framework.AssertionFailedError)

Example 60 with AssertionFailedError

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();
}
Also used : Context(android.content.Context) Playable(de.danoeh.antennapod.core.util.playback.Playable) LocalPSMP(de.danoeh.antennapod.core.service.playback.LocalPSMP) PlaybackServiceMediaPlayer(de.danoeh.antennapod.core.service.playback.PlaybackServiceMediaPlayer) CountDownLatch(java.util.concurrent.CountDownLatch) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15