Search in sources :

Example 41 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.

the class RegistrationApplicationListenerTest method should_not_deregister_when_not_autoDeregister.

@Test
public void should_not_deregister_when_not_autoDeregister() {
    ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
    ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
    RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
    listener.onClosedContext(new ContextClosedEvent(mock(WebApplicationContext.class)));
    verify(registrator, never()).deregister();
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) ContextClosedEvent(org.springframework.context.event.ContextClosedEvent) Test(org.junit.jupiter.api.Test)

Example 42 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.

the class RegistrationApplicationListenerTest method should_not_deregister_when_autoDeregister_and_not_root.

@Test
public void should_not_deregister_when_autoDeregister_and_not_root() {
    ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
    ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
    RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
    listener.setAutoDeregister(true);
    ApplicationContext mockContext = mock(ApplicationContext.class);
    when(mockContext.getParent()).thenReturn(mock(ApplicationContext.class));
    listener.onClosedContext(new ContextClosedEvent(mockContext));
    verify(registrator, never()).deregister();
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) ContextClosedEvent(org.springframework.context.event.ContextClosedEvent) Test(org.junit.jupiter.api.Test)

Example 43 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.

the class RegistrationApplicationListenerTest method should_deregister_when_autoDeregister.

@Test
public void should_deregister_when_autoDeregister() {
    ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
    ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
    RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
    listener.setAutoDeregister(true);
    listener.onClosedContext(new ContextClosedEvent(mock(ApplicationContext.class)));
    verify(registrator).deregister();
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) ContextClosedEvent(org.springframework.context.event.ContextClosedEvent) Test(org.junit.jupiter.api.Test)

Example 44 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.

the class RegistrationApplicationListenerTest method should_init_and_shutdown_taskScheduler.

@Test
public void should_init_and_shutdown_taskScheduler() {
    ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
    ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
    RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
    listener.afterPropertiesSet();
    verify(scheduler, times(1)).afterPropertiesSet();
    listener.destroy();
    verify(scheduler, times(1)).destroy();
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 45 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-framework by spring-projects.

the class WebSocketConfigurationSupport method initDefaultSockJsScheduler.

private ThreadPoolTaskScheduler initDefaultSockJsScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setThreadNamePrefix("SockJS-");
    scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
    scheduler.setRemoveOnCancelPolicy(true);
    return scheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)

Aggregations

ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)122 Test (org.junit.Test)41 Bean (org.springframework.context.annotation.Bean)32 BeanFactory (org.springframework.beans.factory.BeanFactory)31 Test (org.junit.jupiter.api.Test)26 CountDownLatch (java.util.concurrent.CountDownLatch)19 QueueChannel (org.springframework.integration.channel.QueueChannel)19 GenericMessage (org.springframework.messaging.support.GenericMessage)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 ExecutorService (java.util.concurrent.ExecutorService)10 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)8 MqttPahoMessageDrivenChannelAdapter (org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 MqttPahoMessageHandler (org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler)6 JmsTemplate (org.springframework.jms.core.JmsTemplate)6 ArrayList (java.util.ArrayList)5 Log (org.apache.commons.logging.Log)5 MessageChannel (org.springframework.messaging.MessageChannel)5 File (java.io.File)4 ConnectionFactory (javax.jms.ConnectionFactory)4