use of com.vaadin.flow.server.WrappedHttpSession in project flow by vaadin.
the class DefaultTemplateParserTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
VaadinServletRequest request = Mockito.mock(VaadinServletRequest.class);
VaadinSession session = Mockito.mock(VaadinSession.class);
factory = (VaadinUriResolverFactory) vaadinRequest -> resolver;
Mockito.when(session.getAttribute(VaadinUriResolverFactory.class)).thenReturn(factory);
Mockito.when(service.getDependencyFilters()).thenReturn(Collections.emptyList());
WrappedHttpSession wrappedSession = Mockito.mock(WrappedHttpSession.class);
HttpSession httpSession = Mockito.mock(HttpSession.class);
Mockito.when(wrappedSession.getHttpSession()).thenReturn(httpSession);
servlet = new VaadinServlet() {
@Override
protected VaadinServletService createServletService() throws ServletException, ServiceException {
return service;
}
@Override
public ServletContext getServletContext() {
return servletContext;
}
};
Mockito.when(service.getServlet()).thenReturn(servlet);
Mockito.when(resolver.resolveVaadinUri("/bar.html")).thenReturn("bar.html");
Mockito.when(resolver.resolveVaadinUri("/bar1.html")).thenReturn("bar1.html");
Mockito.when(resolver.resolveVaadinUri("/bundle.html")).thenReturn("bundle.html");
Mockito.when(request.getWrappedSession()).thenReturn(wrappedSession);
Mockito.when(request.getServletPath()).thenReturn("");
Mockito.when(servletContext.getResourceAsStream("/bar.html")).thenReturn(new ByteArrayInputStream("<dom-module id='bar'></dom-module>".getBytes(StandardCharsets.UTF_8)));
Mockito.when(servletContext.getResourceAsStream("/bar1.html")).thenReturn(new ByteArrayInputStream("<dom-module id='foo'></dom-module>".getBytes(StandardCharsets.UTF_8)));
Mockito.when(servletContext.getResourceAsStream("/bundle.html")).thenReturn(getBundle(), getBundle(), getBundle());
CurrentInstance.set(VaadinRequest.class, request);
CurrentInstance.set(VaadinSession.class, session);
CurrentInstance.set(VaadinService.class, service);
}
Aggregations