use of org.springframework.core.task.SyncTaskExecutor in project spring-integration by spring-projects.
the class ExecutorChannelTests method interceptorWithModifiedMessage.
@Test
public void interceptorWithModifiedMessage() {
ExecutorChannel channel = new ExecutorChannel(new SyncTaskExecutor());
channel.setBeanFactory(mock(BeanFactory.class));
channel.afterPropertiesSet();
MessageHandler handler = mock(MessageHandler.class);
Message<?> expected = mock(Message.class);
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
interceptor.setMessageToReturn(expected);
channel.addInterceptor(interceptor);
channel.subscribe(handler);
channel.send(new GenericMessage<Object>("foo"));
verify(handler).handleMessage(expected);
assertEquals(1, interceptor.getCounter().get());
assertTrue(interceptor.wasAfterHandledInvoked());
}
use of org.springframework.core.task.SyncTaskExecutor in project iaf by ibissource.
the class OpenApiTestBase method getTaskExecutor.
/**
* TaskExecutor used to start and configure adapters
*/
private static TaskExecutor getTaskExecutor() {
if (taskExecutor == null) {
// Make sure all threads are joining the calling thread
SyncTaskExecutor executor = new SyncTaskExecutor();
taskExecutor = executor;
}
return taskExecutor;
}
use of org.springframework.core.task.SyncTaskExecutor in project cloudbreak by hortonworks.
the class AbstractActionTest method setup.
@Before
public void setup() throws Exception {
underTest = spy(new TestAction());
underTest.setFailureEvent(Event.FAILURE);
MockitoAnnotations.initMocks(this);
BDDMockito.given(flow.getFlowId()).willReturn(FLOW_ID);
BDDMockito.given(runningFlows.get(anyString())).willReturn(flow);
StateMachineConfigurationBuilder<State, Event> configurationBuilder = new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configurationBuilder.setTaskExecutor(new SyncTaskExecutor());
StateMachineStateBuilder<State, Event> stateBuilder = new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
stateBuilder.withStates().initial(State.INIT).state(State.DOING, underTest, null);
StateMachineTransitionBuilder<State, Event> transitionBuilder = new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
transitionBuilder.withExternal().source(State.INIT).target(State.DOING).event(Event.DOIT);
stateMachine = new ObjectStateMachineFactory<>(configurationBuilder.build(), transitionBuilder.build(), stateBuilder.build()).getStateMachine();
stateMachine.start();
}
use of org.springframework.core.task.SyncTaskExecutor in project spring-framework by spring-projects.
the class WebAsyncManager method logExecutorWarning.
private void logExecutorWarning() {
if (taskExecutorWarning && logger.isWarnEnabled()) {
synchronized (DEFAULT_TASK_EXECUTOR) {
AsyncTaskExecutor executor = this.taskExecutor;
if (taskExecutorWarning && (executor instanceof SimpleAsyncTaskExecutor || executor instanceof SyncTaskExecutor)) {
String executorTypeName = executor.getClass().getSimpleName();
logger.warn("\n!!!\n" + "An Executor is required to handle java.util.concurrent.Callable return values.\n" + "Please, configure a TaskExecutor in the MVC config under \"async support\".\n" + "The " + executorTypeName + " currently in use is not suitable under load.\n" + "-------------------------------\n" + "Request URI: '" + formatRequestUri() + "'\n" + "!!!");
taskExecutorWarning = false;
}
}
}
}
Aggregations