Search in sources :

Example 6 with SchedulerService

use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.

the class ExtensionMessageSourceTestCase method failedToCreateFlowTrigger.

@Test
public void failedToCreateFlowTrigger() throws Exception {
    Exception e = new RuntimeException();
    SchedulerService schedulerService = muleContext.getSchedulerService();
    doThrow(e).when(schedulerService).cpuLightScheduler();
    messageSource.initialise();
    final Throwable throwable = catchThrowable(messageSource::start);
    assertThat(throwable, is(instanceOf(LifecycleException.class)));
    assertThat(throwable.getCause(), is(sameInstance(e)));
}
Also used : SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) ThrowableAssert.catchThrowable(org.assertj.core.api.ThrowableAssert.catchThrowable) MuleException(org.mule.runtime.api.exception.MuleException) LifecycleException(org.mule.runtime.api.lifecycle.LifecycleException) IOException(java.io.IOException) RetryPolicyExhaustedException(org.mule.runtime.core.api.retry.policy.RetryPolicyExhaustedException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test)

Example 7 with SchedulerService

use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.

the class ExtensionMessageSourceTestCase method failedToCreateRetryScheduler.

@Test
public void failedToCreateRetryScheduler() throws Exception {
    messageSource.initialise();
    Exception e = new RuntimeException();
    SchedulerService schedulerService = muleContext.getSchedulerService();
    doThrow(e).when(schedulerService).cpuLightScheduler();
    final Throwable throwable = catchThrowable(messageSource::start);
    assertThat(throwable.getCause(), is(sameInstance(e)));
}
Also used : SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) ThrowableAssert.catchThrowable(org.assertj.core.api.ThrowableAssert.catchThrowable) MuleException(org.mule.runtime.api.exception.MuleException) LifecycleException(org.mule.runtime.api.lifecycle.LifecycleException) IOException(java.io.IOException) RetryPolicyExhaustedException(org.mule.runtime.core.api.retry.policy.RetryPolicyExhaustedException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test)

Example 8 with SchedulerService

use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.

the class ServerNotificationsTestCase method testAsyncNotificationRejectedExecution.

@Test
public void testAsyncNotificationRejectedExecution() {
    MuleContext muleContext = mock(MuleContext.class);
    SchedulerService schedulerService = mock(SchedulerService.class);
    Scheduler scheduler = mock(Scheduler.class);
    when(muleContext.getSchedulerService()).thenReturn(schedulerService);
    when(schedulerService.cpuLightScheduler()).thenReturn(scheduler);
    when(scheduler.submit(any(Callable.class))).thenThrow(new RejectedExecutionException());
    Notification notification = mock(CustomNotification.class);
    when(notification.isSynchronous()).thenReturn(false);
    NotificationListener notificationListener = mock(CustomNotificationListener.class);
    ServerNotificationManager manager = new ServerNotificationManager();
    manager.setMuleContext(muleContext);
    manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class);
    manager.addListener(notificationListener);
    manager.fireNotification(notification);
    verify(notificationListener, never()).onNotification(notification);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) Scheduler(org.mule.runtime.api.scheduler.Scheduler) Callable(java.util.concurrent.Callable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Notification(org.mule.runtime.api.notification.Notification) CustomNotification(org.mule.runtime.api.notification.CustomNotification) CustomNotificationListener(org.mule.runtime.api.notification.CustomNotificationListener) NotificationListener(org.mule.runtime.api.notification.NotificationListener) Test(org.junit.Test)

Aggregations

SchedulerService (org.mule.runtime.api.scheduler.SchedulerService)8 Test (org.junit.Test)4 MuleException (org.mule.runtime.api.exception.MuleException)3 SimpleUnitTestSupportSchedulerService (org.mule.tck.SimpleUnitTestSupportSchedulerService)3 IOException (java.io.IOException)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)2 ConfigurationComponentLocator (org.mule.runtime.api.component.location.ConfigurationComponentLocator)2 ConnectionException (org.mule.runtime.api.connection.ConnectionException)2 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 LifecycleException (org.mule.runtime.api.lifecycle.LifecycleException)2 Scheduler (org.mule.runtime.api.scheduler.Scheduler)2 RetryPolicyExhaustedException (org.mule.runtime.core.api.retry.policy.RetryPolicyExhaustedException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 Thread.currentThread (java.lang.Thread.currentThread)1 ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptyMap (java.util.Collections.emptyMap)1