use of com.vaadin.flow.spring.SpringServlet in project flow by vaadin.
the class RequestUtilTest method setupMockServlet.
private SpringServlet setupMockServlet() {
SpringServlet servlet = Mockito.mock(SpringServlet.class);
SpringVaadinServletService service = Mockito.mock(SpringVaadinServletService.class);
Router router = Mockito.mock(Router.class);
RouteRegistry routeRegistry = Mockito.mock(RouteRegistry.class);
Mockito.when(springServletRegistration.getServlet()).thenReturn(servlet);
Mockito.when(servlet.getService()).thenReturn(service);
Mockito.when(service.getRouter()).thenReturn(router);
Mockito.when(router.getRegistry()).thenReturn(routeRegistry);
return servlet;
}
use of com.vaadin.flow.spring.SpringServlet in project flow by vaadin.
the class RequestUtilTest method testAnonymousRouteRequest_rootMappedServlet_publicView.
@Test
public void testAnonymousRouteRequest_rootMappedServlet_publicView() {
Mockito.when(vaadinConfigurationProperties.getUrlMapping()).thenReturn("/*");
SpringServlet servlet = setupMockServlet();
addRoute(servlet, PublicRootView.class);
addRoute(servlet, AnotherPublicView.class);
MockHttpServletRequest request = createRequest(null);
request.setServletPath("/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
request = createRequest("other");
request.setServletPath("/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
}
use of com.vaadin.flow.spring.SpringServlet in project flow by vaadin.
the class RequestUtilTest method testAnonymousRouteRequest_fooMappedServlet_publicView.
@Test
public void testAnonymousRouteRequest_fooMappedServlet_publicView() {
Mockito.when(vaadinConfigurationProperties.getUrlMapping()).thenReturn("/foo/*");
SpringServlet servlet = setupMockServlet();
addRoute(servlet, PublicRootView.class);
addRoute(servlet, AnotherPublicView.class);
MockHttpServletRequest request = createRequest(null);
request.setServletPath("/foo/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
request = createRequest("");
request.setServletPath("/foo/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
request = createRequest("/");
request.setServletPath("/foo/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
request = createRequest("other");
request.setServletPath("/foo/");
Assert.assertTrue(requestUtil.isAnonymousRoute(request));
}
use of com.vaadin.flow.spring.SpringServlet in project flow by vaadin.
the class RequestUtilTest method testAnonymousRouteRequest_fooMappedServlet_publicViewPathOutsideServlet.
@Test
public void testAnonymousRouteRequest_fooMappedServlet_publicViewPathOutsideServlet() {
Mockito.when(vaadinConfigurationProperties.getUrlMapping()).thenReturn("/foo/*");
SpringServlet servlet = setupMockServlet();
addRoute(servlet, PublicRootView.class);
addRoute(servlet, AnotherPublicView.class);
MockHttpServletRequest request = createRequest(null);
request.setServletPath("/");
Assert.assertFalse(requestUtil.isAnonymousRoute(request));
request = createRequest("other");
request.setServletPath("/");
Assert.assertFalse(requestUtil.isAnonymousRoute(request));
}
Aggregations