Skip to content

Commit

Permalink
fix: get all available task executors instead of one via getBean (#700)
Browse files Browse the repository at this point in the history
* fix: get all available task executors instead of one  via getBean

fixes #697
  • Loading branch information
Denis authored Dec 9, 2020
1 parent 347decc commit 1ee823e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ protected Collection<Class<?>> getServiceTypes() {
@Override
protected Lookup createLookup(
Map<Class<?>, Collection<Object>> services) {
services.put(Executor.class, Collections
.singleton(appContext.getBean(TaskExecutor.class)));
Map<String, TaskExecutor> executors = appContext
.getBeansOfType(TaskExecutor.class);
if (!executors.isEmpty()) {
services.put(Executor.class, Collections
.singleton(executors.values().iterator().next()));
}
return super.createLookup(services);
}

Expand Down Expand Up @@ -739,7 +743,8 @@ private List<String> getDefaultPackages() {

private List<String> getLookupPackages() {
return Stream.concat(getDefaultPackages().stream(),
Stream.of("com.vaadin.flow.server.frontend.fusion", "com.vaadin.flow.component.polymertemplate.rpc"))
Stream.of("com.vaadin.flow.server.frontend.fusion",
"com.vaadin.flow.component.polymertemplate.rpc"))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public class VaadinServletContextInitializerTest {
public void init() {
MockitoAnnotations.openMocks(this);

Mockito.when(applicationContext.getBean(TaskExecutor.class))
.thenReturn(executor);
Mockito.when(applicationContext.getBeansOfType(TaskExecutor.class))
.thenReturn(Collections.singletonMap("foo", executor));

PowerMockito.mockStatic(
VaadinServletContextInitializer.SpringStubServletConfig.class);
Expand Down Expand Up @@ -107,7 +107,7 @@ public void onStartup_devModeNotInitialized_devModeInitialized()
theMock.verifyNoMoreInteractions();
}

Mockito.verify(applicationContext).getBean(TaskExecutor.class);
Mockito.verify(applicationContext).getBeansOfType(TaskExecutor.class);
Mockito.verify(servletContext).setAttribute(
Mockito.eq(Lookup.class.getName()), capture.capture());
Lookup lookup = capture.getValue();
Expand Down

0 comments on commit 1ee823e

Please sign in to comment.