use of org.springframework.scheduling.TaskScheduler in project spring-boot-admin by codecentric.
the class RegistrationApplicationListenerTest method test_no_register.
@Test
public void test_no_register() throws Exception {
ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
TaskScheduler scheduler = mock(TaskScheduler.class);
RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
listener.setAutoRegister(false);
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null, mock(ConfigurableWebApplicationContext.class)));
verify(scheduler, never()).scheduleAtFixedRate(isA(Runnable.class), eq(10_000L));
}
use of org.springframework.scheduling.TaskScheduler in project spring-boot-admin by codecentric.
the class RegistrationApplicationListenerTest method test_no_deregister.
@Test
public void test_no_deregister() throws Exception {
ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
TaskScheduler scheduler = mock(TaskScheduler.class);
RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
listener.onClosedContext(new ContextClosedEvent(mock(EmbeddedWebApplicationContext.class)));
verify(registrator, never()).deregister();
}
use of org.springframework.scheduling.TaskScheduler in project spring-framework by spring-projects.
the class DefaultStompSessionTests method receiptNotReceived.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void receiptNotReceived() throws Exception {
TaskScheduler taskScheduler = mock(TaskScheduler.class);
this.session.afterConnected(this.connection);
this.session.setTaskScheduler(taskScheduler);
AtomicReference<Boolean> notReceived = new AtomicReference<>();
ScheduledFuture future = mock(ScheduledFuture.class);
when(taskScheduler.schedule(any(Runnable.class), any(Date.class))).thenReturn(future);
StompHeaders headers = new StompHeaders();
headers.setDestination("/topic/foo");
headers.setReceipt("my-receipt");
Receiptable receiptable = this.session.send(headers, "payload");
receiptable.addReceiptLostTask(() -> notReceived.set(true));
ArgumentCaptor<Runnable> taskCaptor = ArgumentCaptor.forClass(Runnable.class);
verify(taskScheduler).schedule(taskCaptor.capture(), (Date) notNull());
Runnable scheduledTask = taskCaptor.getValue();
assertNotNull(scheduledTask);
assertNull(notReceived.get());
scheduledTask.run();
assertTrue(notReceived.get());
verify(future).cancel(true);
verifyNoMoreInteractions(future);
}
use of org.springframework.scheduling.TaskScheduler in project spring-framework by spring-projects.
the class SockJsWebSocketHandlerTests method getSubProtocolsNone.
@Test
public void getSubProtocolsNone() throws Exception {
WebSocketHandler handler = new TextWebSocketHandler();
TaskScheduler scheduler = mock(TaskScheduler.class);
DefaultSockJsService service = new DefaultSockJsService(scheduler);
WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null);
SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session);
assertNull(sockJsHandler.getSubProtocols());
}
use of org.springframework.scheduling.TaskScheduler in project spring-framework by spring-projects.
the class SockJsWebSocketHandlerTests method getSubProtocols.
@Test
public void getSubProtocols() throws Exception {
SubscribableChannel channel = mock(SubscribableChannel.class);
SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel);
StompSubProtocolHandler stompHandler = new StompSubProtocolHandler();
handler.addProtocolHandler(stompHandler);
TaskScheduler scheduler = mock(TaskScheduler.class);
DefaultSockJsService service = new DefaultSockJsService(scheduler);
WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null);
SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session);
assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols());
}
Aggregations