Search in sources :

Example 11 with TaskExecutor

use of org.springframework.core.task.TaskExecutor in project plugin-prov-azure by ligoj.

the class ProvAzurePluginResourceTest method checkStatusShudownFailed.

/**
 * Authority is valid, but the token cannot be acquired
 */
@Test
public void checkStatusShudownFailed() throws Exception {
    prepareMockAuth();
    httpServer.start();
    final TaskExecutor taskExecutor = Mockito.mock(TaskExecutor.class);
    final ProvAzurePluginResource resource = newResource(new ExecutorServiceAdapter(taskExecutor) {

        @Override
        public void shutdown() {
            throw new IllegalStateException();
        }
    });
    Assertions.assertThrows(IllegalStateException.class, () -> {
        resource.checkStatus(subscriptionResource.getParametersNoCheck(subscription));
    });
}
Also used : TaskExecutor(org.springframework.core.task.TaskExecutor) ExecutorServiceAdapter(org.springframework.core.task.support.ExecutorServiceAdapter) Test(org.junit.jupiter.api.Test) AbstractServerTest(org.ligoj.app.AbstractServerTest)

Example 12 with TaskExecutor

use of org.springframework.core.task.TaskExecutor in project qpp-conversion-tool by CMSgov.

the class ConcurrencyConfigTest method testIsSync.

@Test
void testIsSync() {
    TaskExecutor executor = new ConcurrencyConfig().taskExecutor();
    assertThat(executor).isInstanceOf(SyncTaskExecutor.class);
}
Also used : SyncTaskExecutor(org.springframework.core.task.SyncTaskExecutor) TaskExecutor(org.springframework.core.task.TaskExecutor) Test(org.junit.jupiter.api.Test)

Example 13 with TaskExecutor

use of org.springframework.core.task.TaskExecutor in project spring-framework by spring-projects.

the class ExecutorSubscribableChannelTests method sendWithExecutor.

@Test
public void sendWithExecutor() {
    BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
    TaskExecutor executor = mock(TaskExecutor.class);
    ExecutorSubscribableChannel testChannel = new ExecutorSubscribableChannel(executor);
    testChannel.addInterceptor(interceptor);
    testChannel.subscribe(this.handler);
    testChannel.send(this.message);
    verify(executor).execute(this.runnableCaptor.capture());
    verify(this.handler, never()).handleMessage(this.message);
    this.runnableCaptor.getValue().run();
    verify(this.handler).handleMessage(this.message);
    assertThat(interceptor.getCounter().get()).isEqualTo(1);
    assertThat(interceptor.wasAfterHandledInvoked()).isTrue();
}
Also used : TaskExecutor(org.springframework.core.task.TaskExecutor) Test(org.junit.jupiter.api.Test)

Example 14 with TaskExecutor

use of org.springframework.core.task.TaskExecutor in project spring-framework by spring-projects.

the class WebSocketMessageBrokerStatsTests method inboundAndOutboundChannelsWithMockedTaskExecutor.

@Test
void inboundAndOutboundChannelsWithMockedTaskExecutor() {
    TaskExecutor executor = mock(TaskExecutor.class);
    stats.setInboundChannelExecutor(executor);
    stats.setOutboundChannelExecutor(executor);
    assertThat(stats.getClientInboundExecutorStatsInfo()).as("inbound channel stats").isEqualTo("unknown");
    assertThat(stats.getClientOutboundExecutorStatsInfo()).as("outbound channel stats").isEqualTo("unknown");
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) TaskExecutor(org.springframework.core.task.TaskExecutor) Test(org.junit.jupiter.api.Test)

Aggregations

TaskExecutor (org.springframework.core.task.TaskExecutor)14 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)5 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)5 SimpleAsyncTaskExecutor (org.springframework.core.task.SimpleAsyncTaskExecutor)4 HashMap (java.util.HashMap)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 ISender (nl.nn.adapterframework.core.ISender)2 SenderException (nl.nn.adapterframework.core.SenderException)2 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)2 Guard (nl.nn.adapterframework.util.Guard)2 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)2 AsyncExecutor (org.activiti.engine.impl.asyncexecutor.AsyncExecutor)2 SpringAsyncExecutor (org.activiti.spring.SpringAsyncExecutor)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 MessagingException (org.springframework.messaging.MessagingException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ISenderWithParameters (nl.nn.adapterframework.core.ISenderWithParameters)1 StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)1