List of usage examples for org.springframework.core.task.support ExecutorServiceAdapter ExecutorServiceAdapter
public ExecutorServiceAdapter(TaskExecutor taskExecutor)
From source file:org.ligoj.app.plugin.prov.azure.ProvAzurePluginResourceTest.java
private ExecutorService newExecutorService() { final TaskExecutor taskExecutor = Mockito.mock(TaskExecutor.class); return new ExecutorServiceAdapter(taskExecutor) { @Override//from w w w . j a v a 2s . co m public void shutdown() { // Do nothing } }; }
From source file:org.ligoj.app.plugin.prov.azure.ProvAzurePluginResourceTest.java
/** * Authority is valid, but the token cannot be acquired *//*from ww w . j ava 2 s. c o m*/ @Test public void checkStatusShudownFailed() throws Exception { prepareMockAuth(); 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)); }); }
From source file:org.ligoj.app.plugin.vm.azure.VmAzurePluginResourceTest.java
/** * Authority is valid, but the token cannot be acquired *//* www . ja v a 2s . co m*/ @Test public void checkStatusShudownFailed() throws Exception { prepareMockAuth(); httpServer.start(); final TaskExecutor taskExecutor = Mockito.mock(TaskExecutor.class); final VmAzurePluginResource resource = newResource(new ExecutorServiceAdapter(taskExecutor) { @Override public void shutdown() { throw new IllegalStateException(); } }); Assertions.assertThrows(IllegalStateException.class, () -> { resource.checkStatus(subscriptionResource.getParametersNoCheck(subscription)); }); }
From source file:org.springframework.integration.kafka.listener.QueueingMessageListenerInvoker.java
public QueueingMessageListenerInvoker(int capacity, final OffsetManager offsetManager, Object delegate, final ErrorHandler errorHandler, Executor executor, boolean autoCommitOnError) { this.capacity = capacity; this.autoCommitOnError = autoCommitOnError; if (delegate instanceof MessageListener) { this.messageListener = (MessageListener) delegate; this.acknowledgingMessageListener = null; } else if (delegate instanceof AcknowledgingMessageListener) { this.acknowledgingMessageListener = (AcknowledgingMessageListener) delegate; this.messageListener = null; } else {// ww w. j a v a2s.co m // it's neither, an exception will be thrown throw new IllegalArgumentException("Either a " + MessageListener.class.getName() + " or a " + AcknowledgingMessageListener.class.getName() + " must be provided"); } this.offsetManager = offsetManager; this.errorHandler = errorHandler; if (executor != null) { this.executorService = new ExecutorServiceAdapter(new ConcurrentTaskExecutor(executor)); } else { this.executorService = Executors.newSingleThreadExecutor(); } }