use of com.vaadin.flow.router.legacy.RouterConfiguration in project flow by vaadin.
the class RouterConfigurationTest method assertRoutePriority.
private static void assertRoutePriority(String location, String strongerRoute, String weakerRoute) {
// First verify that the test makes sense
assertMatches(location, strongerRoute);
assertMatches(location, weakerRoute);
NavigationHandler weakerHandler = createNoopHandler();
NavigationHandler strongerHandler = createNoopHandler();
RouterConfiguration configuration = createConfiguration();
configuration.setRoute(strongerRoute, strongerHandler);
configuration.setRoute(weakerRoute, weakerHandler);
Optional<NavigationHandler> handler = configuration.resolveRoute(new Location(location));
Assert.assertSame(handler.get(), strongerHandler);
// Do the same again with setRoute run in the opposite order
configuration = createConfiguration();
configuration.setRoute(weakerRoute, weakerHandler);
configuration.setRoute(strongerRoute, strongerHandler);
handler = configuration.resolveRoute(new Location(location));
Assert.assertSame(handler.get(), strongerHandler);
}
use of com.vaadin.flow.router.legacy.RouterConfiguration in project flow by vaadin.
the class RouterTest method testConfigurationImmutable.
@Test(expected = IllegalStateException.class)
public void testConfigurationImmutable() {
Router router = new Router();
ImmutableRouterConfiguration configuration = router.getConfiguration();
((RouterConfiguration) configuration).setResolver(e -> null);
}
use of com.vaadin.flow.router.legacy.RouterConfiguration in project flow by vaadin.
the class RouterTest method testLeakedConfigurationImmutable.
@Test
public void testLeakedConfigurationImmutable() {
Router router = new Router();
AtomicReference<RouterConfiguration> configurationLeak = new AtomicReference<>();
router.reconfigure(configurationLeak::set);
Resolver newResolver = e -> null;
configurationLeak.get().setResolver(newResolver);
Assert.assertNotSame(newResolver, router.getConfiguration().getResolver());
}
Aggregations