Open
Description
I have a component annotated with @RouteScope and when I try to init the app in the test, I get the error:
Caused by: java.lang.IllegalStateException: UI bean store is not found by the initial UI id via the key 'uid-1' and it's not found by the key 'win-ROOT-2521314-0.2626611481' after relocation.
at com.vaadin.flow.spring.scopes.VaadinRouteScope$RouteStoreWrapper.relocateStore(VaadinRouteScope.java:123)
at com.vaadin.flow.spring.scopes.VaadinRouteScope$RouteStoreWrapper.lambda$getBeanStore$b500751e$1(VaadinRouteScope.java:100)
at com.vaadin.flow.component.page.Page.retrieveExtendedClientDetails(Page.java:567)
at com.github.mvysny.kaributesting.v10.MockPage.retrieveExtendedClientDetails(MockVaadin.kt:421)
at com.vaadin.flow.spring.scopes.VaadinRouteScope$RouteStoreWrapper.getBeanStore(VaadinRouteScope.java:99)
at com.vaadin.flow.spring.scopes.VaadinRouteScope.getBeanStore(VaadinRouteScope.java:412)
at com.vaadin.flow.spring.scopes.AbstractScope.get(AbstractScope.java:44)
at com.vaadin.flow.spring.scopes.VaadinRouteScope.get(VaadinRouteScope.java:67)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:371)
... 103 more
it seems to me this error is caused by this commit: 7d0435e. I tested using version 1.3.16 and it works ok.
This is the code in my test class:
private static final Routes routes = new Routes().autoDiscoverViews("the.package");
@Autowired
private ApplicationContext ctx;
@BeforeEach
public void mockVaadin() {
final Function0<UI> uiFactory = UI::new;
final SpringServlet servlet = new MockSpringServlet(routes, ctx, uiFactory);
MockVaadin.setup(uiFactory, servlet);
}
@BeforeEach
public void navigate() {
UI.getCurrent()
.navigate(AView.class);
_assertOne(AView.class);
}
and this is what I have in my POM:
<dependency>
<groupId>com.github.mvysny.kaributesting</groupId>
<artifactId>karibu-testing-v10-spring</artifactId>
<version>1.3.18</version>
<scope>test</scope>
</dependency>
The code that triggers the bug is something like:
@Route(...)
public class ARoute {
...
@Inject
private TheClassThatCausesProblem the classe;
...
}
and:
@RouteScope
public class TheClassThatCausesProblem extends HorizontalLayout {
...
}
Activity