Search in sources :

Example 1 with InvalidRouteConfigurationException

use of com.vaadin.flow.server.InvalidRouteConfigurationException in project flow by vaadin.

the class RouteRegistryInitializer method onStartup.

@Override
public void onStartup(Set<Class<?>> classSet, ServletContext servletContext) throws ServletException {
    try {
        if (classSet == null) {
            RouteRegistry.getInstance(servletContext).setNavigationTargets(Collections.emptySet());
            return;
        }
        Set<Class<? extends Component>> routes = validateRouteClasses(classSet.stream());
        RouteRegistry.getInstance(servletContext).setNavigationTargets(routes);
    } catch (InvalidRouteConfigurationException irce) {
        throw new ServletException("Exception while registering Routes on servlet startup", irce);
    }
}
Also used : ServletException(javax.servlet.ServletException) InvalidRouteConfigurationException(com.vaadin.flow.server.InvalidRouteConfigurationException) Component(com.vaadin.flow.component.Component)

Example 2 with InvalidRouteConfigurationException

use of com.vaadin.flow.server.InvalidRouteConfigurationException in project flow by vaadin.

the class RouterTest method verify_collisions_not_allowed_with_naming_convention.

@Test
public void verify_collisions_not_allowed_with_naming_convention() {
    InvalidRouteConfigurationException exception = null;
    try {
        setNavigationTargets(NamingConvention.class, NamingConventionView.class);
    } catch (InvalidRouteConfigurationException e) {
        exception = e;
    }
    Assert.assertNotNull("Routes with same navigation target should not be allowed", exception);
}
Also used : InvalidRouteConfigurationException(com.vaadin.flow.server.InvalidRouteConfigurationException) Test(org.junit.Test)

Example 3 with InvalidRouteConfigurationException

use of com.vaadin.flow.server.InvalidRouteConfigurationException in project flow by vaadin.

the class RouteRegistryInitializerTest method routeFilter_ignoresErrorTargets.

@Test
public void routeFilter_ignoresErrorTargets() throws InvalidRouteConfigurationException {
    registry.setErrorNavigationTargets(Stream.of(IgnoredErrorView.class, FileNotFound.class).collect(Collectors.toSet()));
    Assert.assertTrue(registry.getErrorNavigationTarget(new NotFoundException()).isPresent());
    ErrorTargetEntry errorTargetEntry = registry.getErrorNavigationTarget(new Exception()).get();
    Assert.assertNotEquals(IgnoredErrorView.class, errorTargetEntry.getNavigationTarget());
}
Also used : ErrorTargetEntry(com.vaadin.flow.router.internal.ErrorTargetEntry) NotFoundException(com.vaadin.flow.router.NotFoundException) ServletException(javax.servlet.ServletException) InvalidRouteLayoutConfigurationException(com.vaadin.flow.server.InvalidRouteLayoutConfigurationException) NotFoundException(com.vaadin.flow.router.NotFoundException) ExpectedException(org.junit.rules.ExpectedException) InvalidRouteConfigurationException(com.vaadin.flow.server.InvalidRouteConfigurationException) Test(org.junit.Test)

Aggregations

InvalidRouteConfigurationException (com.vaadin.flow.server.InvalidRouteConfigurationException)3 ServletException (javax.servlet.ServletException)2 Test (org.junit.Test)2 Component (com.vaadin.flow.component.Component)1 NotFoundException (com.vaadin.flow.router.NotFoundException)1 ErrorTargetEntry (com.vaadin.flow.router.internal.ErrorTargetEntry)1 InvalidRouteLayoutConfigurationException (com.vaadin.flow.server.InvalidRouteLayoutConfigurationException)1 ExpectedException (org.junit.rules.ExpectedException)1